Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7caa2a6ec0 | ||
|
|
cef5fb67bb | ||
|
|
0b87338fb9 | ||
|
|
2f25ac4542 | ||
|
|
0e76999e07 | ||
|
|
e8bbbc0492 | ||
|
|
74acbb6b25 | ||
|
|
3292b2efb7 | ||
|
|
8bda37b02d | ||
|
|
e73022e3c4 | ||
|
|
c4f5f80558 | ||
|
|
31a68bbb77 | ||
|
|
2f7a7ed095 | ||
|
|
6f8a092547 | ||
|
|
42a3e4ad9c | ||
|
|
429b5ba085 | ||
|
|
a0c68115c1 | ||
|
|
5864af0675 | ||
|
|
67b9407807 | ||
|
|
3486e5de0a | ||
|
|
b521fdff4e | ||
|
|
45e4ffbee7 | ||
|
|
bae5dafc0c | ||
|
|
dbe5aabe6d | ||
|
|
428c38c113 | ||
|
|
6cbeab1935 |
No files matched your search
@@ -314,6 +314,41 @@ jobs:
|
||||
- name: Run ${{ matrix.suite }}
|
||||
run: BEHAT_SUITES="${{ matrix.suite }}" python3 tests/acceptance/run-github.py
|
||||
|
||||
ldap-pool-tests:
|
||||
needs: [build-and-test]
|
||||
name: ldapPool-${{ matrix.suite }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
suite:
|
||||
- apiGraphUser,apiGraph,apiGraphGroup
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
|
||||
with:
|
||||
php-version: "8.4"
|
||||
extensions: curl, xml, mbstring, zip, ldap, gd
|
||||
tools: composer
|
||||
|
||||
- name: Install libvips runtime
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
# NEEDRESTART_MODE=a: auto-restart services silently; without this, needrestart can fail with exit code 6
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
- name: Restore binary permissions
|
||||
run: chmod +x ocis/bin/ocis tests/ociswrapper/bin/ociswrapper
|
||||
|
||||
- name: Run ${{ matrix.suite }} with OCIS_LDAP_POOL_ENABLED=true
|
||||
run: BEHAT_SUITES="${{ matrix.suite }}" OCIS_LDAP_POOL_ENABLED=true python3 tests/acceptance/run-github.py
|
||||
|
||||
core-api-tests:
|
||||
name: ${{ matrix.suite }}
|
||||
needs: [build-and-test]
|
||||
@@ -694,8 +729,70 @@ jobs:
|
||||
- name: Run WOPI validator (cs3)
|
||||
run: python3 tests/acceptance/run-wopi.py --type cs3
|
||||
|
||||
external-ldap-tests:
|
||||
name: external-ldap-smoke
|
||||
needs: [build-and-test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Enable pnpm
|
||||
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
|
||||
|
||||
# web/idp assets must be embedded for `ocis server` to come up (same as run-github.py)
|
||||
- name: Generate assets
|
||||
run: make ci-node-generate
|
||||
|
||||
- name: Build oCIS
|
||||
run: make -C ocis build
|
||||
|
||||
# Boots an external osixia LDAP + oCIS (embedded idm excluded) and runs the
|
||||
# smoke scope against the graph API — exercises the external-directory
|
||||
# read-after-write / retry path (OCISDEV-1030/1032/1033) that the embedded-idm
|
||||
# acceptance jobs never hit.
|
||||
- name: Run external-LDAP smoke
|
||||
run: tests/ldap-smoke/run.sh
|
||||
|
||||
external-ldap-distributed-tests:
|
||||
name: external-ldap-distributed-smoke
|
||||
needs: [build-and-test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Enable pnpm
|
||||
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
|
||||
|
||||
# web/idp assets must be embedded for `ocis server` to come up (same as run-github.py)
|
||||
- name: Generate assets
|
||||
run: make ci-node-generate
|
||||
|
||||
- name: Build oCIS
|
||||
run: make -C ocis build
|
||||
|
||||
# Distributed LDAP topology (proxy over an async syncrepl replica + write master);
|
||||
# the replication lag exercises the retry / read-after-write path (OCISDEV-1030/1032/1033).
|
||||
- name: Run external-LDAP distributed smoke
|
||||
run: tests/ldap-smoke-distributed/run.sh
|
||||
|
||||
all-acceptance-tests:
|
||||
needs: [detect-changes, local-api-tests, cli-tests, core-api-tests, litmus, cs3api, wopi-builtin, wopi-cs3, e2e-tests]
|
||||
needs: [detect-changes, local-api-tests, cli-tests, ldap-pool-tests, core-api-tests, litmus, cs3api, wopi-builtin, wopi-cs3, e2e-tests, external-ldap-tests, external-ldap-distributed-tests]
|
||||
runs-on: ubuntu-latest
|
||||
if: always()
|
||||
steps:
|
||||
|
||||
+1094
-5
File diff suppressed because it is too large.
Load diff
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
Bugfix: Do not disable personal space on inconclusive permission check
|
||||
Bugfix: Keep personal space when Drives.Create permission check is inconclusive
|
||||
|
||||
When a user's role is (re-)assigned, both the proxy (on OIDC login) and the graph
|
||||
appRoleAssignment handler check the `Drives.Create` permission to decide whether to
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,15 @@
|
||||
Bugfix: Prevent deleting your own account in the user management
|
||||
|
||||
In the admin settings user management, the account you are currently logged in
|
||||
as could be selected and included in a delete action, even though the backend
|
||||
always rejects self-deletion. Deleting a selection that included your own
|
||||
account produced a "Failed to delete 1 user" error and made your own row
|
||||
temporarily disappear from the list until the page was refreshed.
|
||||
|
||||
The delete action now excludes the current user from the request, so all other
|
||||
selected users are deleted while your own account is left untouched. When your
|
||||
own account is part of the selection, the delete confirmation dialog shows a
|
||||
hint that it will not be deleted.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12661
|
||||
https://github.com/owncloud/ocis/issues/12582
|
||||
@@ -0,0 +1,10 @@
|
||||
Bugfix: Stop breadcrumb items from being announced twice
|
||||
|
||||
Each breadcrumb list item had `tabindex="0"`, putting the item itself in the
|
||||
keyboard/screen reader focus order in addition to the link or button nested
|
||||
inside it. This caused every breadcrumb segment to be announced twice in a
|
||||
row. The list item is no longer a separate focus stop; only its inner link
|
||||
or button is, while the item remains focusable enough for existing
|
||||
drag-and-drop styling to keep working.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12643
|
||||
@@ -0,0 +1,8 @@
|
||||
Bugfix: Fix invisible group icon in share collaborator list
|
||||
|
||||
The icon shown next to group entries in the share collaborator autocomplete
|
||||
list used a color variable that no longer resolved to a valid value, making
|
||||
the icon effectively invisible against the background. The icon now uses the
|
||||
correct default text color variable so it renders properly again.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12722
|
||||
@@ -0,0 +1,12 @@
|
||||
Bugfix: Announce IDP sign-in errors and fix keyboard use
|
||||
|
||||
The login, consent, and account chooser pages did not announce error
|
||||
messages when they appeared, and invalid username/password fields gave no
|
||||
indication of their error state. The consent screen's scope list also had no
|
||||
programmatic link between each entry and its checkbox, and the account
|
||||
chooser's "continue as" and "use another account" entries could not be
|
||||
reached or activated with a keyboard. A visible focus outline on the login
|
||||
form's input fields had also been removed with no replacement. All of these
|
||||
have been fixed.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12649
|
||||
@@ -0,0 +1,28 @@
|
||||
Bugfix: Fix low-contrast form controls in dark and vault themes
|
||||
|
||||
Several form controls were hard to see against dark and vault theme
|
||||
backgrounds. The view-options range slider had no visible track border and
|
||||
relied on an opacity dip on hover, making it barely visible at rest. The
|
||||
switch component's off-state track and thumb, and its on-state thumb, used
|
||||
colors too close to their surrounding background to read as a toggle. The
|
||||
select combobox's highlighted/selected option text used a color too close to
|
||||
the highlight background.
|
||||
|
||||
The global search input's text color was forced with `!important`,
|
||||
overriding the theme-specific search text color some themes set, which made
|
||||
typed text render in white on a white search input background in the vault
|
||||
"Dark Theme – High Contrast". The search placeholder color also used an
|
||||
invalid CSS custom property fallback (a bare property name instead of a
|
||||
nested `var()`), silently breaking the placeholder color for any theme that
|
||||
didn't define a search-specific placeholder token, and the vault "Dark
|
||||
Theme"'s placeholder color was too close to its input's text and border color
|
||||
to read as muted.
|
||||
|
||||
The slider now has a visible border and no longer dims on rest, the switch
|
||||
and select now use colors with sufficient contrast against their
|
||||
backgrounds, the `!important` override blocking theme-specific search colors
|
||||
has been removed, the invalid placeholder fallback has been fixed, and the
|
||||
vault "Dark Theme" placeholder color has been changed to one with visible
|
||||
contrast against the input text.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12639
|
||||
@@ -0,0 +1,9 @@
|
||||
Bugfix: Fix keyboard navigation in "New" and "Upload" dropdown menus
|
||||
|
||||
Opening the "New" or "Upload" dropdown menu in the Files app toolbar did
|
||||
not move focus into the menu, so pressing the arrow keys had no effect
|
||||
on the highlighted item, unlike the existing right-click context menu.
|
||||
Both dropdowns now focus their first item on open, restoring arrow key
|
||||
navigation.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12646
|
||||
@@ -0,0 +1,10 @@
|
||||
Bugfix: Remove unneeded keyboard focus stops
|
||||
|
||||
Some icons and date columns in tables (spaces list, file list) could
|
||||
unexpectedly receive keyboard focus even though they don't trigger any
|
||||
action, adding unnecessary stops when tabbing through the page. The
|
||||
contextual helper icon also carried a label that duplicated the label
|
||||
already present on its surrounding button. These redundant focus stops
|
||||
and duplicate labels have been removed.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12645
|
||||
@@ -0,0 +1,15 @@
|
||||
Bugfix: Restore hover feedback in high-contrast and dark themes
|
||||
|
||||
The Light and Dark High-Contrast themes set the background-highlight color
|
||||
token equal to the default page background, making hover backgrounds
|
||||
indistinguishable from the resting background wherever background-highlight
|
||||
was used for interactive feedback, such as the global search results
|
||||
dropdown. The non-high-contrast Dark theme had the same collision.
|
||||
|
||||
background-highlight now matches background-hover in the affected theme
|
||||
definitions, and the search results dropdown and create-shortcut context
|
||||
menu now use the background-hover color directly for their hover and active
|
||||
states, since background-highlight is otherwise used for static surfaces
|
||||
like cards, modals and form fields rather than interaction feedback.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12613
|
||||
@@ -0,0 +1,12 @@
|
||||
Bugfix: Preserve accessibility focus in the file versions sidebar
|
||||
|
||||
Opening the file versions panel with a keyboard or screen reader could move
|
||||
focus to the main page, and restoring a version could briefly move focus to the
|
||||
main page before selecting the sidebar's back button. The sidebar now manages
|
||||
focus throughout panel transitions and loading states, restores focus to the
|
||||
control that opened it when closed, and returns focus to the restored version's
|
||||
Restore button after the operation completes. Version dates and action labels
|
||||
also provide clearer context for screen reader users without duplicate
|
||||
announcements or additional tab stops.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12630
|
||||
@@ -0,0 +1,10 @@
|
||||
Enhancement: Improve page structure on several pages
|
||||
|
||||
We've added missing `main` and `footer` regions to several pages (404,
|
||||
private link resolving, missing config, logout, access denied, public link
|
||||
resolving) for a more consistent page structure. We've also fixed the
|
||||
"Skip to main" link, which previously did nothing on pages using the plain
|
||||
layout (login, logout, public/private link pages) due to a missing target id
|
||||
and a stale cached DOM reference.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12637
|
||||
@@ -0,0 +1,6 @@
|
||||
Enhancement: Apply Kiteworks branding to the web theme
|
||||
|
||||
The default oCIS theme now uses the Kiteworks OSPO name, slogan and logos
|
||||
across all regular and vault mode themes.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12734
|
||||
@@ -0,0 +1,19 @@
|
||||
Enhancement: Add an opt-in bounded LDAP connection pool
|
||||
|
||||
The auth-basic, users, groups and graph services can now be switched from a
|
||||
single long-lived reconnecting LDAP connection to a bounded pool of connections,
|
||||
so concurrent requests no longer serialize on one socket. Connections are dialed
|
||||
and bound lazily on checkout, unhealthy connections are discarded and lazily
|
||||
re-dialed rather than eagerly reconnected, and checkout blocks with a configurable
|
||||
timeout once the pool is exhausted.
|
||||
|
||||
Pooling is off by default and fully backwards compatible. Enable it per service
|
||||
via 'OCIS_LDAP_POOL_ENABLED' (or the service-specific '<SERVICE>_LDAP_POOL_ENABLED'
|
||||
override), and tune it with 'OCIS_LDAP_POOL_SIZE' (default 5) and
|
||||
'OCIS_LDAP_POOL_CHECKOUT_TIMEOUT' (default 30s).
|
||||
|
||||
The graph service's identity backend now shares the same LDAP client
|
||||
implementation used by the reva auth/user/group managers instead of maintaining
|
||||
its own separate reconnecting client.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12688
|
||||
@@ -0,0 +1,14 @@
|
||||
Enhancement: Eliminate redundant LDAP read-after-write on create and update
|
||||
|
||||
The graph LDAP backend no longer re-reads an entry immediately after writing it
|
||||
just to recover the entry ID for the response. When oCIS generates the ID itself
|
||||
(GRAPH_LDAP_SERVER_UUID disabled), the create response is now synthesized from the
|
||||
data already sent to the directory, and update responses are built by folding the
|
||||
applied modifications onto the entry that was read before the write. This avoids a
|
||||
round-trip that, against a replicated directory reached through a proxy, could hit
|
||||
a lagging replica and fail or return stale data.
|
||||
|
||||
When the directory assigns the ID (GRAPH_LDAP_SERVER_UUID enabled), creates keep
|
||||
the existing read-back, since the generated ID cannot otherwise be recovered.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12618
|
||||
@@ -0,0 +1,7 @@
|
||||
Enhancement: Show the select-all checkbox label in tile view
|
||||
|
||||
The label of the select-all checkbox in the resource tiles view is now
|
||||
visible, improving the user experience by making it clear what the
|
||||
checkbox is for.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12640
|
||||
@@ -0,0 +1,18 @@
|
||||
Bugfix: Fix concurrent map access when listing shares
|
||||
|
||||
Listing shares could abort the whole oCIS process with the Go runtime error
|
||||
"fatal error: concurrent map read and map write". This is an unrecoverable
|
||||
runtime fault, so it could not be caught and recovered from, and it dropped all
|
||||
connections that were in flight at that moment.
|
||||
|
||||
When converting CS3 shares into Graph DriveItems, the worker goroutines read
|
||||
from the shared driveItems map while the collecting loop was already writing
|
||||
results into the very same map. The results channel is buffered, so the workers
|
||||
never blocked when handing over an item and the collecting loop started writing
|
||||
while workers were still running. The results are now collected after all
|
||||
workers have finished, which removes the overlapping access.
|
||||
|
||||
Note that lowering the maximum concurrency did not avoid this, as a single
|
||||
worker could still run concurrently with the collecting loop.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12673
|
||||
@@ -0,0 +1,15 @@
|
||||
Bugfix: Show vault-shared mountpoints in the vault drive list
|
||||
|
||||
Shares of vault resources are mountpoints hosted on the shares storage provider
|
||||
that grant into the vault storage provider. When listing spaces with the vault
|
||||
`storage_id`, the storage registry skipped the shares provider entirely, so the
|
||||
vault share mountpoint was missing from the vault drive list while still showing
|
||||
up in the regular drive list.
|
||||
|
||||
The registry now also queries the shares provider when the vault storage id is
|
||||
requested and segregates share mountpoints by their `grantStorageID`, so a vault
|
||||
share only appears in the vault drive list and a regular share only in the
|
||||
regular one.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12656
|
||||
https://github.com/owncloud/reva/pull/670
|
||||
@@ -0,0 +1,18 @@
|
||||
Bugfix: Log unmapped thumbnail errors and always report a sabredav exception
|
||||
|
||||
The webdav service logged failures of the thumbnails service at debug level only.
|
||||
Errors which are not a property of the requested file, such as the thumbnails
|
||||
service being unreachable, were therefore invisible at production log levels: a
|
||||
complete preview outage produced HTTP 500 responses without a single log line
|
||||
explaining them. Unmapped errors are now logged at error level, while expected
|
||||
per-file outcomes such as an unsupported file type or a file still being
|
||||
processed stay at debug level. Two of the four thumbnail handlers also logged
|
||||
without the request context, so their messages carried no request id.
|
||||
|
||||
In addition, `codesEnum` only mapped four status codes, so error responses for
|
||||
all other codes were rendered with an empty `<s:exception></s:exception>`
|
||||
element. The missing entries for 403, 425 and 429 have been added and any
|
||||
remaining unmapped code now falls back to a generic exception name, so clients
|
||||
always receive a usable exception.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12667
|
||||
@@ -10,10 +10,11 @@ require (
|
||||
github.com/MicahParks/keyfunc/v2 v2.1.0
|
||||
github.com/Nerzal/gocloak/v13 v13.9.0
|
||||
github.com/bbalet/stopwords v1.0.0
|
||||
github.com/beevik/etree v1.6.0
|
||||
github.com/beevik/etree v1.7.0
|
||||
github.com/blevesearch/bleve/v2 v2.6.0
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible
|
||||
github.com/coreos/go-oidc/v3 v3.19.0
|
||||
github.com/cenkalti/backoff/v5 v5.0.3
|
||||
github.com/coreos/go-oidc/v3 v3.20.0
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20241105092511-3ad35d174fc1
|
||||
github.com/davidbyttow/govips/v2 v2.18.0
|
||||
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
|
||||
@@ -21,10 +22,10 @@ require (
|
||||
github.com/egirna/icap-client v0.1.1
|
||||
github.com/gabriel-vasile/mimetype v1.4.13
|
||||
github.com/ggwhite/go-masker v1.1.0
|
||||
github.com/go-chi/chi/v5 v5.3.0
|
||||
github.com/go-chi/chi/v5 v5.3.1
|
||||
github.com/go-chi/httprate v0.16.0
|
||||
github.com/go-chi/render v1.0.3
|
||||
github.com/go-ldap/ldap/v3 v3.4.13
|
||||
github.com/go-ldap/ldap/v3 v3.4.14
|
||||
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3
|
||||
github.com/go-micro/plugins/v4/client/grpc v1.2.1
|
||||
github.com/go-micro/plugins/v4/logger/zerolog v1.2.0
|
||||
@@ -50,7 +51,7 @@ require (
|
||||
github.com/jellydator/ttlcache/v3 v3.4.1
|
||||
github.com/jinzhu/now v1.1.5
|
||||
github.com/justinas/alice v1.2.0
|
||||
github.com/kovidgoyal/imaging v1.8.22
|
||||
github.com/kovidgoyal/imaging v1.8.23
|
||||
github.com/leonelquinteros/gotext v1.7.2
|
||||
github.com/libregraph/idm v0.5.0
|
||||
github.com/libregraph/lico v0.67.0
|
||||
@@ -66,7 +67,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.18.2
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260710104539-1f85e04c1e35
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260804100559-3d6017309c36
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.23.2
|
||||
@@ -96,16 +97,16 @@ require (
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0
|
||||
go.opentelemetry.io/otel/sdk v1.44.0
|
||||
go.opentelemetry.io/otel/trace v1.44.0
|
||||
golang.org/x/crypto v0.53.0
|
||||
golang.org/x/crypto v0.54.0
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f
|
||||
golang.org/x/image v0.43.0
|
||||
golang.org/x/net v0.56.0
|
||||
golang.org/x/image v0.44.0
|
||||
golang.org/x/net v0.57.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sync v0.21.0
|
||||
golang.org/x/term v0.44.0
|
||||
golang.org/x/text v0.38.0
|
||||
golang.org/x/sync v0.22.0
|
||||
golang.org/x/term v0.45.0
|
||||
golang.org/x/text v0.40.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa
|
||||
google.golang.org/grpc v1.82.0
|
||||
google.golang.org/grpc v1.82.1
|
||||
google.golang.org/protobuf v1.36.11
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gotest.tools/v3 v3.5.2
|
||||
@@ -154,7 +155,6 @@ require (
|
||||
github.com/blevesearch/zapx/v17 v17.1.2 // indirect
|
||||
github.com/bluele/gcache v0.0.2 // indirect
|
||||
github.com/bombsimon/logrusr/v3 v3.1.0 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/ceph/go-ceph v0.40.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73 // indirect
|
||||
@@ -186,7 +186,7 @@ require (
|
||||
github.com/fsnotify/fsnotify v1.10.1 // indirect
|
||||
github.com/gdexlab/go-render v1.0.1 // indirect
|
||||
github.com/go-acme/lego/v4 v4.34.0 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.9.0 // indirect
|
||||
github.com/go-git/go-git/v5 v5.19.1 // indirect
|
||||
@@ -341,10 +341,10 @@ require (
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/mod v0.36.0 // indirect
|
||||
golang.org/x/sys v0.46.0 // indirect
|
||||
golang.org/x/mod v0.37.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
golang.org/x/tools v0.45.0 // indirect
|
||||
golang.org/x/tools v0.47.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
|
||||
|
||||
@@ -104,8 +104,8 @@ github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ
|
||||
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
|
||||
github.com/bbalet/stopwords v1.0.0 h1:0TnGycCtY0zZi4ltKoOGRFIlZHv0WqpoIGUsObjztfo=
|
||||
github.com/bbalet/stopwords v1.0.0/go.mod h1:sAWrQoDMfqARGIn4s6dp7OW7ISrshUD8IP2q3KoqPjc=
|
||||
github.com/beevik/etree v1.6.0 h1:u8Kwy8pp9D9XeITj2Z0XtA5qqZEmtJtuXZRQi+j03eE=
|
||||
github.com/beevik/etree v1.6.0/go.mod h1:bh4zJxiIr62SOf9pRzN7UUYaEDa9HEKafK25+sLc0Gc=
|
||||
github.com/beevik/etree v1.7.0 h1:xjBk9O4p4x7D1YajePjfLzdaFC4/uYUENA7P0pv6gXA=
|
||||
github.com/beevik/etree v1.7.0/go.mod h1:bh4zJxiIr62SOf9pRzN7UUYaEDa9HEKafK25+sLc0Gc=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
@@ -188,8 +188,8 @@ github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJ
|
||||
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
|
||||
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/go-oidc/v3 v3.19.0 h1:F/xyOi3x1UnG1U27YVnM1N6bHiL1K2upi6U/0qr8r+I=
|
||||
github.com/coreos/go-oidc/v3 v3.19.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
github.com/coreos/go-oidc/v3 v3.20.0 h1:EtE0WIBHk03N+DqGkY4+UONzzZHk7amKt6IyNd7OsZE=
|
||||
github.com/coreos/go-oidc/v3 v3.20.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
||||
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA=
|
||||
@@ -286,10 +286,10 @@ github.com/go-acme/lego/v4 v4.34.0 h1:oRsIuPJ4ORX7ufviXvelUpBSez2XxeKGwo5pNG9BVe
|
||||
github.com/go-acme/lego/v4 v4.34.0/go.mod h1:gsmdlx/ZS6OUeXbOj0U+VnCLLfEFj4WCYRkcGpZw+pc=
|
||||
github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-asn1-ber/asn1-ber v1.4.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-chi/chi/v5 v5.3.0 h1:halUjDxhshgXHMrao5bB8eNBXo/rnzwr8m5m36glehM=
|
||||
github.com/go-chi/chi/v5 v5.3.0/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 h1:H9AZkK22UOmfX8J84ubyaZxKJZ3FMHVwn8swoMML7iQ=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-chi/chi/v5 v5.3.1 h1:3j4HZLGZQ3JpMCrPJF/Jl3mYJfWLKBfNJ6quurUGCf8=
|
||||
github.com/go-chi/chi/v5 v5.3.1/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
|
||||
github.com/go-chi/httprate v0.16.0 h1:8V5DH9j6pSK6UQoBsTpvMyFxycqaKEIToyPKzHJjUa8=
|
||||
github.com/go-chi/httprate v0.16.0/go.mod h1:A8lo+qRhk+s9LiuP5saS7XCGDXRXMcrueq0NfIuCa/I=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
@@ -317,8 +317,8 @@ github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj
|
||||
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
|
||||
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||
github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
|
||||
github.com/go-ldap/ldap/v3 v3.4.13 h1:+x1nG9h+MZN7h/lUi5Q3UZ0fJ1GyDQYbPvbuH38baDQ=
|
||||
github.com/go-ldap/ldap/v3 v3.4.13/go.mod h1:LxsGZV6vbaK0sIvYfsv47rfh4ca0JXokCoKjZxsszv0=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14 h1:D6PYdEgsaVzsXyr6w/yDC06Ria4uUhWm+Rb+er8lfAs=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14/go.mod h1:S4eJUMUNjDkE0ZJtIZdybwyb03sGGLW6gxXT1Hs8VKA=
|
||||
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3 h1:sfz1YppV05y4sYaW7kXZtrocU/+vimnIWt4cxAYh7+o=
|
||||
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3/go.mod h1:ZXFhGda43Z2TVbfGZefXyMJzsDHhCh0go3bZUcwTx7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
@@ -597,8 +597,8 @@ github.com/kovidgoyal/go-parallel v1.1.1 h1:1OzpNjtrUkBPq3UaqrnvOoB2F9RttSt811ui
|
||||
github.com/kovidgoyal/go-parallel v1.1.1/go.mod h1:BJNIbe6+hxyFWv7n6oEDPj3PA5qSw5OCtf0hcVxWJiw=
|
||||
github.com/kovidgoyal/go-shm v1.0.0 h1:HJEel9D1F9YhULvClEHJLawoRSj/1u/EDV7MJbBPgQo=
|
||||
github.com/kovidgoyal/go-shm v1.0.0/go.mod h1:Yzb80Xf9L3kaoB2RGok9hHwMIt7Oif61kT6t3+VnZds=
|
||||
github.com/kovidgoyal/imaging v1.8.22 h1:CtpoRXQpS79xxJsKu8+LUJJE/0i4FLquJZy0QH+QNlM=
|
||||
github.com/kovidgoyal/imaging v1.8.22/go.mod h1:y8wo4JTv4D+skbtQf6fHg8nA1qtagvCcn8J2Nu5k2Jg=
|
||||
github.com/kovidgoyal/imaging v1.8.23 h1:4WsboyQ/E8tic2kX49P93Rvscg33SPsCwTBG5EZZF54=
|
||||
github.com/kovidgoyal/imaging v1.8.23/go.mod h1:k3Iot3H0v2rSWXIxQISfT3e9wIryqzAHLHCuhG7z9lM=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
@@ -739,8 +739,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260710104539-1f85e04c1e35 h1:40KHez6z6Ea+MHatRfZp4ZTX1TASGRG5UfvOpsQRbgU=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260710104539-1f85e04c1e35/go.mod h1:m2fGRZDsnNSBszbnwysuq7uhlitQ90+weX4FFQRdkak=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260804100559-3d6017309c36 h1:yXuG0tNLpm1jB4jfKxmiGsgslzzB+JA2di4J7K+KsA0=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260804100559-3d6017309c36/go.mod h1:zJV1uSPyjLXGhb3JwI0EuUx8GJaq1d/NCmpuqN0U4IE=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M=
|
||||
@@ -1015,8 +1015,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
|
||||
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -1031,8 +1031,8 @@ golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJk
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.43.0 h1:FLxcP4ec2350nTfOC8ysKtqYSIFbk/QGjw1ZHNP4tsY=
|
||||
golang.org/x/image v0.43.0/go.mod h1:rrpelvGFt+kLPAjPM4HeWPgrl0FtafueU//e5N0qk/Q=
|
||||
golang.org/x/image v0.44.0 h1:+tDekMZED9+LrtB3G5xzRggpVh9CARjZqROla3R3R+I=
|
||||
golang.org/x/image v0.44.0/go.mod h1:V8K3KE9KKKE+pLpQDOeN18w9oacNSvy1tDOirTu4xtY=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@@ -1054,8 +1054,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4=
|
||||
golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ=
|
||||
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
|
||||
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1099,8 +1099,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
|
||||
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -1124,8 +1124,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -1188,8 +1188,8 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
||||
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
@@ -1197,8 +1197,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc=
|
||||
golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y=
|
||||
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
||||
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -1210,8 +1210,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -1264,8 +1264,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8=
|
||||
golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0=
|
||||
golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=
|
||||
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -1343,8 +1343,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
|
||||
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
|
||||
google.golang.org/grpc v1.82.1 h1:NnAxzGRA0677vCa4BUkOAnO5+FfQqVl9iUXeD0IqcGE=
|
||||
google.golang.org/grpc v1.82.1/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e h1:m7aQHHqd0q89mRwhwS9Bx2rjyl/hsFAeta+uGrHsQaU=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e/go.mod h1:gID3PKrg7pWKntu9Ss6zTLJ0ttC0X9IHgREOCZwbCVU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
|
||||
)
|
||||
@@ -83,6 +84,10 @@ type LDAPProvider struct {
|
||||
UserGuestAttribute string `yaml:"user_guest_attribute" env:"OCIS_LDAP_USER_GUEST_ATTRIBUTE" desc:"LDAP attribute that marks a user as a guest of an instance." introductionVersion:"7.0"`
|
||||
UserSchema LDAPUserSchema `yaml:"user_schema"`
|
||||
GroupSchema LDAPGroupSchema `yaml:"group_schema"`
|
||||
|
||||
PoolEnabled bool `yaml:"pool_enabled" env:"OCIS_LDAP_POOL_ENABLED;AUTH_BASIC_LDAP_POOL_ENABLED" desc:"Instead of a single long-lived reconnecting connection, enable a bounded pool of LDAP connections. This means that concurrent requests will no longer be serialised on one connection." introductionVersion:"8.2.0"`
|
||||
PoolSize int `yaml:"pool_size" env:"OCIS_LDAP_POOL_SIZE;AUTH_BASIC_LDAP_POOL_SIZE" desc:"Maximum number of concurrently open LDAP connections when 'OCIS_LDAP_POOL_ENABLED' is 'true'. Defaults to 5 when unset or <= 0." introductionVersion:"8.2.0"`
|
||||
PoolCheckoutTimeout time.Duration `yaml:"pool_checkout_timeout" env:"OCIS_LDAP_POOL_CHECKOUT_TIMEOUT;AUTH_BASIC_LDAP_POOL_CHECKOUT_TIMEOUT" desc:"Maximum time to wait for a pooled LDAP connection to become available once the pool is exhausted. Defaults to 30s when unset or <= 0. See the Environment Variable Types description for more details." introductionVersion:"8.2.0"`
|
||||
}
|
||||
|
||||
type LDAPUserSchema struct {
|
||||
|
||||
@@ -2,6 +2,7 @@ package defaults
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
|
||||
ocisldap "github.com/owncloud/ocis/v2/ocis-pkg/ldap"
|
||||
@@ -55,6 +56,9 @@ func DefaultConfig() *config.Config {
|
||||
DisableUserMechanism: "attribute",
|
||||
LdapDisabledUsersGroupDN: "cn=DisabledUsersGroup,ou=groups,o=libregraph-idm",
|
||||
IDP: "https://localhost:9200",
|
||||
PoolEnabled: false,
|
||||
PoolSize: 5,
|
||||
PoolCheckoutTimeout: 30 * time.Second,
|
||||
UserSchema: config.LDAPUserSchema{
|
||||
ID: "ownclouduuid",
|
||||
Mail: "mail",
|
||||
|
||||
@@ -75,6 +75,9 @@ func ldapConfigFromString(cfg config.LDAPProvider) map[string]interface{} {
|
||||
"user_enabled_property": cfg.UserSchema.Enabled,
|
||||
"group_local_disabled_dn": cfg.LdapDisabledUsersGroupDN,
|
||||
"idp": cfg.IDP,
|
||||
"pool_enabled": cfg.PoolEnabled,
|
||||
"pool_size": cfg.PoolSize,
|
||||
"pool_checkout_timeout": cfg.PoolCheckoutTimeout,
|
||||
"user_schema": map[string]interface{}{
|
||||
"id": cfg.UserSchema.ID,
|
||||
"idIsOctetString": cfg.UserSchema.IDIsOctetString,
|
||||
|
||||
@@ -63,16 +63,23 @@ type Spaces struct {
|
||||
}
|
||||
|
||||
type LDAP struct {
|
||||
URI string `yaml:"uri" env:"OCIS_LDAP_URI;GRAPH_LDAP_URI" desc:"URI of the LDAP Server to connect to. Supported URI schemes are 'ldaps://' and 'ldap://'" introductionVersion:"pre5.0"`
|
||||
CACert string `yaml:"cacert" env:"OCIS_LDAP_CACERT;GRAPH_LDAP_CACERT" desc:"Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the LDAP service. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH/idm." introductionVersion:"pre5.0"`
|
||||
Insecure bool `yaml:"insecure" env:"OCIS_LDAP_INSECURE;GRAPH_LDAP_INSECURE" desc:"Disable TLS certificate validation for the LDAP connections. Do not set this in production environments." introductionVersion:"pre5.0"`
|
||||
BindDN string `yaml:"bind_dn" env:"OCIS_LDAP_BIND_DN;GRAPH_LDAP_BIND_DN" desc:"LDAP DN to use for simple bind authentication with the target LDAP server." introductionVersion:"pre5.0"`
|
||||
BindPassword string `yaml:"bind_password" env:"OCIS_LDAP_BIND_PASSWORD;GRAPH_LDAP_BIND_PASSWORD" desc:"Password to use for authenticating the 'bind_dn'." introductionVersion:"pre5.0"`
|
||||
UseServerUUID bool `yaml:"use_server_uuid" env:"GRAPH_LDAP_SERVER_UUID" desc:"If set to true, rely on the LDAP Server to generate a unique ID for users and groups, like when using 'entryUUID' as the user ID attribute." introductionVersion:"pre5.0"`
|
||||
UsePasswordModExOp bool `yaml:"use_password_modify_exop" env:"GRAPH_LDAP_SERVER_USE_PASSWORD_MODIFY_EXOP" desc:"Use the 'Password Modify Extended Operation' for updating user passwords." introductionVersion:"pre5.0"`
|
||||
WriteEnabled bool `yaml:"write_enabled" env:"OCIS_LDAP_SERVER_WRITE_ENABLED;GRAPH_LDAP_SERVER_WRITE_ENABLED" desc:"Allow creating, modifying and deleting LDAP users via the GRAPH API. This can only be set to 'true' when keeping default settings for the LDAP user and group attribute types (the 'OCIS_LDAP_USER_SCHEMA_* and 'OCIS_LDAP_GROUP_SCHEMA_* variables)." introductionVersion:"pre5.0"`
|
||||
UpdateUserLastSignInDate bool `yaml:"update_user_last_sign_in_date" env:"OCIS_LDAP_UPDATE_LAST_SIGNIN_DATE;GRAPH_LDAP_UPDATE_LAST_SIGNIN_DATE" desc:"Update the 'oCLastSignInTimestamp' LDAP attribute of a user when the user signs in. The attribute is only persisted when 'OCIS_LDAP_SERVER_WRITE_ENABLED' is also enabled. Set this to 'false' to avoid an LDAP write on every sign-in, e.g. when the last sign-in timestamp is not needed or the LDAP write load should be reduced." introductionVersion:"8.2.0"`
|
||||
RefintEnabled bool `yaml:"refint_enabled" env:"GRAPH_LDAP_REFINT_ENABLED" desc:"Signals that the server has the refint plugin enabled, which makes some actions not needed." introductionVersion:"pre5.0"`
|
||||
URI string `yaml:"uri" env:"OCIS_LDAP_URI;GRAPH_LDAP_URI" desc:"URI of the LDAP Server to connect to. Supported URI schemes are 'ldaps://' and 'ldap://'" introductionVersion:"pre5.0"`
|
||||
CACert string `yaml:"cacert" env:"OCIS_LDAP_CACERT;GRAPH_LDAP_CACERT" desc:"Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the LDAP service. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH/idm." introductionVersion:"pre5.0"`
|
||||
Insecure bool `yaml:"insecure" env:"OCIS_LDAP_INSECURE;GRAPH_LDAP_INSECURE" desc:"Disable TLS certificate validation for the LDAP connections. Do not set this in production environments." introductionVersion:"pre5.0"`
|
||||
BindDN string `yaml:"bind_dn" env:"OCIS_LDAP_BIND_DN;GRAPH_LDAP_BIND_DN" desc:"LDAP DN to use for simple bind authentication with the target LDAP server." introductionVersion:"pre5.0"`
|
||||
BindPassword string `yaml:"bind_password" env:"OCIS_LDAP_BIND_PASSWORD;GRAPH_LDAP_BIND_PASSWORD" desc:"Password to use for authenticating the 'bind_dn'." introductionVersion:"pre5.0"`
|
||||
UseServerUUID bool `yaml:"use_server_uuid" env:"GRAPH_LDAP_SERVER_UUID" desc:"If set to true, rely on the LDAP Server to generate a unique ID for users and groups, like when using 'entryUUID' as the user ID attribute." introductionVersion:"pre5.0"`
|
||||
UsePasswordModExOp bool `yaml:"use_password_modify_exop" env:"GRAPH_LDAP_SERVER_USE_PASSWORD_MODIFY_EXOP" desc:"Use the 'Password Modify Extended Operation' for updating user passwords." introductionVersion:"pre5.0"`
|
||||
WriteEnabled bool `yaml:"write_enabled" env:"OCIS_LDAP_SERVER_WRITE_ENABLED;GRAPH_LDAP_SERVER_WRITE_ENABLED" desc:"Allow creating, modifying and deleting LDAP users via the GRAPH API. This can only be set to 'true' when keeping default settings for the LDAP user and group attribute types (the 'OCIS_LDAP_USER_SCHEMA_* and 'OCIS_LDAP_GROUP_SCHEMA_* variables)." introductionVersion:"pre5.0"`
|
||||
UpdateUserLastSignInDate bool `yaml:"update_user_last_sign_in_date" env:"OCIS_LDAP_UPDATE_LAST_SIGNIN_DATE;GRAPH_LDAP_UPDATE_LAST_SIGNIN_DATE" desc:"Update the 'oCLastSignInTimestamp' LDAP attribute of a user when the user signs in. The attribute is only persisted when 'OCIS_LDAP_SERVER_WRITE_ENABLED' is also enabled. Set this to 'false' to avoid an LDAP write on every sign-in, e.g. when the last sign-in timestamp is not needed or the LDAP write load should be reduced." introductionVersion:"8.2.0"`
|
||||
RetryMaxCount int `yaml:"retry_max_count" env:"OCIS_LDAP_RETRY_MAX_COUNT;GRAPH_LDAP_RETRY_MAX_COUNT" desc:"Maximum number of retries for failed LDAP operations. Reads retry on transient and network errors; writes retry only when the connection failed before the request was sent (e.g. a reused idle connection found closed), so the request provably never reached the server and cannot be double-applied. Default 1." introductionVersion:"8.2.0"`
|
||||
RetryBaseDelay time.Duration `yaml:"retry_base_delay" env:"OCIS_LDAP_RETRY_BASE_DELAY;GRAPH_LDAP_RETRY_BASE_DELAY" desc:"Base delay for exponential backoff between LDAP retries (e.g. '100ms'). Set to 0 to disable backoff." introductionVersion:"8.2.0"`
|
||||
RetryMaxDelay time.Duration `yaml:"retry_max_delay" env:"OCIS_LDAP_RETRY_MAX_DELAY;GRAPH_LDAP_RETRY_MAX_DELAY" desc:"Maximum delay cap for exponential backoff between LDAP retries (e.g. '5s'). 0 (default) uses the library default cap of 60s." introductionVersion:"8.2.0"`
|
||||
RefintEnabled bool `yaml:"refint_enabled" env:"GRAPH_LDAP_REFINT_ENABLED" desc:"Signals that the server has the refint plugin enabled, which makes some actions not needed." introductionVersion:"pre5.0"`
|
||||
|
||||
PoolEnabled bool `yaml:"pool_enabled" env:"OCIS_LDAP_POOL_ENABLED;GRAPH_LDAP_POOL_ENABLED" desc:"Instead of a single long-lived reconnecting connection, enable a bounded pool of LDAP connections. This means that concurrent requests will no longer be serialised on one connection." introductionVersion:"8.2.0"`
|
||||
PoolSize int `yaml:"pool_size" env:"OCIS_LDAP_POOL_SIZE;GRAPH_LDAP_POOL_SIZE" desc:"Maximum number of concurrently open LDAP connections when 'OCIS_LDAP_POOL_ENABLED' is 'true'. Defaults to 5 when unset or <= 0." introductionVersion:"8.2.0"`
|
||||
PoolCheckoutTimeout time.Duration `yaml:"pool_checkout_timeout" env:"OCIS_LDAP_POOL_CHECKOUT_TIMEOUT;GRAPH_LDAP_POOL_CHECKOUT_TIMEOUT" desc:"Maximum time to wait for a pooled LDAP connection to become available once the pool is exhausted. Defaults to 30s when unset or <= 0. See the Environment Variable Types description for more details." introductionVersion:"8.2.0"`
|
||||
|
||||
UserBaseDN string `yaml:"user_base_dn" env:"OCIS_LDAP_USER_BASE_DN;GRAPH_LDAP_USER_BASE_DN" desc:"Search base DN for looking up LDAP users." introductionVersion:"pre5.0"`
|
||||
UserSearchScope string `yaml:"user_search_scope" env:"OCIS_LDAP_USER_SCOPE;GRAPH_LDAP_USER_SCOPE" desc:"LDAP search scope to use when looking up users. Supported scopes are 'base', 'one' and 'sub'." introductionVersion:"pre5.0"`
|
||||
|
||||
@@ -88,6 +88,9 @@ func DefaultConfig() *config.Config {
|
||||
Insecure: false,
|
||||
CACert: path.Join(defaults.BaseDataPath(), "idm", "ldap.crt"),
|
||||
BindDN: "uid=libregraph,ou=sysusers,o=libregraph-idm",
|
||||
PoolEnabled: false,
|
||||
PoolSize: 5,
|
||||
PoolCheckoutTimeout: 30 * time.Second,
|
||||
UseServerUUID: false,
|
||||
UsePasswordModExOp: true,
|
||||
WriteEnabled: true,
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/CiscoM31/godata"
|
||||
backoff "github.com/cenkalti/backoff/v5"
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/google/uuid"
|
||||
"github.com/libregraph/idm/pkg/ldapdn"
|
||||
@@ -54,6 +55,11 @@ type LDAP struct {
|
||||
refintEnabled bool
|
||||
usePwModifyExOp bool
|
||||
|
||||
// bounds for the read-back retry in readBackAfterWrite
|
||||
retryMaxCount int
|
||||
retryBaseDelay time.Duration
|
||||
retryMaxDelay time.Duration
|
||||
|
||||
userBaseDN string
|
||||
userFilter string
|
||||
userObjectClass string
|
||||
@@ -64,14 +70,14 @@ type LDAP struct {
|
||||
disableUserMechanism DisableUserMechanismType
|
||||
localUserDisableGroupDN string
|
||||
|
||||
groupBaseDN string
|
||||
groupCreateBaseDN string
|
||||
groupFilter string
|
||||
groupObjectClass string
|
||||
groupAdditionalObjectClasses []string
|
||||
groupIDisOctetString bool
|
||||
groupScope int
|
||||
groupAttributeMap groupAttributeMap
|
||||
groupBaseDN string
|
||||
groupCreateBaseDN string
|
||||
groupFilter string
|
||||
groupObjectClass string
|
||||
groupAdditionalObjectClasses []string
|
||||
groupIDisOctetString bool
|
||||
groupScope int
|
||||
groupAttributeMap groupAttributeMap
|
||||
|
||||
educationConfig educationConfig
|
||||
|
||||
@@ -149,6 +155,15 @@ func NewLDAPBackend(lc ldap.Client, config config.LDAP, logger *log.Logger, inst
|
||||
if config.GroupNameAttribute == "" || config.GroupIDAttribute == "" {
|
||||
return nil, errors.New("invalid group attribute mappings")
|
||||
}
|
||||
|
||||
// Octet-string ID attributes (e.g. Active Directory's objectGUID) are assigned by
|
||||
// the directory server, which requires UseServerUUID=true. With UseServerUUID=false
|
||||
// oCIS generates the ID and writes it as a string UUID, so an octet-string ID
|
||||
// attribute would be decoded from raw string bytes and produce a corrupt ID. Reject
|
||||
// this incompatible combination at startup instead of silently returning bad IDs.
|
||||
if !config.UseServerUUID && (config.UserIDIsOctetString || config.GroupIDIsOctetString) {
|
||||
return nil, errors.New("invalid config: octet-string ID attributes require GRAPH_LDAP_SERVER_UUID=true")
|
||||
}
|
||||
gam := groupAttributeMap{
|
||||
name: config.GroupNameAttribute,
|
||||
id: config.GroupIDAttribute,
|
||||
@@ -195,6 +210,9 @@ func NewLDAPBackend(lc ldap.Client, config config.LDAP, logger *log.Logger, inst
|
||||
return &LDAP{
|
||||
useServerUUID: config.UseServerUUID,
|
||||
usePwModifyExOp: config.UsePasswordModExOp,
|
||||
retryMaxCount: config.RetryMaxCount,
|
||||
retryBaseDelay: config.RetryBaseDelay,
|
||||
retryMaxDelay: config.RetryMaxDelay,
|
||||
userBaseDN: config.UserBaseDN,
|
||||
userFilter: config.UserFilter,
|
||||
userObjectClass: config.UserObjectClass,
|
||||
@@ -266,10 +284,21 @@ func (i *LDAP) CreateUser(ctx context.Context, user libregraph.User) (*libregrap
|
||||
}
|
||||
}
|
||||
|
||||
// Read back user from LDAP to get the generated UUID
|
||||
e, err := i.getUserByDN(ar.DN, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var e *ldap.Entry
|
||||
if i.useServerUUID {
|
||||
// The directory assigns the ID and conn.Add cannot return it, so we must
|
||||
// read the entry back to recover the generated UUID.
|
||||
e, err = i.readBackAfterWrite(func() (*ldap.Entry, error) {
|
||||
return i.getUserByDN(ar.DN, "")
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// oCIS generated the ID and wrote it into the AddRequest, so everything the
|
||||
// model builder needs is already in hand — synthesize the entry instead of
|
||||
// reading it back (avoids a read-after-write against a lagging replica).
|
||||
e = ldap.NewEntry(ar.DN, attrsFromAddRequest(ar))
|
||||
}
|
||||
return i.createUserModelFromLDAP(e), nil
|
||||
}
|
||||
@@ -439,11 +468,12 @@ func (i *LDAP) UpdateUser(ctx context.Context, nameOrID string, user libregraph.
|
||||
}
|
||||
}
|
||||
|
||||
// Read back user from LDAP to get the generated UUID
|
||||
e, err = i.getUserByDN(e.DN, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Fold the applied changes onto the pre-read entry instead of reading it back.
|
||||
// The ID is immutable on update (rejected above) and every field the model builder
|
||||
// reads is either already on e or in the ModifyRequest just applied, so no
|
||||
// read-after-write is needed. The rename branch (changeUserName) is handled above
|
||||
// and keeps its own read-back.
|
||||
e = applyModifyToEntry(e, &mr)
|
||||
|
||||
returnUser := i.createUserModelFromLDAP(e)
|
||||
|
||||
@@ -523,6 +553,13 @@ func (i *LDAP) getEntryByDN(dn string, attrs []string, filter string) (*ldap.Ent
|
||||
Msg("getEntryByDN")
|
||||
res, err := i.conn.Search(searchRequest)
|
||||
if err != nil {
|
||||
// A lagging replica returns NoSuchObject(32) for a base search on a
|
||||
// not-yet-replicated DN; a slower one returns success with 0 entries. Both
|
||||
// mean "not there yet", so map to the same ErrNotFound that readBackAfterWrite
|
||||
// retries on.
|
||||
if ldap.IsErrorWithCode(err, ldap.LDAPResultNoSuchObject) {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
i.logger.Error().Err(err).Str("backend", "ldap").Str("dn", dn).Msg("Search ldap by DN failed")
|
||||
return nil, errorcode.New(errorcode.ItemNotFound, "user lookup failed")
|
||||
}
|
||||
@@ -533,6 +570,38 @@ func (i *LDAP) getEntryByDN(dn string, attrs []string, filter string) (*ldap.Ent
|
||||
return res.Entries[0], nil
|
||||
}
|
||||
|
||||
// readBackAfterWrite runs readFn, retrying on ErrNotFound with backoff. A 0-entry
|
||||
// read after a successful write means the read hit a replica lagging behind the
|
||||
// primary; the connection-level retry only sees error codes, not this empty result,
|
||||
// so the retry happens here. Bounds default to one immediate re-read (count=1,
|
||||
// delay=0) and are tunable via the shared LDAP retry config.
|
||||
func (i *LDAP) readBackAfterWrite(readFn func() (*ldap.Entry, error)) (*ldap.Entry, error) {
|
||||
maxRetries := i.retryMaxCount
|
||||
if maxRetries < 1 {
|
||||
maxRetries = 1
|
||||
}
|
||||
|
||||
var bo *backoff.ExponentialBackOff
|
||||
for try := 0; ; try++ {
|
||||
e, err := readFn()
|
||||
if !errors.Is(err, ErrNotFound) || try >= maxRetries {
|
||||
return e, err
|
||||
}
|
||||
|
||||
if i.retryBaseDelay > 0 {
|
||||
if bo == nil {
|
||||
bo = backoff.NewExponentialBackOff()
|
||||
bo.InitialInterval = i.retryBaseDelay
|
||||
if i.retryMaxDelay > 0 {
|
||||
bo.MaxInterval = i.retryMaxDelay
|
||||
}
|
||||
bo.Reset()
|
||||
}
|
||||
time.Sleep(bo.NextBackOff())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (i *LDAP) searchLDAPEntryByFilter(basedn string, attrs []string, filter string) (*ldap.Entry, error) {
|
||||
if filter == "" {
|
||||
filter = "(objectclass=*)"
|
||||
|
||||
@@ -1,414 +0,0 @@
|
||||
package ldap
|
||||
|
||||
// LDAP automatic reconnection mechanism, inspired by:
|
||||
// https://gist.github.com/emsearcy/cba3295d1a06d4c432ab4f6173b65e4f#file-ldap_snippet-go
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
)
|
||||
|
||||
var (
|
||||
errMaxRetries = errors.New("max retries")
|
||||
)
|
||||
|
||||
type ldapConnection struct {
|
||||
Conn *ldap.Conn
|
||||
Error error
|
||||
}
|
||||
|
||||
// ConnWithReconnect implements the ldap.Client interface
|
||||
type ConnWithReconnect struct {
|
||||
conn chan ldapConnection
|
||||
reset chan *ldap.Conn
|
||||
retries int
|
||||
logger *log.Logger
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
URI string
|
||||
BindDN string
|
||||
BindPassword string
|
||||
TLSConfig *tls.Config
|
||||
}
|
||||
|
||||
func NewLDAPWithReconnect(logger *log.Logger, config Config) ConnWithReconnect {
|
||||
conn := ConnWithReconnect{
|
||||
conn: make(chan ldapConnection),
|
||||
reset: make(chan *ldap.Conn),
|
||||
retries: 1,
|
||||
logger: logger,
|
||||
}
|
||||
go conn.ldapAutoConnect(config)
|
||||
return conn
|
||||
}
|
||||
|
||||
// Search implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Search(sr *ldap.SearchRequest) (*ldap.SearchResult, error) {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var res *ldap.SearchResult
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
res, err = conn.Search(sr)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// non network error, return it to the client
|
||||
return res, err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP Search")
|
||||
}
|
||||
// if we get here we reached the maximum retries. So return an error
|
||||
return nil, ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// Add implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Add(a *ldap.AddRequest) error {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
err = conn.Add(a)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// non network error, return it to the client
|
||||
return err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP Add")
|
||||
}
|
||||
// if we get here we reached the maximum retries. So return an error
|
||||
return ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// Del implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Del(d *ldap.DelRequest) error {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
err = conn.Del(d)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// non network error, return it to the client
|
||||
return err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP Del")
|
||||
}
|
||||
// if we get here we reached the maximum retries. So return an error
|
||||
return ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// Modify implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Modify(m *ldap.ModifyRequest) error {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
err = conn.Modify(m)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// non network error, return it to the client
|
||||
return err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP Modify")
|
||||
}
|
||||
// if we get here we reached the maximum retries. So return an error
|
||||
return ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// PasswordModify implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) PasswordModify(m *ldap.PasswordModifyRequest) (*ldap.PasswordModifyResult, error) {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var res *ldap.PasswordModifyResult
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
res, err = conn.PasswordModify(m)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// non network error, return it to the client
|
||||
return res, err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP Password Modify")
|
||||
}
|
||||
// if we get here we reached the maximum retries. So return an error
|
||||
return nil, ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// ModifyDN implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) ModifyDN(m *ldap.ModifyDNRequest) error {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
err = conn.ModifyDN(m)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// non network error, return it to the client
|
||||
return err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP ModifyDN")
|
||||
}
|
||||
// if we get here we reached the maximum retries. So return an error
|
||||
return ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// GetConnection implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) GetConnection() (*ldap.Conn, error) {
|
||||
conn := <-c.conn
|
||||
if conn.Conn != nil && !ldap.IsErrorWithCode(conn.Error, ldap.ErrorNetwork) {
|
||||
c.logger.Debug().Msg("using existing Connection")
|
||||
return conn.Conn, conn.Error
|
||||
}
|
||||
return c.reconnect(conn.Conn)
|
||||
}
|
||||
|
||||
// ldapAutoConnect implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) ldapAutoConnect(config Config) {
|
||||
var (
|
||||
l *ldap.Conn
|
||||
err error
|
||||
)
|
||||
for {
|
||||
select {
|
||||
case resConn := <-c.reset:
|
||||
// Only close the connection and reconnect if the current
|
||||
// connection, matches the one we got via the reset channel.
|
||||
// If they differ we already reconnected
|
||||
if l != nil && l == resConn {
|
||||
c.logger.Debug().Msgf("closing connection %v", &l)
|
||||
l.Close()
|
||||
}
|
||||
if l == resConn || l == nil {
|
||||
c.logger.Debug().Msg("reconnecting to LDAP")
|
||||
l, err = c.ldapConnect(config)
|
||||
} else {
|
||||
c.logger.Debug().Msg("already reconnected")
|
||||
}
|
||||
case c.conn <- ldapConnection{l, err}:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ldapConnect implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) ldapConnect(config Config) (*ldap.Conn, error) {
|
||||
c.logger.Debug().Msgf("Connecting to %s", config.URI)
|
||||
|
||||
var err error
|
||||
var l *ldap.Conn
|
||||
if config.TLSConfig != nil {
|
||||
l, err = ldap.DialURL(config.URI, ldap.DialWithTLSConfig(config.TLSConfig))
|
||||
} else {
|
||||
l, err = ldap.DialURL(config.URI)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
c.logger.Error().Err(err).Msg("could not get ldap Connection")
|
||||
} else {
|
||||
c.logger.Debug().Msg("LDAP Connected")
|
||||
if config.BindDN != "" {
|
||||
c.logger.Debug().Msgf("Binding as %s", config.BindDN)
|
||||
err = l.Bind(config.BindDN, config.BindPassword)
|
||||
if err != nil {
|
||||
c.logger.Error().Err(err).Msg("Bind failed")
|
||||
l.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return l, err
|
||||
}
|
||||
|
||||
// reconnect implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) reconnect(resetConn *ldap.Conn) (*ldap.Conn, error) {
|
||||
c.logger.Debug().Msg("LDAP connection reset")
|
||||
c.reset <- resetConn
|
||||
c.logger.Debug().Msg("Waiting for new connection")
|
||||
result := <-c.conn
|
||||
return result.Conn, result.Error
|
||||
}
|
||||
|
||||
// Extended implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Extended(req *ldap.ExtendedRequest) (*ldap.ExtendedResponse, error) {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: in reva there is a good retry util function
|
||||
var res *ldap.ExtendedResponse
|
||||
for try := 0; try <= c.retries; try++ {
|
||||
res, err = conn.Extended(req)
|
||||
if !ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
|
||||
// Non network error, return it to the client
|
||||
return res, err
|
||||
}
|
||||
|
||||
c.logger.Debug().Msgf("Network Error. attempt %d", try)
|
||||
conn, err = c.reconnect(conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.logger.Debug().Msg("retrying LDAP Extended")
|
||||
}
|
||||
// Return error when reached the maximum retries.
|
||||
return nil, ldap.NewError(ldap.ErrorNetwork, errMaxRetries)
|
||||
}
|
||||
|
||||
// Remaining methods to fulfill ldap.Client interface
|
||||
|
||||
func (c ConnWithReconnect) Start() {}
|
||||
|
||||
// StartTLS implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) StartTLS(*tls.Config) error {
|
||||
return ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// Close implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Close() (err error) {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return conn.Close()
|
||||
}
|
||||
|
||||
// GetLastError implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) GetLastError() error {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return conn.GetLastError()
|
||||
}
|
||||
|
||||
// IsClosing implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) IsClosing() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// SetTimeout implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) SetTimeout(time.Duration) {}
|
||||
|
||||
// Bind implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Bind(username, password string) error {
|
||||
return ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// UnauthenticatedBind implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) UnauthenticatedBind(username string) error {
|
||||
return ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// SimpleBind implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) SimpleBind(*ldap.SimpleBindRequest) (*ldap.SimpleBindResult, error) {
|
||||
return nil, ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// ExternalBind implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) ExternalBind() error {
|
||||
return ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// ModifyWithResult implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) ModifyWithResult(m *ldap.ModifyRequest) (*ldap.ModifyResult, error) {
|
||||
conn, err := c.GetConnection()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return conn.ModifyWithResult(m)
|
||||
}
|
||||
|
||||
// Compare implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Compare(dn, attribute, value string) (bool, error) {
|
||||
return false, ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// Compare implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error) {
|
||||
return nil, ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// SearchAsync implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) SearchAsync(ctx context.Context, searchRequest *ldap.SearchRequest, bufferSize int) ldap.Response {
|
||||
// unimplemented
|
||||
return nil
|
||||
}
|
||||
|
||||
// NTLMUnauthenticatedBind implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) NTLMUnauthenticatedBind(domain, username string) error {
|
||||
return ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// TLSConnectionState implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) TLSConnectionState() (tls.ConnectionState, bool) {
|
||||
return tls.ConnectionState{}, false
|
||||
}
|
||||
|
||||
// Unbind implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Unbind() error {
|
||||
return ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// DirSync implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) DirSync(searchRequest *ldap.SearchRequest, flags, maxAttrCount int64, cookie []byte) (*ldap.SearchResult, error) {
|
||||
return nil, ldap.NewError(ldap.LDAPResultNotSupported, fmt.Errorf("not implemented"))
|
||||
}
|
||||
|
||||
// DirSyncAsync implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) DirSyncAsync(ctx context.Context, searchRequest *ldap.SearchRequest, bufferSize int, flags, maxAttrCount int64, cookie []byte) ldap.Response {
|
||||
// unimplemented
|
||||
return nil
|
||||
}
|
||||
|
||||
// Syncrepl implements the ldap.Client interface
|
||||
func (c ConnWithReconnect) Syncrepl(ctx context.Context, searchRequest *ldap.SearchRequest, bufferSize int, mode ldap.ControlSyncRequestMode, cookie []byte, reloadHint bool) ldap.Response {
|
||||
// unimplemented
|
||||
return nil
|
||||
}
|
||||
@@ -89,10 +89,20 @@ func (i *LDAP) CreateEducationClass(ctx context.Context, class libregraph.Educat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Read back group from LDAP to get the generated UUID
|
||||
e, err := i.getEducationClassByDN(ar.DN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var e *ldap.Entry
|
||||
if i.useServerUUID {
|
||||
// The directory assigns the ID and conn.Add cannot return it, so we must
|
||||
// read the entry back to recover the generated UUID.
|
||||
e, err = i.readBackAfterWrite(func() (*ldap.Entry, error) {
|
||||
return i.getEducationClassByDN(ar.DN)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// oCIS generated the ID and wrote it into the AddRequest, so synthesize the
|
||||
// entry from data already in hand instead of reading it back.
|
||||
e = ldap.NewEntry(ar.DN, attrsFromAddRequest(ar))
|
||||
}
|
||||
return i.createEducationClassModelFromLDAP(e), nil
|
||||
}
|
||||
@@ -142,7 +152,10 @@ func (i *LDAP) UpdateEducationClass(ctx context.Context, id string, class libreg
|
||||
return nil, ErrReadOnly
|
||||
}
|
||||
|
||||
g, err := i.getLDAPGroupByID(id, false)
|
||||
// Request the full education-class attribute set (classification, externalID, …),
|
||||
// not just [name, id], so the folded response entry carries everything the model
|
||||
// builder reads — otherwise a displayName-only update would drop classification.
|
||||
g, err := i.getEducationClassByID(id, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -174,12 +187,17 @@ func (i *LDAP) UpdateEducationClass(ctx context.Context, id string, class libreg
|
||||
|
||||
dn := g.DN
|
||||
|
||||
// The externalID lives in the RDN and is changed via ModifyDN, not the ModifyRequest.
|
||||
// The model builder reads it from the externalID attribute, so we fold it on as an
|
||||
// attribute replace below (deleteOldRDN=true updates the attribute server-side).
|
||||
externalIDChanged := false
|
||||
if eID := class.GetExternalId(); eID != "" {
|
||||
if g.GetEqualFoldAttributeValue(i.educationConfig.classAttributeMap.externalID) != eID {
|
||||
dn, err = i.updateClassExternalID(ctx, dn, eID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
externalIDChanged = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,9 +216,14 @@ func (i *LDAP) UpdateEducationClass(ctx context.Context, id string, class libreg
|
||||
}
|
||||
}
|
||||
|
||||
g, err = i.getEducationClassByDN(dn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// Fold the applied changes onto the pre-read entry instead of reading it back.
|
||||
// The externalID rename is modelled as an attribute replace so the returned model
|
||||
// reflects the new externalID.
|
||||
g = applyModifyToEntry(g, &mr)
|
||||
if externalIDChanged {
|
||||
extRename := ldap.ModifyRequest{DN: dn}
|
||||
extRename.Replace(i.educationConfig.classAttributeMap.externalID, []string{class.GetExternalId()})
|
||||
g = applyModifyToEntry(g, &extRename)
|
||||
}
|
||||
|
||||
return i.createEducationClassModelFromLDAP(g), nil
|
||||
|
||||
@@ -50,7 +50,11 @@ func TestCreateEducationClass(t *testing.T) {
|
||||
},
|
||||
nil)
|
||||
|
||||
b, err := getMockedBackend(lm, eduConfig, &logger)
|
||||
// useServerUUID=true keeps the read-back path (the directory assigns the ID),
|
||||
// which is what this test asserts (Search called once, fixed entry returned).
|
||||
c := eduConfig
|
||||
c.UseServerUUID = true
|
||||
b, err := getMockedBackend(lm, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, "", b.educationConfig.classObjectClass)
|
||||
class := libregraph.NewEducationClass()
|
||||
|
||||
@@ -160,10 +160,20 @@ func (i *LDAP) CreateEducationSchool(ctx context.Context, school libregraph.Educ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Read back school from LDAP to get the generated UUID
|
||||
e, err := i.getSchoolByDN(ar.DN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var e *ldap.Entry
|
||||
if i.useServerUUID {
|
||||
// The directory assigns the ID and conn.Add cannot return it, so we must
|
||||
// read the entry back to recover the generated UUID.
|
||||
e, err = i.readBackAfterWrite(func() (*ldap.Entry, error) {
|
||||
return i.getSchoolByDN(ar.DN)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// oCIS generated the ID and wrote it into the AddRequest, so synthesize the
|
||||
// entry from data already in hand instead of reading it back.
|
||||
e = ldap.NewEntry(ar.DN, attrsFromAddRequest(ar))
|
||||
}
|
||||
return i.createSchoolModelFromLDAP(e), nil
|
||||
}
|
||||
@@ -240,7 +250,9 @@ func (i *LDAP) updateDisplayName(ctx context.Context, dn string, providedDisplay
|
||||
|
||||
// updateSchoolProperties updates the properties (other that displayName) of a school.
|
||||
// It checks if a school number is already taken, before updating the school number
|
||||
func (i *LDAP) updateSchoolProperties(ctx context.Context, dn string, currentSchool, updatedSchool libregraph.EducationSchool) error {
|
||||
// updateSchoolProperties applies the ModifyRequest and returns it so the caller can
|
||||
// fold the applied changes onto the pre-read entry (avoiding a read-after-write).
|
||||
func (i *LDAP) updateSchoolProperties(ctx context.Context, dn string, currentSchool, updatedSchool libregraph.EducationSchool) (*ldap.ModifyRequest, error) {
|
||||
logger := i.logger.SubloggerWithRequestID(ctx)
|
||||
|
||||
mr := ldap.NewModifyRequest(dn, nil)
|
||||
@@ -248,7 +260,7 @@ func (i *LDAP) updateSchoolProperties(ctx context.Context, dn string, currentSch
|
||||
if *updatedSchoolNumber != "" && currentSchool.GetSchoolNumber() != *updatedSchoolNumber {
|
||||
_, err := i.getSchoolByNumber(*updatedSchoolNumber)
|
||||
if err == nil {
|
||||
return errSchoolNumberExists
|
||||
return nil, errSchoolNumberExists
|
||||
}
|
||||
mr.Replace(i.educationConfig.schoolAttributeMap.schoolNumber, []string{*updatedSchoolNumber})
|
||||
}
|
||||
@@ -267,10 +279,10 @@ func (i *LDAP) updateSchoolProperties(ctx context.Context, dn string, currentSch
|
||||
|
||||
if err := i.conn.Modify(mr); err != nil {
|
||||
logger.Debug().Err(err).Msg("error updating school number")
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil
|
||||
return mr, nil
|
||||
}
|
||||
|
||||
// UpdateEducationSchool updates the supplied school in the identity backend
|
||||
@@ -287,6 +299,11 @@ func (i *LDAP) UpdateEducationSchool(ctx context.Context, numberOrID string, sch
|
||||
}
|
||||
|
||||
currentSchool := i.createSchoolModelFromLDAP(e)
|
||||
// Fold the applied changes onto the pre-read entry instead of reading it back.
|
||||
// updateDisplayName mutates the RDN via ModifyDN; the model builder reads displayName
|
||||
// from the attribute, so we model the rename as a displayName attribute replace.
|
||||
// updateSchoolProperties returns the ModifyRequest it applied so we can fold it on.
|
||||
fold := ldap.NewModifyRequest(e.DN, nil)
|
||||
switch i.updateEducationSchoolOperation(school, *currentSchool) {
|
||||
case tooManyValues:
|
||||
return nil, fmt.Errorf("school name and school number cannot be updated in the same request")
|
||||
@@ -297,17 +314,16 @@ func (i *LDAP) UpdateEducationSchool(ctx context.Context, numberOrID string, sch
|
||||
if err := i.updateDisplayName(ctx, e.DN, school.GetDisplayName()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fold.Replace(i.educationConfig.schoolAttributeMap.displayName, []string{school.GetDisplayName()})
|
||||
case schoolPropertiesUpdated:
|
||||
if err := i.updateSchoolProperties(ctx, e.DN, *currentSchool, school); err != nil {
|
||||
mr, err := i.updateSchoolProperties(ctx, e.DN, *currentSchool, school)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fold.Changes = mr.Changes
|
||||
}
|
||||
|
||||
// Read back school from LDAP
|
||||
e, err = i.getSchoolByNumberOrID(i.getID(e))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
e = applyModifyToEntry(e, fold)
|
||||
return i.createSchoolModelFromLDAP(e), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,6 @@ var schoolEntry1 = ldap.NewEntry("ou=Test School1",
|
||||
"ocEducationSchoolNumber": {"0042"},
|
||||
"owncloudUUID": {"hijk-defg"},
|
||||
})
|
||||
var schoolEntryWithTermination = ldap.NewEntry("ou=Test School",
|
||||
map[string][]string{
|
||||
"ou": {"Test School"},
|
||||
"ocEducationSchoolNumber": {"0123"},
|
||||
"owncloudUUID": {"abcd-defg"},
|
||||
"ocEducationSchoolTerminationTimestamp": {"20420131120000Z"},
|
||||
})
|
||||
|
||||
var (
|
||||
filterSchoolSearchByIdExisting = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=abcd-defg)(ocEducationSchoolNumber=abcd-defg)))"
|
||||
@@ -177,7 +170,11 @@ func TestCreateEducationSchool(t *testing.T) {
|
||||
Entries: []*ldap.Entry{schoolEntry},
|
||||
},
|
||||
nil)
|
||||
b, err := getMockedBackend(lm, eduConfig, &logger)
|
||||
// useServerUUID=true keeps the read-back path (the directory assigns the ID),
|
||||
// which is what this test asserts (fixed entry returned with a known id).
|
||||
c := eduConfig
|
||||
c.UseServerUUID = true
|
||||
b, err := getMockedBackend(lm, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, "", b.educationConfig.schoolObjectClass)
|
||||
|
||||
@@ -218,6 +215,7 @@ func TestUpdateEducationSchoolTerminationDate(t *testing.T) {
|
||||
return false
|
||||
}
|
||||
lm.On("Modify", mock.MatchedBy(ldapSchoolTerminationRequestMatcher)).Return(nil)
|
||||
// Single pre-read; the termination Replace is folded onto it (no read-back).
|
||||
lm.On("Search", mock.Anything).
|
||||
Return(
|
||||
&ldap.SearchResult{
|
||||
@@ -225,13 +223,6 @@ func TestUpdateEducationSchoolTerminationDate(t *testing.T) {
|
||||
},
|
||||
nil).
|
||||
Once()
|
||||
lm.On("Search", mock.Anything).
|
||||
Return(
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{schoolEntryWithTermination},
|
||||
},
|
||||
nil).
|
||||
Once()
|
||||
|
||||
b, err := getMockedBackend(lm, eduConfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
@@ -240,7 +231,7 @@ func TestUpdateEducationSchoolTerminationDate(t *testing.T) {
|
||||
terminationTime := time.Date(2042, time.January, 31, 12, 0, 0, 0, time.UTC)
|
||||
school.SetTerminationDate(terminationTime)
|
||||
resSchool, err := b.UpdateEducationSchool(context.Background(), "abcd-defg", *school)
|
||||
lm.AssertNumberOfCalls(t, "Search", 2)
|
||||
lm.AssertNumberOfCalls(t, "Search", 1)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, resSchool)
|
||||
assert.Equal(t, "Test School", resSchool.GetDisplayName())
|
||||
|
||||
@@ -44,10 +44,20 @@ func (i *LDAP) CreateEducationUser(ctx context.Context, user libregraph.Educatio
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Read back user from LDAP to get the generated UUID
|
||||
e, err := i.getEducationUserByDN(ar.DN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var e *ldap.Entry
|
||||
if i.useServerUUID {
|
||||
// The directory assigns the ID and conn.Add cannot return it, so we must
|
||||
// read the entry back to recover the generated UUID.
|
||||
e, err = i.readBackAfterWrite(func() (*ldap.Entry, error) {
|
||||
return i.getEducationUserByDN(ar.DN)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// oCIS generated the ID and wrote it into the AddRequest, so synthesize the
|
||||
// entry from data already in hand instead of reading it back.
|
||||
e = ldap.NewEntry(ar.DN, attrsFromAddRequest(ar))
|
||||
}
|
||||
return i.createEducationUserModelFromLDAP(e), nil
|
||||
}
|
||||
@@ -170,11 +180,11 @@ func (i *LDAP) UpdateEducationUser(ctx context.Context, id string, user libregra
|
||||
}
|
||||
}
|
||||
|
||||
// Read back user from LDAP to get the generated UUID
|
||||
e, err = i.getEducationUserByDN(e.DN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Fold the applied changes onto the pre-read entry instead of reading it back.
|
||||
// The ID is immutable on update (rejected above) and every field the model builder
|
||||
// reads is either already on e or in the ModifyRequest just applied. The rename
|
||||
// branch (changeUserName) is handled above and keeps its own read-back.
|
||||
e = applyModifyToEntry(e, &mr)
|
||||
|
||||
returnUser := i.createEducationUserModelFromLDAP(e)
|
||||
|
||||
|
||||
@@ -97,7 +97,11 @@ var sr3 *ldap.SearchRequest = &ldap.SearchRequest{
|
||||
|
||||
func TestCreateEducationUser(t *testing.T) {
|
||||
lm := &mocks.Client{}
|
||||
b, err := getMockedBackend(lm, eduConfig, &logger)
|
||||
// useServerUUID=true keeps the read-back path (the directory assigns the ID),
|
||||
// which is what this test asserts (Search called once, fixed entry returned).
|
||||
c := eduConfig
|
||||
c.UseServerUUID = true
|
||||
b, err := getMockedBackend(lm, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
//assert.NotEqual(t, "", b.educationConfig.schoolObjectClass)
|
||||
lm.On("Add", mock.Anything).Return(nil)
|
||||
|
||||
@@ -220,10 +220,20 @@ func (i *LDAP) CreateGroup(ctx context.Context, group libregraph.Group) (*libreg
|
||||
}
|
||||
}
|
||||
|
||||
// Read back group from LDAP to get the generated UUID
|
||||
e, err := i.getGroupByDN(ar.DN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var e *ldap.Entry
|
||||
if i.useServerUUID {
|
||||
// The directory assigns the ID and conn.Add cannot return it, so we must
|
||||
// read the entry back to recover the generated UUID.
|
||||
e, err = i.readBackAfterWrite(func() (*ldap.Entry, error) {
|
||||
return i.getGroupByDN(ar.DN)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// oCIS generated the ID and wrote it into the AddRequest, so synthesize the
|
||||
// entry from data already in hand instead of reading it back.
|
||||
e = ldap.NewEntry(ar.DN, attrsFromAddRequest(ar))
|
||||
}
|
||||
return i.createGroupModelFromLDAP(e), nil
|
||||
}
|
||||
@@ -462,7 +472,7 @@ func (i *LDAP) groupToLDAPAttrValues(group libregraph.Group) (map[string][]strin
|
||||
attrs["objectClass"] = append(attrs["objectClass"], i.groupAdditionalObjectClasses...)
|
||||
|
||||
if !i.useServerUUID {
|
||||
attrs["owncloudUUID"] = []string{uuid.Must(uuid.NewV4()).String()}
|
||||
attrs[i.groupAttributeMap.id] = []string{uuid.Must(uuid.NewV4()).String()}
|
||||
attrs["objectClass"] = append(attrs["objectClass"], "owncloud")
|
||||
}
|
||||
|
||||
@@ -490,7 +500,7 @@ func (i *LDAP) getLDAPGroupByNameOrID(nameOrID string, requestMembers bool) (*ld
|
||||
if err == nil {
|
||||
filter = fmt.Sprintf("(|(%s=%s)(%s=%s))", i.groupAttributeMap.name, ldap.EscapeFilter(nameOrID), i.groupAttributeMap.id, idString)
|
||||
} else {
|
||||
filter = fmt.Sprintf("(%s=%s)", i.userAttributeMap.userName, ldap.EscapeFilter(nameOrID))
|
||||
filter = fmt.Sprintf("(%s=%s)", i.groupAttributeMap.name, ldap.EscapeFilter(nameOrID))
|
||||
}
|
||||
return i.getLDAPGroupByFilter(filter, requestMembers)
|
||||
}
|
||||
|
||||
@@ -460,8 +460,12 @@ func TestUpdateUser(t *testing.T) {
|
||||
DN: "uid=oldName",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"oldmail@example.org"},
|
||||
Name: lconfig.UserDisplayNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
@@ -482,54 +486,6 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=oldName",
|
||||
Scope: 0,
|
||||
DerefAliases: 0,
|
||||
SizeLimit: 1,
|
||||
TimeLimit: 0,
|
||||
TypesOnly: false,
|
||||
Filter: "(objectClass=inetOrgPerson)",
|
||||
Attributes: ldapUserAttributes,
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
DN: "uid=oldName",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: lconfig.UserIDAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserEmailAttribute,
|
||||
Values: []string{"testuser@example.org"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserDisplayNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserEnabledAttribute,
|
||||
Values: []string{""},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
@@ -590,7 +546,11 @@ func TestUpdateUser(t *testing.T) {
|
||||
DN: "uid=oldName",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "displayname",
|
||||
Name: lconfig.UserDisplayNameAttribute,
|
||||
Values: []string{"oldName"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
@@ -612,54 +572,6 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=oldName",
|
||||
Scope: 0,
|
||||
DerefAliases: 0,
|
||||
SizeLimit: 1,
|
||||
TimeLimit: 0,
|
||||
TypesOnly: false,
|
||||
Filter: "(objectClass=inetOrgPerson)",
|
||||
Attributes: ldapUserAttributes,
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
DN: "uid=oldName",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: lconfig.UserIDAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserEmailAttribute,
|
||||
Values: []string{"testuser@example.org"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserDisplayNameAttribute,
|
||||
Values: []string{"newName"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserEnabledAttribute,
|
||||
Values: []string{""},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
@@ -910,8 +822,12 @@ func TestUpdateUser(t *testing.T) {
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testuser@example.org"},
|
||||
Name: lconfig.UserDisplayNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
@@ -932,54 +848,6 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=name",
|
||||
Scope: 0,
|
||||
DerefAliases: 0,
|
||||
SizeLimit: 1,
|
||||
TimeLimit: 0,
|
||||
TypesOnly: false,
|
||||
Filter: "(objectClass=inetOrgPerson)",
|
||||
Attributes: ldapUserAttributes,
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: lconfig.UserIDAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserEmailAttribute,
|
||||
Values: []string{"testuser@example.org"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserDisplayNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserNameAttribute,
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserEnabledAttribute,
|
||||
Values: []string{"FALSE"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
@@ -1040,9 +908,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "uid",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testuser@example.org"},
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
@@ -1114,58 +986,6 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change(nil),
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
ldap.NewSearchRequest(
|
||||
"uid=name",
|
||||
ldap.ScopeBaseObject,
|
||||
ldap.NeverDerefAliases, 1, 0, false,
|
||||
"(objectClass=inetOrgPerson)",
|
||||
ldapUserAttributes,
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "uid",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "mail",
|
||||
Values: []string{"testuser@example.org"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1207,9 +1027,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "uid",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testuser@example.org"},
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
@@ -1281,58 +1105,6 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change(nil),
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
ldap.NewSearchRequest(
|
||||
"uid=name",
|
||||
ldap.ScopeBaseObject,
|
||||
ldap.NeverDerefAliases, 1, 0, false,
|
||||
"(objectClass=inetOrgPerson)",
|
||||
ldapUserAttributes,
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "uid",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "mail",
|
||||
Values: []string{"testuser@example.org"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1373,9 +1145,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "uid",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testuser@example.org"},
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
@@ -1415,62 +1191,6 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change(nil),
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
ldap.NewSearchRequest(
|
||||
"uid=name",
|
||||
ldap.ScopeBaseObject,
|
||||
ldap.NeverDerefAliases, 1, 0, false,
|
||||
"(objectClass=inetOrgPerson)",
|
||||
ldapUserAttributes,
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
DN: "uid=name",
|
||||
Attributes: []*ldap.EntryAttribute{
|
||||
{
|
||||
Name: "uid",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "entryUUID",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "mail",
|
||||
Values: []string{"testuser@example.org"},
|
||||
},
|
||||
{
|
||||
Name: lconfig.UserTypeAttribute,
|
||||
Values: []string{"Member"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package identity
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
)
|
||||
|
||||
// attrsFromAddRequest flattens the attributes of an *ldap.AddRequest into the
|
||||
// map[string][]string shape that ldap.NewEntry expects. It is used to synthesize
|
||||
// the response entry from data already in hand, avoiding a read-after-write when
|
||||
// oCIS generated the entry's ID itself (useServerUUID=false).
|
||||
func attrsFromAddRequest(ar *ldap.AddRequest) map[string][]string {
|
||||
attrs := make(map[string][]string, len(ar.Attributes))
|
||||
for _, a := range ar.Attributes {
|
||||
vals := make([]string, len(a.Vals))
|
||||
copy(vals, a.Vals)
|
||||
attrs[a.Type] = vals
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
|
||||
// applyModifyToEntry returns a copy of base with the changes from mr folded on
|
||||
// (Replace / Add / Delete). It never mutates base. Attribute names are matched
|
||||
// case-insensitively, consistent with ldap.Entry's GetEqualFold* accessors, so
|
||||
// folding never produces a duplicate attribute entry that differs only in case.
|
||||
//
|
||||
// It is used to synthesize the response entry after an update from the pre-read
|
||||
// entry plus the ModifyRequest being persisted, avoiding a read-after-write.
|
||||
func applyModifyToEntry(base *ldap.Entry, mr *ldap.ModifyRequest) *ldap.Entry {
|
||||
if base == nil {
|
||||
return nil
|
||||
}
|
||||
if mr == nil {
|
||||
mr = &ldap.ModifyRequest{DN: base.DN}
|
||||
}
|
||||
// Deep-copy base into a name->values map so we never touch the original.
|
||||
attrs := make(map[string][]string, len(base.Attributes))
|
||||
// order preserves the original attribute order, with new attributes appended.
|
||||
order := make([]string, 0, len(base.Attributes))
|
||||
index := make(map[string]string, len(base.Attributes)) // fold-key -> stored name
|
||||
for _, a := range base.Attributes {
|
||||
vals := make([]string, len(a.Values))
|
||||
copy(vals, a.Values)
|
||||
attrs[a.Name] = vals
|
||||
order = append(order, a.Name)
|
||||
index[strings.ToLower(a.Name)] = a.Name
|
||||
}
|
||||
|
||||
// name resolves the stored attribute name for attrType case-insensitively,
|
||||
// registering a new attribute (preserving the request's casing) if none matches.
|
||||
name := func(attrType string) string {
|
||||
if n, ok := index[strings.ToLower(attrType)]; ok {
|
||||
return n
|
||||
}
|
||||
index[strings.ToLower(attrType)] = attrType
|
||||
order = append(order, attrType)
|
||||
return attrType
|
||||
}
|
||||
|
||||
for _, change := range mr.Changes {
|
||||
attrType := change.Modification.Type
|
||||
vals := change.Modification.Vals
|
||||
switch change.Operation {
|
||||
case ldap.ReplaceAttribute:
|
||||
n := name(attrType)
|
||||
cp := make([]string, len(vals))
|
||||
copy(cp, vals)
|
||||
attrs[n] = cp
|
||||
case ldap.AddAttribute:
|
||||
n := name(attrType)
|
||||
attrs[n] = append(attrs[n], vals...)
|
||||
case ldap.DeleteAttribute:
|
||||
if n, ok := index[strings.ToLower(attrType)]; ok {
|
||||
if len(vals) == 0 {
|
||||
// whole-attribute delete
|
||||
delete(attrs, n)
|
||||
} else {
|
||||
kept := removeValues(attrs[n], vals)
|
||||
if len(kept) == 0 {
|
||||
// the last value was removed; a real server drops the attribute
|
||||
delete(attrs, n)
|
||||
} else {
|
||||
attrs[n] = kept
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dn := base.DN
|
||||
if mr.DN != "" {
|
||||
dn = mr.DN
|
||||
}
|
||||
result := ldap.NewEntry(dn, nil)
|
||||
result.Attributes = make([]*ldap.EntryAttribute, 0, len(order))
|
||||
for _, n := range order {
|
||||
v, ok := attrs[n]
|
||||
if !ok {
|
||||
// deleted attribute
|
||||
continue
|
||||
}
|
||||
result.Attributes = append(result.Attributes, ldap.NewEntryAttribute(n, v))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// removeValues returns have with every element of remove stripped out.
|
||||
func removeValues(have, remove []string) []string {
|
||||
if len(have) == 0 {
|
||||
return have
|
||||
}
|
||||
drop := make(map[string]struct{}, len(remove))
|
||||
for _, r := range remove {
|
||||
drop[r] = struct{}{}
|
||||
}
|
||||
kept := make([]string, 0, len(have))
|
||||
for _, v := range have {
|
||||
if _, ok := drop[v]; ok {
|
||||
continue
|
||||
}
|
||||
kept = append(kept, v)
|
||||
}
|
||||
return kept
|
||||
}
|
||||
@@ -0,0 +1,741 @@
|
||||
package identity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func TestAttrsFromAddRequest(t *testing.T) {
|
||||
ar := ldap.NewAddRequest("uid=alice,ou=people,dc=test", nil)
|
||||
ar.Attribute("uid", []string{"alice"})
|
||||
ar.Attribute("displayname", []string{"Alice Example"})
|
||||
ar.Attribute("mail", []string{"alice@example.org", "a@example.org"})
|
||||
|
||||
attrs := attrsFromAddRequest(ar)
|
||||
|
||||
assert.Equal(t, []string{"alice"}, attrs["uid"])
|
||||
assert.Equal(t, []string{"Alice Example"}, attrs["displayname"])
|
||||
assert.Equal(t, []string{"alice@example.org", "a@example.org"}, attrs["mail"])
|
||||
|
||||
// round-trips through ldap.NewEntry with case-insensitive lookup
|
||||
e := ldap.NewEntry(ar.DN, attrs)
|
||||
assert.Equal(t, ar.DN, e.DN)
|
||||
assert.Equal(t, "alice", e.GetEqualFoldAttributeValue("UID"))
|
||||
assert.Equal(t, "Alice Example", e.GetEqualFoldAttributeValue("displayName"))
|
||||
assert.Equal(t, []string{"alice@example.org", "a@example.org"}, e.GetEqualFoldAttributeValues("mail"))
|
||||
}
|
||||
|
||||
// TestAttrsFromAddRequestDoesNotAliasRequest guards against attrsFromAddRequest
|
||||
// returning slices that alias ar.Attributes[].Vals: mutating the returned map must
|
||||
// never change the AddRequest's own values, and vice versa.
|
||||
func TestAttrsFromAddRequestDoesNotAliasRequest(t *testing.T) {
|
||||
ar := ldap.NewAddRequest("uid=alice,ou=people,dc=test", nil)
|
||||
ar.Attribute("mail", []string{"alice@example.org"})
|
||||
|
||||
attrs := attrsFromAddRequest(ar)
|
||||
attrs["mail"][0] = "mutated@example.org"
|
||||
|
||||
assert.Equal(t, []string{"alice@example.org"}, ar.Attributes[0].Vals)
|
||||
}
|
||||
|
||||
func TestApplyModifyToEntry(t *testing.T) {
|
||||
base := ldap.NewEntry("uid=alice,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"alice"},
|
||||
"displayname": {"Alice Example"},
|
||||
"mail": {"alice@example.org"},
|
||||
"member": {"cn=a", "cn=b"},
|
||||
})
|
||||
|
||||
t.Run("Replace overwrites existing attribute", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("displayname", []string{"Alice New"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice New", got.GetEqualFoldAttributeValue("displayname"))
|
||||
})
|
||||
|
||||
t.Run("Replace adds a not-yet-present attribute", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("givenname", []string{"Alice"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice", got.GetEqualFoldAttributeValue("givenname"))
|
||||
})
|
||||
|
||||
t.Run("Add appends to existing attribute", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Add("member", []string{"cn=c"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, []string{"cn=a", "cn=b", "cn=c"}, got.GetEqualFoldAttributeValues("member"))
|
||||
})
|
||||
|
||||
t.Run("Delete whole attribute", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Delete("mail", []string{})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Empty(t, got.GetEqualFoldAttributeValues("mail"))
|
||||
})
|
||||
|
||||
t.Run("Delete specific value", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Delete("member", []string{"cn=a"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, []string{"cn=b"}, got.GetEqualFoldAttributeValues("member"))
|
||||
})
|
||||
|
||||
t.Run("Delete last remaining value drops the attribute", func(t *testing.T) {
|
||||
single := ldap.NewEntry(base.DN, map[string][]string{
|
||||
"member": {"cn=a"},
|
||||
})
|
||||
mr := &ldap.ModifyRequest{DN: single.DN}
|
||||
mr.Delete("member", []string{"cn=a"})
|
||||
|
||||
got := applyModifyToEntry(single, mr)
|
||||
assert.Empty(t, got.GetEqualFoldAttributeValues("member"))
|
||||
for _, a := range got.Attributes {
|
||||
assert.NotEqual(t, "member", strings.ToLower(a.Name), "attribute must be dropped, not left empty")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("nil ModifyRequest returns base unchanged", func(t *testing.T) {
|
||||
got := applyModifyToEntry(base, nil)
|
||||
assert.Equal(t, base.DN, got.DN)
|
||||
assert.Equal(t, "Alice Example", got.GetEqualFoldAttributeValue("displayname"))
|
||||
assert.Equal(t, []string{"cn=a", "cn=b"}, got.GetEqualFoldAttributeValues("member"))
|
||||
})
|
||||
|
||||
t.Run("nil base returns nil", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: "uid=alice,ou=people,dc=test"}
|
||||
mr.Replace("displayname", []string{"Alice New"})
|
||||
|
||||
got := applyModifyToEntry(nil, mr)
|
||||
assert.Nil(t, got)
|
||||
})
|
||||
|
||||
t.Run("case-insensitive match creates no duplicate", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("DisplayName", []string{"Alice Caps"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice Caps", got.GetEqualFoldAttributeValue("displayname"))
|
||||
// exactly one attribute entry whose name folds to displayname
|
||||
count := 0
|
||||
for _, a := range got.Attributes {
|
||||
if strings.EqualFold(a.Name, "displayname") {
|
||||
count++
|
||||
}
|
||||
}
|
||||
assert.Equal(t, 1, count)
|
||||
})
|
||||
|
||||
t.Run("base is never mutated", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("displayname", []string{"Mutated"})
|
||||
mr.Add("member", []string{"cn=z"})
|
||||
mr.Delete("mail", []string{})
|
||||
|
||||
_ = applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice Example", base.GetEqualFoldAttributeValue("displayname"))
|
||||
assert.Equal(t, []string{"cn=a", "cn=b"}, base.GetEqualFoldAttributeValues("member"))
|
||||
assert.Equal(t, "alice@example.org", base.GetEqualFoldAttributeValue("mail"))
|
||||
})
|
||||
|
||||
t.Run("Replace populates ByteValues for raw accessors", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("displayname", []string{"Raw Value"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, []byte("Raw Value"), got.GetEqualFoldRawAttributeValue("displayname"))
|
||||
})
|
||||
}
|
||||
|
||||
// TestCreateUserSynthesizesWhenNotServerUUID asserts that with useServerUUID=false
|
||||
// CreateUser builds the response model from the AddRequest instead of reading the
|
||||
// entry back — i.e. no Search is issued after the Add.
|
||||
func TestCreateUserSynthesizesWhenNotServerUUID(t *testing.T) {
|
||||
displayName := "DisplayName"
|
||||
mail := "user@example"
|
||||
userName := "user"
|
||||
surname := "surname"
|
||||
givenName := "givenName"
|
||||
userType := "Member"
|
||||
|
||||
l := &mocks.Client{}
|
||||
// Add succeeds; Search must NOT be called (no read-back).
|
||||
l.On("Add", mock.Anything).Return(nil)
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
user := libregraph.NewUser(displayName, userName)
|
||||
user.SetMail(mail)
|
||||
user.SetSurname(surname)
|
||||
user.SetGivenName(givenName)
|
||||
user.SetAccountEnabled(true)
|
||||
user.SetUserType(userType)
|
||||
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
b, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.Nil(t, err)
|
||||
|
||||
newUser, err := b.CreateUser(context.Background(), *user)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, displayName, newUser.GetDisplayName())
|
||||
assert.Equal(t, mail, newUser.GetMail())
|
||||
assert.Equal(t, userName, newUser.GetOnPremisesSamAccountName())
|
||||
assert.Equal(t, givenName, newUser.GetGivenName())
|
||||
assert.Equal(t, surname, newUser.GetSurname())
|
||||
assert.True(t, newUser.GetAccountEnabled())
|
||||
assert.Equal(t, userType, newUser.GetUserType())
|
||||
// oCIS generated the id and wrote it into the Add; it must be present on the model.
|
||||
assert.NotEmpty(t, newUser.GetId())
|
||||
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
}
|
||||
|
||||
// TestCreateUserSynthesizedModelEqualsReadBack is the regression guard: the model
|
||||
// CreateUser returns from the synthesize path (useServerUUID=false) must equal the
|
||||
// model the unchanged builder produces from the entry a read-back would have returned
|
||||
// — i.e. the server's echo of exactly what oCIS wrote. Eliminating the read-back must
|
||||
// not change the CreateUser response for any populated field.
|
||||
func TestCreateUserSynthesizedModelEqualsReadBack(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
user := libregraph.NewUser("DisplayName", "user")
|
||||
user.SetMail("user@example")
|
||||
user.SetSurname("surname")
|
||||
user.SetGivenName("givenName")
|
||||
user.SetAccountEnabled(true)
|
||||
user.SetUserType("Member")
|
||||
|
||||
// Capture the AddRequest so we can reproduce the entry a read-back would return.
|
||||
var written *ldap.AddRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Run(func(args mock.Arguments) {
|
||||
written = args.Get(0).(*ldap.AddRequest)
|
||||
}).Return(nil)
|
||||
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
b, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.Nil(t, err)
|
||||
|
||||
synthUser, err := b.CreateUser(context.Background(), *user)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Ground truth: what the old read-back path would have built. A base-scoped search
|
||||
// on the DN returns exactly the attributes that were written, so the read-back entry
|
||||
// is ldap.NewEntry over the captured AddRequest.
|
||||
readBackEntry := ldap.NewEntry(written.DN, attrsFromAddRequest(written))
|
||||
readBackModel := b.createUserModelFromLDAP(readBackEntry)
|
||||
|
||||
assert.Equal(t, readBackModel, synthUser)
|
||||
}
|
||||
|
||||
// TestSynthesizedEntryPopulatesInstancesWithoutSearch is the regression guard for the
|
||||
// attribute-sourced multi-instance fields. With instanceURLTemplate +
|
||||
// crossInstanceReferenceTemplate configured and instanceMapperEnabled=false, building a
|
||||
// user model from a synthesized entry (as the create/update fold paths do) must populate
|
||||
// user.Instances / CrossInstanceReference AND must not issue a live Search — the codepath
|
||||
// only searches when instanceMapperEnabled=true, which is mutually exclusive with the
|
||||
// "no second LDAP call" guarantee (see the design spec's Testing section).
|
||||
func TestSynthesizedEntryPopulatesInstancesWithoutSearch(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := lconfig
|
||||
c.UserMemberAttribute = "ocMemberOfInstance"
|
||||
c.InstanceURLTemplate = "https://{{.Instancename}}.example.org"
|
||||
c.CrossInstanceReferenceTemplate = "{{.Username}}@{{.Instancename}}"
|
||||
c.InstanceMapperEnabled = false
|
||||
|
||||
l := &mocks.Client{}
|
||||
// A non-empty instanceID is required for the instance templates to be parsed.
|
||||
b, err := NewLDAPBackend(l, c, &logger, "instanceA", "")
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Synthesized entry as attrsFromAddRequest + ldap.NewEntry would produce, carrying a
|
||||
// member-of-instance value so the Instances loop runs.
|
||||
entry := ldap.NewEntry("uid=user,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"user"},
|
||||
"displayname": {"DisplayName"},
|
||||
"mail": {"user@example"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"ocMemberOfInstance": {"instanceA"},
|
||||
})
|
||||
|
||||
model := b.createUserModelFromLDAP(entry)
|
||||
assert.NotNil(t, model)
|
||||
assert.NotEmpty(t, model.Instances)
|
||||
assert.Equal(t, "https://instanceA.example.org", model.Instances[0].GetUrl())
|
||||
assert.NotNil(t, model.CrossInstanceReference)
|
||||
assert.Equal(t, "user@instanceA", model.GetCrossInstanceReference())
|
||||
|
||||
// instanceMapperEnabled=false → getInstance returns the value verbatim, no Search.
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
}
|
||||
|
||||
// TestCreateGroupSynthesizesWhenNotServerUUID asserts CreateGroup builds its response
|
||||
// from the AddRequest (no read-back) when oCIS generated the id itself.
|
||||
func TestCreateGroupSynthesizesWhenNotServerUUID(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
// oCIS writes the generated group id under the configured GroupIDAttribute, so the
|
||||
// synthesized entry must carry the id under that attribute for the model builder.
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
c.GroupIDAttribute = "owncloudUUID"
|
||||
|
||||
var written *ldap.AddRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Run(func(args mock.Arguments) {
|
||||
written = args.Get(0).(*ldap.AddRequest)
|
||||
}).Return(nil)
|
||||
|
||||
b, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.Nil(t, err)
|
||||
|
||||
group := libregraph.NewGroup()
|
||||
group.SetDisplayName("mygroup")
|
||||
|
||||
newGroup, err := b.CreateGroup(context.Background(), *group)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "mygroup", newGroup.GetDisplayName())
|
||||
assert.NotEmpty(t, newGroup.GetId())
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
|
||||
// parity with the read-back-derived model
|
||||
readBackModel := b.createGroupModelFromLDAP(ldap.NewEntry(written.DN, attrsFromAddRequest(written)))
|
||||
assert.Equal(t, readBackModel, newGroup)
|
||||
}
|
||||
|
||||
// TestCreateEducationUserSynthesizesWhenNotServerUUID asserts CreateEducationUser
|
||||
// synthesizes its response (no read-back) when oCIS generated the id itself.
|
||||
func TestCreateEducationUserSynthesizesWhenNotServerUUID(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := eduConfig
|
||||
c.UseServerUUID = false
|
||||
|
||||
var written *ldap.AddRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Run(func(args mock.Arguments) {
|
||||
written = args.Get(0).(*ldap.AddRequest)
|
||||
}).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
user := libregraph.NewEducationUser()
|
||||
user.SetDisplayName("Test User")
|
||||
user.SetOnPremisesSamAccountName("testuser")
|
||||
user.SetMail("testuser@example.org")
|
||||
user.SetPrimaryRole("student")
|
||||
user.SetUserType("Member")
|
||||
user.SetAccountEnabled(false)
|
||||
user.SetExternalID("ext-ernal-id")
|
||||
|
||||
eduUser, err := b.CreateEducationUser(context.Background(), *user)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Test User", eduUser.GetDisplayName())
|
||||
assert.Equal(t, "testuser", eduUser.GetOnPremisesSamAccountName())
|
||||
assert.NotEmpty(t, eduUser.GetId())
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
|
||||
readBackModel := b.createEducationUserModelFromLDAP(ldap.NewEntry(written.DN, attrsFromAddRequest(written)))
|
||||
assert.Equal(t, readBackModel, eduUser)
|
||||
}
|
||||
|
||||
// TestCreateEducationClassSynthesizesWhenNotServerUUID asserts CreateEducationClass
|
||||
// synthesizes its response (no read-back) when oCIS generated the id itself.
|
||||
func TestCreateEducationClassSynthesizesWhenNotServerUUID(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := eduConfig
|
||||
c.UseServerUUID = false
|
||||
c.GroupIDAttribute = "owncloudUUID"
|
||||
|
||||
var written *ldap.AddRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Run(func(args mock.Arguments) {
|
||||
written = args.Get(0).(*ldap.AddRequest)
|
||||
}).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
class := libregraph.NewEducationClass()
|
||||
class.SetExternalId("Math0123")
|
||||
class.SetDisplayName("Math")
|
||||
class.SetClassification("course")
|
||||
|
||||
resClass, err := b.CreateEducationClass(context.Background(), *class)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Math", resClass.GetDisplayName())
|
||||
assert.Equal(t, "Math0123", resClass.GetExternalId())
|
||||
assert.Equal(t, "course", resClass.GetClassification())
|
||||
assert.NotEmpty(t, resClass.GetId())
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
|
||||
readBackModel := b.createEducationClassModelFromLDAP(ldap.NewEntry(written.DN, attrsFromAddRequest(written)))
|
||||
assert.Equal(t, readBackModel, resClass)
|
||||
}
|
||||
|
||||
// TestCreateEducationSchoolSynthesizesWhenNotServerUUID asserts CreateEducationSchool
|
||||
// synthesizes its response (no read-back) when oCIS generated the id itself. The
|
||||
// pre-create duplicate-number Search still fires; only the read-back is eliminated.
|
||||
func TestCreateEducationSchoolSynthesizesWhenNotServerUUID(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := eduConfig
|
||||
c.UseServerUUID = false
|
||||
|
||||
var written *ldap.AddRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Run(func(args mock.Arguments) {
|
||||
written = args.Get(0).(*ldap.AddRequest)
|
||||
}).Return(nil)
|
||||
// The duplicate-schoolNumber lookup before Add is a subtree search that returns
|
||||
// "not found" so create proceeds. No base-scoped read-back must follow the Add.
|
||||
l.On("Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeWholeSubtree
|
||||
})).Return(&ldap.SearchResult{Entries: []*ldap.Entry{}}, nil)
|
||||
|
||||
b, err := getMockedBackend(l, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
school := libregraph.NewEducationSchool()
|
||||
school.SetDisplayName("Test School")
|
||||
school.SetSchoolNumber("0123")
|
||||
|
||||
resSchool, err := b.CreateEducationSchool(context.Background(), *school)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Test School", resSchool.GetDisplayName())
|
||||
assert.Equal(t, "0123", resSchool.GetSchoolNumber())
|
||||
assert.NotEmpty(t, resSchool.GetId())
|
||||
// no base-scoped read-back on the created school DN
|
||||
l.AssertNotCalled(t, "Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeBaseObject
|
||||
}))
|
||||
|
||||
readBackModel := b.createSchoolModelFromLDAP(ldap.NewEntry(written.DN, attrsFromAddRequest(written)))
|
||||
assert.Equal(t, readBackModel, resSchool)
|
||||
}
|
||||
|
||||
// TestUpdateUserFoldsNoReadBack asserts a non-rename UpdateUser does not read the
|
||||
// entry back: it pre-reads once, Modifies, and folds the ModifyRequest onto the
|
||||
// pre-read entry to build the response.
|
||||
func TestUpdateUserFoldsNoReadBack(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
preRead := ldap.NewEntry("uid=user,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"user"},
|
||||
"displayname": {"Old Name"},
|
||||
"mail": {"old@example.org"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"userTypeAttribute": {"Member"},
|
||||
})
|
||||
|
||||
l := &mocks.Client{}
|
||||
// Pre-read (subtree search by name/id) returns the entry once.
|
||||
l.On("Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeWholeSubtree
|
||||
})).Return(&ldap.SearchResult{Entries: []*ldap.Entry{preRead}}, nil).Once()
|
||||
l.On("Modify", mock.Anything).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, lconfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
id := "abcd-defg"
|
||||
newMail := "new@example.org"
|
||||
update := libregraph.UserUpdate{Mail: &newMail}
|
||||
update.Id = &id
|
||||
|
||||
got, err := b.UpdateUser(context.Background(), "user", update)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, newMail, got.GetMail())
|
||||
assert.Equal(t, "Old Name", got.GetDisplayName())
|
||||
assert.Equal(t, "abcd-defg", got.GetId())
|
||||
|
||||
// No base-scoped read-back after the Modify.
|
||||
l.AssertNotCalled(t, "Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeBaseObject
|
||||
}))
|
||||
}
|
||||
|
||||
// TestUpdateEducationUserFoldsNoReadBack asserts a non-rename UpdateEducationUser
|
||||
// folds the ModifyRequest onto the pre-read entry rather than reading it back.
|
||||
func TestUpdateEducationUserFoldsNoReadBack(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
preRead := ldap.NewEntry("uid=testuser,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"testuser"},
|
||||
"displayname": {"Test User"},
|
||||
"mail": {"old@example.org"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"userClass": {"student"},
|
||||
"userTypeAttribute": {"Member"},
|
||||
})
|
||||
|
||||
l := &mocks.Client{}
|
||||
// Pre-read by name/id (subtree) returns the entry; no base-scoped read-back after.
|
||||
l.On("Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeWholeSubtree
|
||||
})).Return(&ldap.SearchResult{Entries: []*ldap.Entry{preRead}}, nil).Once()
|
||||
l.On("Modify", mock.Anything).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, eduConfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
newMail := "new@example.org"
|
||||
user := libregraph.NewEducationUser()
|
||||
user.SetMail(newMail)
|
||||
|
||||
got, err := b.UpdateEducationUser(context.Background(), "testuser", *user)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, newMail, got.GetMail())
|
||||
assert.Equal(t, "Test User", got.GetDisplayName())
|
||||
assert.Equal(t, "abcd-defg", got.GetId())
|
||||
|
||||
l.AssertNotCalled(t, "Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeBaseObject
|
||||
}))
|
||||
}
|
||||
|
||||
// TestUpdateEducationSchoolFoldsNoReadBack asserts UpdateEducationSchool folds the
|
||||
// applied property changes onto the pre-read entry rather than reading it back.
|
||||
func TestUpdateEducationSchoolFoldsNoReadBack(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
preRead := ldap.NewEntry("ou=Test School", map[string][]string{
|
||||
"ou": {"Test School"},
|
||||
"ocEducationSchoolNumber": {"0123"},
|
||||
"owncloudUUID": {"abcd-defg"},
|
||||
})
|
||||
|
||||
l := &mocks.Client{}
|
||||
// Single pre-read; the termination Replace is folded on. No second Search.
|
||||
l.On("Search", mock.Anything).Return(&ldap.SearchResult{Entries: []*ldap.Entry{preRead}}, nil).Once()
|
||||
l.On("Modify", mock.Anything).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, eduConfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
school := libregraph.NewEducationSchool()
|
||||
terminationTime := time.Date(2042, time.January, 31, 12, 0, 0, 0, time.UTC)
|
||||
school.SetTerminationDate(terminationTime)
|
||||
|
||||
got, err := b.UpdateEducationSchool(context.Background(), "abcd-defg", *school)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Test School", got.GetDisplayName())
|
||||
assert.Equal(t, "abcd-defg", got.GetId())
|
||||
assert.Equal(t, "0123", got.GetSchoolNumber())
|
||||
// the folded termination date is reflected in the response
|
||||
assert.True(t, got.HasTerminationDate())
|
||||
assert.True(t, terminationTime.Equal(got.GetTerminationDate()))
|
||||
|
||||
l.AssertNumberOfCalls(t, "Search", 1)
|
||||
}
|
||||
|
||||
// TestUpdateEducationClassFoldPreservesClassificationAndExternalID guards the Site 9
|
||||
// regression: folding must not drop classification/externalID from the response, even
|
||||
// on an update that only changes displayName. It also asserts no read-back after Modify.
|
||||
func TestUpdateEducationClassFoldPreservesClassificationAndExternalID(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
// Full education-class entry as getEducationClassByID would return it.
|
||||
preRead := ldap.NewEntry("ocEducationExternalId=Math0123,ou=groups,dc=test", map[string][]string{
|
||||
"cn": {"Math"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"ocEducationExternalId": {"Math0123"},
|
||||
"ocEducationClassType": {"course"},
|
||||
})
|
||||
|
||||
l := &mocks.Client{}
|
||||
l.On("Search", mock.Anything).Return(&ldap.SearchResult{Entries: []*ldap.Entry{preRead}}, nil).Once()
|
||||
l.On("Modify", mock.Anything).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, eduConfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
newName := "Math-2"
|
||||
class := libregraph.EducationClass{DisplayName: &newName}
|
||||
|
||||
got, err := b.UpdateEducationClass(context.Background(), "abcd-defg", class)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Math-2", got.GetDisplayName())
|
||||
assert.Equal(t, "abcd-defg", got.GetId())
|
||||
// classification and externalID must survive a displayName-only update
|
||||
assert.Equal(t, "course", got.GetClassification())
|
||||
assert.Equal(t, "Math0123", got.GetExternalId())
|
||||
|
||||
l.AssertNotCalled(t, "Search", mock.MatchedBy(func(sr *ldap.SearchRequest) bool {
|
||||
return sr.Scope == ldap.ScopeBaseObject
|
||||
}))
|
||||
}
|
||||
|
||||
// TestCreateGroupSynthesizesWithNonDefaultIDAttribute guards the fix for the
|
||||
// hardcoded "owncloudUUID" id write: the generated id must be stored under the
|
||||
// configured GroupIDAttribute, otherwise the synthesized model has no id and
|
||||
// createGroupModelFromLDAP returns nil (CreateGroup would return (nil, nil)).
|
||||
func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
c.GroupIDAttribute = "entryUUID" // non-default: previously the id was written to owncloudUUID only
|
||||
|
||||
var written *ldap.AddRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Run(func(args mock.Arguments) {
|
||||
written = args.Get(0).(*ldap.AddRequest)
|
||||
}).Return(nil)
|
||||
|
||||
b, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.Nil(t, err)
|
||||
|
||||
group := libregraph.NewGroup()
|
||||
group.SetDisplayName("mygroup")
|
||||
|
||||
newGroup, err := b.CreateGroup(context.Background(), *group)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, newGroup)
|
||||
assert.Equal(t, "mygroup", newGroup.GetDisplayName())
|
||||
// the id was written under the configured attribute and survives synthesis
|
||||
assert.NotEmpty(t, newGroup.GetId())
|
||||
assert.NotEmpty(t, written.Attributes)
|
||||
// the AddRequest carries the id under the configured attribute, not "owncloudUUID"
|
||||
var idFromConfigured, idFromHardcoded string
|
||||
for _, a := range written.Attributes {
|
||||
switch a.Type {
|
||||
case c.GroupIDAttribute:
|
||||
if len(a.Vals) > 0 {
|
||||
idFromConfigured = a.Vals[0]
|
||||
}
|
||||
case "owncloudUUID":
|
||||
if len(a.Vals) > 0 {
|
||||
idFromHardcoded = a.Vals[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.NotEmpty(t, idFromConfigured, "id must be written under the configured GroupIDAttribute")
|
||||
assert.Empty(t, idFromHardcoded, "id must not be written under a hardcoded owncloudUUID")
|
||||
assert.Equal(t, idFromConfigured, newGroup.GetId())
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
}
|
||||
|
||||
// TestCreateEducationClassSynthesizesWithNonDefaultIDAttribute guards the same
|
||||
// hardcoded-id fix on the education-class create path, which reuses
|
||||
// groupToLDAPAttrValues.
|
||||
func TestCreateEducationClassSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := eduConfig
|
||||
c.UseServerUUID = false
|
||||
c.GroupIDAttribute = "entryUUID" // non-default
|
||||
|
||||
l := &mocks.Client{}
|
||||
l.On("Add", mock.Anything).Return(nil)
|
||||
|
||||
b, err := getMockedBackend(l, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
class := libregraph.NewEducationClass()
|
||||
class.SetExternalId("Math0123")
|
||||
class.SetDisplayName("Math")
|
||||
class.SetClassification("course")
|
||||
|
||||
resClass, err := b.CreateEducationClass(context.Background(), *class)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, resClass)
|
||||
assert.Equal(t, "Math", resClass.GetDisplayName())
|
||||
// the id survives synthesis under the configured attribute
|
||||
assert.NotEmpty(t, resClass.GetId())
|
||||
l.AssertNotCalled(t, "Search", mock.Anything)
|
||||
}
|
||||
|
||||
// TestGetGroupByNameUsesGroupNameAttribute guards the fix for the name-only lookup
|
||||
// branch of getLDAPGroupByNameOrID, which previously filtered by the user name
|
||||
// attribute (uid) instead of the group name attribute (cn), so a group could never
|
||||
// be found by name. That else-branch is reached when filterEscapeUUID errors, which
|
||||
// happens for a non-UUID name when the id attribute is an octet string. The lookup
|
||||
// is exercised directly so the assertion isolates the filter, independent of model
|
||||
// building.
|
||||
func TestGetGroupByNameUsesGroupNameAttribute(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
|
||||
c := lconfig
|
||||
// Octet-string group IDs require server-assigned UUIDs; this also makes
|
||||
// filterEscapeUUID error on a non-UUID name, reaching the name-only else branch.
|
||||
c.UseServerUUID = true
|
||||
c.GroupIDIsOctetString = true
|
||||
|
||||
var groupSearch *ldap.SearchRequest
|
||||
l := &mocks.Client{}
|
||||
l.On("Search", mock.Anything).Run(func(args mock.Arguments) {
|
||||
groupSearch = args.Get(0).(*ldap.SearchRequest)
|
||||
}).Return(&ldap.SearchResult{Entries: []*ldap.Entry{groupEntry}}, nil)
|
||||
|
||||
b, err := getMockedBackend(l, c, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
_, err = b.getLDAPGroupByNameOrID("group", false)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, groupSearch)
|
||||
// the filter must use the group name attribute (cn), not the user name attribute (uid)
|
||||
assert.Contains(t, groupSearch.Filter, "("+b.groupAttributeMap.name+"=group)")
|
||||
assert.NotContains(t, groupSearch.Filter, b.userAttributeMap.userName+"=group")
|
||||
}
|
||||
|
||||
// TestNewLDAPBackendRejectsOctetStringWithoutServerUUID guards the fail-fast check:
|
||||
// octet-string ID attributes (server-assigned, e.g. AD objectGUID) are incompatible
|
||||
// with UseServerUUID=false, where oCIS generates string UUIDs. The combination must
|
||||
// be rejected at startup rather than silently producing corrupt IDs.
|
||||
func TestNewLDAPBackendRejectsOctetStringWithoutServerUUID(t *testing.T) {
|
||||
logger := log.NewLogger(log.Level("debug"))
|
||||
l := &mocks.Client{}
|
||||
|
||||
t.Run("user octet-string without server UUID is rejected", func(t *testing.T) {
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
c.UserIDIsOctetString = true
|
||||
_, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("group octet-string without server UUID is rejected", func(t *testing.T) {
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
c.GroupIDIsOctetString = true
|
||||
_, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("octet-string with server UUID is allowed", func(t *testing.T) {
|
||||
c := lconfig
|
||||
c.UseServerUUID = true
|
||||
c.UserIDIsOctetString = true
|
||||
c.GroupIDIsOctetString = true
|
||||
_, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("string IDs without server UUID is allowed", func(t *testing.T) {
|
||||
c := lconfig
|
||||
c.UseServerUUID = false
|
||||
c.UserIDIsOctetString = false
|
||||
c.GroupIDIsOctetString = false
|
||||
_, err := NewLDAPBackend(l, c, &logger, "", "")
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
@@ -435,20 +435,20 @@ func (g BaseGraphService) cs3UserSharesToDriveItems(ctx context.Context, shares
|
||||
return nil
|
||||
})
|
||||
}
|
||||
// Wait for things to settle down, then close results chan
|
||||
go func() {
|
||||
_ = errg.Wait() // error is checked later
|
||||
close(results)
|
||||
}()
|
||||
|
||||
// Wait for all workers to finish before collecting the results. The workers
|
||||
// read from driveItems, so writing to it below must not overlap with them.
|
||||
// The results channel is buffered with len(shares), which is at least the
|
||||
// number of items the workers can send, so they never block on the handover.
|
||||
if err := errg.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
close(results)
|
||||
|
||||
for item := range results {
|
||||
driveItems[item.GetId()] = *item
|
||||
}
|
||||
|
||||
if err := errg.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return driveItems, nil
|
||||
}
|
||||
|
||||
@@ -535,20 +535,20 @@ func (g BaseGraphService) cs3OCMSharesToDriveItems(ctx context.Context, shares [
|
||||
return nil
|
||||
})
|
||||
}
|
||||
// Wait for things to settle down, then close results chan
|
||||
go func() {
|
||||
_ = errg.Wait() // error is checked later
|
||||
close(results)
|
||||
}()
|
||||
|
||||
// Wait for all workers to finish before collecting the results. The workers
|
||||
// read from driveItems, so writing to it below must not overlap with them.
|
||||
// The results channel is buffered with len(shares), which is at least the
|
||||
// number of items the workers can send, so they never block on the handover.
|
||||
if err := errg.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
close(results)
|
||||
|
||||
for item := range results {
|
||||
driveItems[item.GetId()] = *item
|
||||
}
|
||||
|
||||
if err := errg.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return driveItems, nil
|
||||
}
|
||||
|
||||
@@ -797,20 +797,20 @@ func (g BaseGraphService) cs3PublicSharesToDriveItems(ctx context.Context, share
|
||||
return nil
|
||||
})
|
||||
}
|
||||
// Wait for things to settle down, then close results chan
|
||||
go func() {
|
||||
_ = errg.Wait() // error is checked later
|
||||
close(results)
|
||||
}()
|
||||
|
||||
// Wait for all workers to finish before collecting the results. The workers
|
||||
// read from driveItems, so writing to it below must not overlap with them.
|
||||
// The results channel is buffered with len(shares), which is at least the
|
||||
// number of items the workers can send, so they never block on the handover.
|
||||
if err := errg.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
close(results)
|
||||
|
||||
for item := range results {
|
||||
driveItems[item.GetId()] = *item
|
||||
}
|
||||
|
||||
if err := errg.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return driveItems, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
|
||||
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
|
||||
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
|
||||
"github.com/owncloud/reva/v2/pkg/conversions"
|
||||
"github.com/owncloud/reva/v2/pkg/rgrpc/status"
|
||||
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
|
||||
cs3mocks "github.com/owncloud/reva/v2/tests/cs3mocks/mocks"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// numRaceTestResources needs to be comfortably larger than the number of
|
||||
// workers so that some workers are still reading from the driveItems map while
|
||||
// the collecting loop has already started writing to it.
|
||||
const numRaceTestResources = 200
|
||||
|
||||
// newRaceTestService builds a BaseGraphService with a mocked gateway that can
|
||||
// stat any resource and resolve any user.
|
||||
func newRaceTestService(t *testing.T, maxConcurrency int) BaseGraphService {
|
||||
t.Helper()
|
||||
|
||||
selectorName := fmt.Sprintf("GatewaySelectorRace%d", maxConcurrency)
|
||||
pool.RemoveSelector(selectorName + "com.owncloud.api.gateway")
|
||||
|
||||
gatewayClient := &cs3mocks.GatewayAPIClient{}
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(
|
||||
func(_ context.Context, req *storageprovider.StatRequest, _ ...grpc.CallOption) *storageprovider.StatResponse {
|
||||
return &storageprovider.StatResponse{
|
||||
Status: status.NewOK(context.Background()),
|
||||
Info: &storageprovider.ResourceInfo{
|
||||
Id: req.GetRef().GetResourceId(),
|
||||
Type: storageprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}
|
||||
},
|
||||
nil,
|
||||
)
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(
|
||||
&userpb.GetUserResponse{
|
||||
Status: status.NewOK(context.Background()),
|
||||
User: &userpb.User{
|
||||
Id: &userpb.UserId{Idp: "idp", OpaqueId: "user-id"},
|
||||
DisplayName: "User Name",
|
||||
},
|
||||
},
|
||||
nil,
|
||||
)
|
||||
gatewayClient.On("GetPublicShare", mock.Anything, mock.Anything).Return(
|
||||
&link.GetPublicShareResponse{Status: status.NewOK(context.Background())},
|
||||
nil,
|
||||
)
|
||||
|
||||
gatewaySelector := pool.GetSelector[gateway.GatewayAPIClient](
|
||||
selectorName,
|
||||
"com.owncloud.api.gateway",
|
||||
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
|
||||
return gatewayClient
|
||||
},
|
||||
)
|
||||
|
||||
cfg := defaults.FullDefaultConfig()
|
||||
cfg.Identity.LDAP.CACert = ""
|
||||
cfg.TokenManager.JWTSecret = "loremipsum"
|
||||
cfg.MaxConcurrency = maxConcurrency
|
||||
|
||||
logger := log.NewLogger()
|
||||
|
||||
return BaseGraphService{
|
||||
logger: &logger,
|
||||
gatewaySelector: gatewaySelector,
|
||||
identityCache: identity.NewIdentityCache(identity.IdentityCacheWithGatewaySelector(gatewaySelector)),
|
||||
config: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
// raceTestShares returns one user share per resource, all distinct resources so
|
||||
// that every share becomes its own unit of work.
|
||||
func raceTestShares() []*collaboration.Share {
|
||||
editorResourcePermissions := conversions.NewEditorRole().CS3ResourcePermissions()
|
||||
|
||||
shares := make([]*collaboration.Share, 0, numRaceTestResources)
|
||||
for i := 0; i < numRaceTestResources; i++ {
|
||||
shares = append(shares, &collaboration.Share{
|
||||
Id: &collaboration.ShareId{OpaqueId: fmt.Sprintf("share-id-%d", i)},
|
||||
ResourceId: &storageprovider.ResourceId{
|
||||
StorageId: "storageid",
|
||||
SpaceId: "spaceid",
|
||||
OpaqueId: fmt.Sprintf("opaqueid-%d", i),
|
||||
},
|
||||
Grantee: &storageprovider.Grantee{
|
||||
Type: storageprovider.GranteeType_GRANTEE_TYPE_USER,
|
||||
Id: &storageprovider.Grantee_UserId{
|
||||
UserId: &userpb.UserId{OpaqueId: "user-id"},
|
||||
},
|
||||
},
|
||||
Permissions: &collaboration.SharePermissions{Permissions: editorResourcePermissions},
|
||||
})
|
||||
}
|
||||
return shares
|
||||
}
|
||||
|
||||
// TestCS3UserSharesToDriveItemsConcurrentMapAccess reproduces OCISDEV-1088: the
|
||||
// errgroup workers read the driveItems map while the collecting loop writes to
|
||||
// it, which makes the Go runtime abort the process with
|
||||
// "fatal error: concurrent map read and map write".
|
||||
//
|
||||
// Run with -race to catch it deterministically.
|
||||
func TestCS3UserSharesToDriveItemsConcurrentMapAccess(t *testing.T) {
|
||||
// A non-empty map is required: the workers only read the map when looking
|
||||
// for an already known drive item, and an empty map read is not enough for
|
||||
// the race detector to flag a conflicting access pattern on every run.
|
||||
driveItems := make(driveItemsByResourceID, numRaceTestResources)
|
||||
for i := 0; i < numRaceTestResources; i++ {
|
||||
driveItems[fmt.Sprintf("storageid$spaceid!seed-%d", i)] = libregraph.DriveItem{}
|
||||
}
|
||||
|
||||
g := newRaceTestService(t, defaults.FullDefaultConfig().MaxConcurrency)
|
||||
|
||||
items, err := g.cs3UserSharesToDriveItems(context.Background(), raceTestShares(), driveItems)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, items, numRaceTestResources+numRaceTestResources)
|
||||
}
|
||||
|
||||
// TestCS3UserSharesToDriveItemsConcurrentMapAccessMaxConcurrencyOne covers the
|
||||
// single worker path.
|
||||
//
|
||||
// This case exists because lowering OCIS_MAX_CONCURRENCY /
|
||||
// GRAPH_MAX_CONCURRENCY to 1 looks like an obvious operational workaround for
|
||||
// OCISDEV-1088, but it never was one: even with a single worker the map was
|
||||
// still read concurrently with the collecting loop, because the results channel
|
||||
// is buffered and the worker never blocks handing off an item. Before the fix
|
||||
// this test failed under -race exactly like the one above.
|
||||
func TestCS3UserSharesToDriveItemsConcurrentMapAccessMaxConcurrencyOne(t *testing.T) {
|
||||
driveItems := make(driveItemsByResourceID, numRaceTestResources)
|
||||
for i := 0; i < numRaceTestResources; i++ {
|
||||
driveItems[fmt.Sprintf("storageid$spaceid!seed-%d", i)] = libregraph.DriveItem{}
|
||||
}
|
||||
|
||||
g := newRaceTestService(t, 1)
|
||||
|
||||
items, err := g.cs3UserSharesToDriveItems(context.Background(), raceTestShares(), driveItems)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, items, numRaceTestResources+numRaceTestResources)
|
||||
}
|
||||
@@ -2,12 +2,9 @@ package svc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -31,7 +28,6 @@ import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
|
||||
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity/ldap"
|
||||
graphmw "github.com/owncloud/ocis/v2/services/graph/pkg/middleware"
|
||||
)
|
||||
|
||||
@@ -451,53 +447,28 @@ func setIdentityBackends(options Options, svc *Graph) error {
|
||||
GatewaySelector: gatewaySelector,
|
||||
}
|
||||
case "ldap":
|
||||
var err error
|
||||
|
||||
var tlsConf *tls.Config
|
||||
if options.Config.Identity.LDAP.Insecure {
|
||||
|
||||
// When insecure is set to true then we don't need a certificate.
|
||||
options.Config.Identity.LDAP.CACert = ""
|
||||
tlsConf = &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
|
||||
//nolint:gosec // We need the ability to run with "insecure" (dev/testing)
|
||||
InsecureSkipVerify: options.Config.Identity.LDAP.Insecure,
|
||||
}
|
||||
}
|
||||
|
||||
if options.Config.Identity.LDAP.CACert != "" {
|
||||
if err := ocisldap.WaitForCA(options.Logger,
|
||||
options.Config.Identity.LDAP.Insecure,
|
||||
options.Config.Identity.LDAP.CACert); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("The configured LDAP CA cert does not exist")
|
||||
}
|
||||
if tlsConf == nil {
|
||||
tlsConf = &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
}
|
||||
}
|
||||
certs := x509.NewCertPool()
|
||||
pemData, err := os.ReadFile(options.Config.Identity.LDAP.CACert)
|
||||
if err != nil {
|
||||
options.Logger.Error().Err(err).Msg("Error initializing LDAP Backend")
|
||||
return err
|
||||
}
|
||||
if !certs.AppendCertsFromPEM(pemData) {
|
||||
options.Logger.Error().Msg("Error initializing LDAP Backend. Adding CA cert failed")
|
||||
return err
|
||||
}
|
||||
tlsConf.RootCAs = certs
|
||||
}
|
||||
|
||||
conn := ldap.NewLDAPWithReconnect(&options.Logger,
|
||||
ldap.Config{
|
||||
URI: options.Config.Identity.LDAP.URI,
|
||||
BindDN: options.Config.Identity.LDAP.BindDN,
|
||||
BindPassword: options.Config.Identity.LDAP.BindPassword,
|
||||
TLSConfig: tlsConf,
|
||||
},
|
||||
)
|
||||
conn, err := utils.GetLDAPClientFromConfig(&utils.LDAPConn{
|
||||
URI: options.Config.Identity.LDAP.URI,
|
||||
Insecure: options.Config.Identity.LDAP.Insecure,
|
||||
CACert: options.Config.Identity.LDAP.CACert,
|
||||
BindDN: options.Config.Identity.LDAP.BindDN,
|
||||
BindPassword: options.Config.Identity.LDAP.BindPassword,
|
||||
PoolEnabled: options.Config.Identity.LDAP.PoolEnabled,
|
||||
PoolSize: options.Config.Identity.LDAP.PoolSize,
|
||||
PoolCheckoutTimeout: options.Config.Identity.LDAP.PoolCheckoutTimeout,
|
||||
})
|
||||
if err != nil {
|
||||
options.Logger.Error().Err(err).Msg("Error initializing LDAP Backend")
|
||||
return err
|
||||
}
|
||||
var iid, masterID string
|
||||
if options.Config.MultiInstance.Enabled {
|
||||
iid = options.Config.MultiInstance.InstanceID
|
||||
|
||||
Loaded 100 of 283 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user