Compare commits

...
Author SHA1 Message Date
Firas Frikha a4007e280b chore: point reva at the OCISDEV-1477 review fixes for load tests 2026-10-06 15:08:05 +02:00
Firas Frikha 31e1c9ee74 chore: point reva at OCISDEV-1477 on the switchover for load tests 2026-10-01 17:52:15 +02:00
Firas Frikha c236c124fc chore(OCISDEV-900): bump reva to rebased pr7-switchover 2026-10-01 10:22:39 +02:00
lars.jurgensen 0197ab199d chore(OCISDEV-900): bump reva to pr7-switchover, add upload_directory and mount_id to revaconfig
- bump github.com/owncloud/reva/v2 to 4717d97b0e (OCISDEV-900-pr7-switchover)
- set upload_directory in OCM dataprovider and storageprovider revaconfig
- add mount_id to storage-users dataprovider revaconfig
2026-10-01 10:22:32 +02:00
Matteo 3fe6545ffd fix(web): [OCISDEV-1474] keep focus on trigger when dropdown closes (#13025)
* fix(web): [OCISDEV-1474] keep focus on trigger when dropdown closes

Dropdowns that close on item click removed the clicked item from the
DOM, dropping keyboard focus to the page body and causing screen
readers to re-announce the whole page over any status message the
action triggered. OcDrop now restores focus to its trigger on close,
unless the action already moved focus elsewhere itself.

* fix(web): [OCISDEV-1474] hide trigger tooltip when refocused on close

Restoring focus to the trigger button popped its own tooltip back
open, since tippy's default trigger includes focus. The tooltip then
sat on top of the button and blocked the next click, breaking the
share e2e test. Hide the tooltip right after refocusing.
2026-10-01 09:15:57 +02:00
Matteo 9f147b8329 fix(web): [OCISDEV-1473] announce status messages to screen readers (#13024)
Toast/status messages (e.g. clipboard copy, file restore) were often
dropped by screen readers because the live region was never cleared
between messages. Clear it before each message and refill after a
short delay so announcements survive focus changes. Toasts themselves
are no longer live regions, since a freshly inserted aria-live node
isn't reliably announced.
2026-10-01 09:15:36 +02:00
Gaurav Soni 3d2dc1a7de fix(graph): [OCISDEV-1466] speed up user search when sharing from the vault (#13023)
Searching for share recipients in the vault ("Safe") could take minutes,
because each search scanned the role assignments of every account in the
system. Vault eligibility is now checked only for the users the search
matched, a few at a time in parallel, so the search is about as fast as
outside the vault.
2026-10-01 09:12:54 +02:00
Prajwol Amatya 52891efd4e [tests-only][full-ci] test: add test for public link brute-force protection (#13008)
test: add test for public link brute-force protection

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-10-01 11:03:09 +05:45
isha dbf40a3dcd [tests-only][full-ci][k8s] test(ci): run e2e test against k8s deployment (#13006)
ci: run e2e test against k8s deployment
2026-10-01 10:44:41 +05:45
isha aa047423f9 [full-ci][tests-only][k8s] fix: k8s-only failure in LDAP posixGroup share invitation test (#13029)
fix: k8s-only failure in LDAP posixGroup share invitation test
2026-09-30 15:22:41 +05:45
Matteo ed40259ebf bump brace-expansion version to 5.0.11 (#13026)
chore: bump brace-expansion version to 5.0.11
2026-09-30 08:11:25 +00:00
isha 2f1946e117 fix: provide accessible name for OcButton spinner (#13018)
* fix: hide spinner from a11y tree in OcButton

* docs: add changelog
2026-09-30 10:04:28 +05:45
dependabot[bot] 60b5b9eca0 build(deps): bump actions/checkout from 6.0.2 to 7.0.1 (#13014)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.2 to 7.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6.0.2...3d3c42e5aac5ba805825da76410c181273ba90b1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-29 20:49:34 +02:00
dependabot[bot] 4daf1331f8 build(deps): bump actions/setup-go from 6.3.0 to 7.0.0 (#13016)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 6.3.0 to 7.0.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v6.3.0...b7ad1dad31e06c5925ef5d2fc7ad053ef454303e)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-29 15:16:45 +02:00
dependabot[bot] 87acc90e4d build(deps): bump actions/setup-node from 6.3.0 to 7.0.0 (#13015)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.3.0 to 7.0.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6.3.0...820762786026740c76f36085b0efc47a31fe5020)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-29 14:33:13 +02:00
Matteo 738b15268d pump fast-uri version (#13021)
chore: pump fast-uri version
2026-09-29 15:08:30 +05:45
Michal Klos dc33f20fee feat: [OCISDEV-1411] don't logout users on a transient IdP userinfo failure (#12999)
* test: [OCISDEV-1411] regression test for userinfo-timeout 401

* fix: [OCISDEV-1411] don't logout users on a transient IdP userinfo failure

* fix: [OCISDEV-1411] don't logout users on a transient IdP userinfo failure

* feat: review

* feat: review

* feat: review
2026-09-29 09:37:48 +02:00
Gaurav Soni 6c278bf2ee fix: OCISDEV-1438 hide Shared via link tab when public sharing is disabled (#13005)
The Shares navigation (desktop tab list and mobile drop-down) always offered a
"Shared via link" entry, even when public link sharing was disabled for the account —
for example in the Vault, where the backend rejects public link creation and the
capability `files_sharing.public.enabled` reports `false`. The entry led to a page
that could never contain anything.

The Shares navigation now hides the "Shared via link" entry whenever
`files_sharing.public.enabled` is `false`. Anyone who still reaches the via-link
route directly, including through the legacy `/list/shared-via-link` redirect, is
redirected to "Shared with me" at navigation time, keeping the current route scope
(e.g. `vault`) intact. When public sharing is enabled, all three entries behave as before.

PR: https://github.com/owncloud/ocis/pull/13005
2026-09-28 16:01:15 +02:00
Juan Pablo Villafañez 9e984d5ef3 [OCISDEV-1407] Homogenize defaults (#12982)
* fix: use "ownCloudUUID" as attribute name everywhere

* fix: use "displayName" as LDAP attribute

* fix: ensure the WopiFolderURLBaseURL always ends with "/"

* fix: restore wrong substitution

* Revert "fix: use "displayName" as LDAP attribute"

This reverts commit 02de7a2db7.

Note that the default values outside of the graph service still remains
2026-09-28 13:27:05 +02:00
Prajwol Amatya 018df1c0f5 [tests-only][full-ci] test: add test to check access to shared space for ldap group member (#12990)
test: add test to check access to shared space for ldap group member

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-09-25 12:43:20 +05:45
Matteo 6292da31c9 fix(web): [OCISDEV-1462] add keyboard shortcut to move focus out of the text editor (#13004)
Tab is bound to indenting in the text editor rather than moving focus,
and the editor's own built-in escape hatch for this (Ctrl-M / Shift-Alt-M
on Mac) doesn't work on a standard Mac keyboard layout, since Option+Shift+M
is consumed by macOS as a diacritic combo before it reaches the page.

Added a Ctrl+M handler, identical on every platform, that moves focus
to the first enabled toolbar button, intercepted ahead of the editor's
own listener. The edit area's accessible description now announces
this shortcut for assistive technology users.
2026-09-24 16:41:58 +02:00
Gaurav Soni 69b4423300 fix: [OCISDEV-1435] resolve vault permanent links opened outside the vault (#13001) 2026-09-24 15:27:57 +02:00
Matteo 015c67e9e6 fix: announce unread count on the notification bell (#13003)
The notification bell's accessible name was a static "Notifications"
string regardless of the unread count, so screen reader users never
heard the count shown visually on the badge.

The accessible name (and tooltip) now include the exact unread count,
with correct singular/plural wording.

OCISDEV-1461
2026-09-24 15:09:53 +02:00
Matteo a0fd651d67 fix: focus notification dropdown on open so arrow keys work immediately (#13002)
Arrow-key navigation in the notification bell's dropdown only started
working after an extra Tab press once it was open. Pressing an arrow
key too early fell through to the browser's default scroll action,
which looked like the dropdown had closed.

Added focus-on-open to the dropdown, matching other click-triggered
dropdowns in the codebase, so focus moves to the first item as soon
as it opens.
2026-09-24 14:54:33 +02:00
Matteo dd7c7fce58 fix: improve contrast on notification bell badge (#13000) 2026-09-24 12:32:35 +02:00
Matteo d8983b8163 fix: improve contrast on disabled empty trash bin button (#12998) 2026-09-24 12:24:25 +02:00
Michal Klos 83cc6fc95e fix: [OCISDEV-55] never combine wildcard CORS origin with credentials (#12983) 2026-09-24 09:42:15 +00:00
isha 146f08513c [tests-only][full-ci][k8s] test: run apiSearchContent on k8s deployment (#12959)
test: disable redundant k8s 5xx retries for search requests
2026-09-24 15:08:15 +05:45
Matteo 21dd288ac4 fix: improve contrast on file name/extension in editor topbar (#12997)
* fix: improve contrast on file name/extension in editor topbar

The file name and extension shown in the topbar when a file is open
were rendered in white on top of a light brand-colored background in
the vault Light Theme, and fell back to the same failing combination
in the vault Dark Theme - High Contrast (where the color was left
unset). Both now use a dark color that reads correctly against that
background.
2026-09-24 11:00:51 +02:00
Matteo cdad61175d fix: improve contrast on share role dropdown hover text (#12995)
* fix: improve contrast on share role dropdown hover text

The share permission dropdown's role options (e.g. "Can view",
"Can edit") rendered their hovered text in a color too close in
lightness to the hover background in the vault Dark Theme,
producing insufficient contrast. Lightened the color slightly to
restore adequate contrast without affecting its other uses.
2026-09-24 09:57:38 +02:00
Pradip Subedi 951f45f54e [tests-only][full-ci][k8s] test: enable coreApiWebdavPreviews in k8s (#12991)
test: enable coreApiWebdavPreviews in k8s
2026-09-24 13:00:00 +05:45
Prajwol Amatya 44a46faae0 [tests-only][full-ci] test: non-admin user get the detail of group along with group members (#12981)
test: non-admin user get the detail of group

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-09-24 12:15:08 +05:45
Matteo 5701e03c52 fix: improve contrast on dropdown menu item hover text (#12994)
* fix: improve contrast on dropdown menu item hover text

Dropdown menu items (e.g. the "New" file/folder menu) rendered their
hovered text in the brand-hover color, which is designed to work as
a background color, not as text on top of the generic hover
background. This produced poor contrast in some themes. The hover
text now uses the same passive-default color already used at rest,
which is verified to read well against the hover background in
every theme.
2026-09-24 08:01:34 +02:00
Ashim Shrestha 12ff0e1fcf [tests-only][full-ci][k8s] test: run apiCollaboration test suite on k8s deployment (#12939)
test: run apiCollaboration test suite on k8s deployment

Signed-off-by: Ashim Shrestha <ashimshrestha2384@gmail.com>
2026-09-24 11:43:52 +05:45
Matteo 09717f094f fix: improve contrast on nav item and primary button hover states (#12993)
* fix: improve contrast on nav item and primary button hover states

Non-active sidebar navigation items and primary-variation buttons
(filled and outline appearances) rendered black text/icons on top of
a dark brown hover background in the vault theme, producing
insufficient contrast. Both now use the text-inverse color for their
hover state instead of the primary-contrast token, which resolves
correctly across all themes.

OCISDEV-1451

* docs: add changelog for nav/primary button hover contrast fix

* docs: link changelog entry to PR #12993
2026-09-24 07:04:51 +02:00
Matteo cb7fc967a9 fix: improve contrast on disabled danger buttons (#12992)
* fix: improve low contrast on disabled danger buttons

Disabled danger-filled buttons had insufficient contrast between their
label text and background, caused by a disabled-state opacity fade
fighting against the muted background color. Danger buttons now keep
full opacity when disabled and use a darker muted background.
2026-09-23 17:23:28 +02:00
Kavita gautam deaf4b6389 [tests-only][full-ci][k8s] test: Run apiSpace test suite on k8s deployment (#12975)
test: run apiSpace on k8s deployment

Signed-off-by: Kavita Gautam <kavita@jankaritech.com>
2026-09-23 17:52:55 +05:45
owncloud-translations-bot[bot] 51eb6039b1 chore: update translations from transifex (#12979)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-09-22 15:47:33 +02:00
Pradip Subedi 02c3df5503 fix: text file previews on libvips without imagemagick support (#12961)
* fix: text file previews on libvips without imagemagick support

* fix: bmp previews on magick-less libvips, vips-tagged tests in CI
2026-09-22 10:30:49 +02:00
434 changed files with 44703 additions and 9012 deletions

No files matched your search

+26 -23
View File
@@ -12,7 +12,7 @@ jobs:
outputs:
docs-only: ${{ steps.check.outputs.docs-only }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
@@ -56,13 +56,13 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
@@ -141,7 +141,9 @@ jobs:
make ci-golangci-lint > /tmp/golangci-lint.log 2>&1 & PIDS=($!)
( ENABLE_VIPS=true make -C ocis build-debug \
&& mv ocis/bin/ocis-debug ocis/bin/ocis ) > /tmp/ocis-build.log 2>&1 & PIDS+=($!)
make test > /tmp/unit-tests.log 2>&1 & PIDS+=($!)
make test > /tmp/unit-tests.log 2>&1 & PIDS+=($!)
# vips-tagged files live only under thumbnails; scoped run, no coverprofile.
go test -v -tags 'enable_vips' ./services/thumbnails/... > /tmp/unit-tests-vips.log 2>&1 & PIDS+=($!)
GOWORK=off make -C tests/ociswrapper build > /tmp/ociswrapper-build.log 2>&1 & PIDS+=($!)
FAILED=0
@@ -158,6 +160,7 @@ jobs:
echo "=== ocis build ===" && cat /tmp/ocis-build.log
echo "=== ociswrapper build ===" && cat /tmp/ociswrapper-build.log
echo "=== unit tests ===" && cat /tmp/unit-tests.log
echo "=== vips unit tests ===" && cat /tmp/unit-tests-vips.log
exit $FAILED
@@ -226,7 +229,7 @@ jobs:
- apiCollaboration
- apiVault
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
@@ -310,7 +313,7 @@ jobs:
suite:
- cliCommands,apiServiceAvailability # grouped: both need ClamAV + email services
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
@@ -358,7 +361,7 @@ jobs:
suite:
- apiGraphUser,apiGraph,apiGraphGroup
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
@@ -414,7 +417,7 @@ jobs:
- "coreApiWebdavProperties"
- "coreApiWebdavMove1,coreApiWebdavPreviews,coreApiWebdavUpload,coreApiWebdavUploadTUS"
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
@@ -530,8 +533,8 @@ jobs:
args: "--type playwright --suites vault-storage"
vault_storage: true
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
# 24.16.0 breaks playwright install (yauzl zip extraction hangs); pin to last known good.
# https://github.com/microsoft/playwright/issues/40724
@@ -700,7 +703,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install libvips runtime
run: |
@@ -725,7 +728,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install libvips runtime
run: |
@@ -750,7 +753,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install libvips runtime
run: |
@@ -775,7 +778,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install libvips runtime
run: |
@@ -800,13 +803,13 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
@@ -833,13 +836,13 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
@@ -866,8 +869,8 @@ jobs:
env:
GOCOVERDIR: ${{ github.workspace }}/coverage-reports
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install REUSE tool
run: pip install reuse
+1 -1
View File
@@ -34,7 +34,7 @@ jobs:
steps:
- name: Checkout ocis repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: owncloud/ocis
+253 -17
View File
@@ -10,7 +10,10 @@ env:
PHP_VERSION: "8.4"
K3D_VERSION: "v5.8.3"
HELM_VERSION: "v3.18.4"
TEST_SERVER_DOMAIN: ocis-server
FED_SERVER_DOMAIN: federation-ocis-server
TEST_SERVER_URL: https://ocis-server
FED_SERVER_URL: https://federation-ocis-server
STORAGE_DRIVER: ocis
OCIS_WRAPPER_URL: http://localhost:5200
K8S: true
@@ -39,7 +42,7 @@ jobs:
- suite: apiGraphUser
- suite: apiGraph
- suite: apiGraphGroup
# - suite: apiSpaces
- suite: apiSpaces
- suite: apiSpacesShares
- suite: apiSpacesDavOperation
- suite: apiDownloads
@@ -49,7 +52,7 @@ jobs:
- suite: apiActivities
- suite: apiSearch1
- suite: apiSearch2
# - suite: apiSearchContent
- suite: apiSearchContent
- suite: apiSharingNgShares
- suite: apiReshare
- suite: apiSharingNgPermissions
@@ -62,7 +65,7 @@ jobs:
- suite: apiAuthApp
- suite: apiAntivirus
- suite: apiOcm
# - suite: apiCollaboration
- suite: apiCollaboration
- suite: apiVault
- suite: "coreApiAuth,coreApiCapabilities,coreApiFavorites,coreApiMain,coreApiVersions"
- suite: "coreApiShareManagementBasicToShares,coreApiShareManagementToShares"
@@ -72,12 +75,11 @@ jobs:
- suite: "coreApiTrashbin,coreApiTrashbinRestore,coreApiWebdavEtagPropagation1,coreApiWebdavEtagPropagation2"
- suite: "coreApiWebdavDelete,coreApiWebdavOperations,coreApiWebdavMove2"
- suite: "coreApiWebdavProperties"
# - suite: "coreApiWebdavPreviews"
- suite: "coreApiWebdavMove1,coreApiWebdavUpload,coreApiWebdavUploadTUS"
- suite: "coreApiWebdavMove1,coreApiWebdavUpload,coreApiWebdavUploadTUS,coreApiWebdavPreviews"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup PHP ${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
@@ -105,7 +107,7 @@ jobs:
- name: Prepare hosts
run: |
echo "127.0.0.1 ocis-server clamav email collabora onlyoffice fakeoffice tika federation-ocis-server keycloak" \
echo "127.0.0.1 $TEST_SERVER_DOMAIN clamav email collabora onlyoffice fakeoffice tika $FED_SERVER_DOMAIN keycloak" \
| sudo tee -a /etc/hosts
- name: Spin up K3d Cluster
@@ -181,11 +183,11 @@ jobs:
# patch the realm so the "web" client's redirect/origin URLs match
# the k8s ingress domain instead of the non-k8s "localhost:9200" one
sed 's|https://localhost:9200|https://ocis-server|g' \
sed "s|https://localhost:9200|${TEST_SERVER_URL}|g" \
tests/config/ci/ocis-mfa-ci-realm.dist.json > /tmp/ocis-realm.json
docker run -d --name keycloak --network host \
-e OCIS_DOMAIN=https://ocis-server \
-e OCIS_DOMAIN="$TEST_SERVER_URL" \
-e KC_HOSTNAME=keycloak \
-e KC_PORT=8443 \
-e KC_DB=postgres \
@@ -213,34 +215,99 @@ jobs:
bash tests/config/k8s/expose-external-svc.sh keycloak:8443
fi
if [[ "${{ matrix.suite }}" == "apiCollaboration" ]]; then
# Start Collabora
docker run -d \
--name collabora \
--network host \
--entrypoint bash \
-e DONT_GEN_SSL_CERT=set \
-e "extra_params=--o:ssl.enable=true --o:ssl.termination=true --o:welcome.enable=false --o:net.frame_ancestors=https://127.0.0.1:9200" \
collabora/code:25.04.7.3.1 \
-c "coolconfig generate-proof-key && bash /start-collabora-online.sh"
timeout 150 bash -c 'until curl -kfsSL https://localhost:9980/hosting/discovery > /dev/null; do sleep 5; done'
echo "collabora ready."
# Start OnlyOffice
docker run -d \
--name onlyoffice \
-p 7443:443 \
-e WOPI_ENABLED=true \
-e USE_UNAUTHORIZED_STORAGE=true \
-v "$(pwd)/tests/config/ci/only-office.json:/tmp/local.json:ro" \
--entrypoint /bin/sh \
onlyoffice/documentserver:9.2.1 \
-c "set -e
cp /tmp/local.json /etc/onlyoffice/documentserver/local.json
openssl req -x509 -newkey rsa:4096 -keyout onlyoffice.key -out onlyoffice.crt -sha256 -days 365 -batch -nodes
mkdir -p /var/www/onlyoffice/Data/certs
cp onlyoffice.key /var/www/onlyoffice/Data/certs/
cp onlyoffice.crt /var/www/onlyoffice/Data/certs/
chmod 400 /var/www/onlyoffice/Data/certs/onlyoffice.key
/app/ds/run-document-server.sh"
timeout 150 bash -c 'until curl -kfsSL https://localhost:7443/hosting/discovery > /dev/null; do sleep 5; done'
echo "onlyoffice ready."
#Start FakeOffice
docker run -d --name fakeoffice --network host \
-v "$(pwd):/ocis:ro" \
python:3-alpine \
python3 -c "
import http.server, pathlib
body = pathlib.Path('/ocis/tests/config/ci/hosting-discovery.xml').read_bytes()
class H(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/xml')
self.end_headers()
self.wfile.write(body)
def log_message(self, *a): pass
http.server.HTTPServer(('', 8080), H).serve_forever()
"
timeout 60 bash -c 'until curl -fsSL http://localhost:8080/hosting/discovery > /dev/null; do sleep 5; done'
echo "fakeoffice ready."
bash tests/config/k8s/expose-external-svc.sh collabora:9980
bash tests/config/k8s/expose-external-svc.sh onlyoffice:7443
bash tests/config/k8s/expose-external-svc.sh fakeoffice:8080
fi
- name: Deploy oCIS
run: |
cd tests/config/k8s
kubectl get pods -n ocis-server -Aw &
kubectl get pods -n "$TEST_SERVER_DOMAIN" -Aw &
make deploy-ocis
if [[ "${{ matrix.suite }}" == "apiOcm" ]]; then
OCM=true make deploy-ocis
fi
- name: Expose node ports
if: ${{ matrix.suite == 'apiCollaboration' }}
run: |
bash tests/config/k8s/expose-nodeports.sh collaboration-collabora 9300 30300
bash tests/config/k8s/expose-nodeports.sh collaboration-fakeoffice 9300 30301
bash tests/config/k8s/expose-nodeports.sh collaboration-onlyoffice 9300 30302
bash tests/config/k8s/expose-nodeports.sh collaboration-fakeoffice 9304 30304
- name: Wait for oCIS to be ready
env:
FILE_URL: ${{ env.TEST_SERVER_URL }}/remote.php/dav/files/admin/hello1.txt
run: |
kubectl wait \
--namespace ocis-server \
--namespace "$TEST_SERVER_DOMAIN" \
--for=condition=Available \
deployment \
--all \
--timeout=10m
kubectl wait \
--namespace ocis-server \
--namespace "$TEST_SERVER_DOMAIN" \
--for=condition=Ready \
pod \
--all \
--timeout=10m
kubectl get pods -n ocis-server
kubectl get pods -n "$TEST_SERVER_DOMAIN"
retry() {
local label=$1
@@ -264,7 +331,7 @@ jobs:
# reached via port-forward since it isn't exposed by any Service.
# local port 19205 (not 9205): 9100-9399 is already bound on the
# host by the k3d loadbalancer's NodePort range, see create-cluster.
kubectl -n ocis-server port-forward deployment/proxy 19205:9205 &
kubectl -n "$TEST_SERVER_DOMAIN" port-forward deployment/proxy 19205:9205 &
PORT_FORWARD_PID=$!
trap 'kill $PORT_FORWARD_PID 2>/dev/null' EXIT
@@ -316,7 +383,7 @@ jobs:
run: |
(
while true; do
kubectl -n ocis-server port-forward deployment/proxy 19205:9205 >> /tmp/proxy-readyz-portforward.log 2>&1
kubectl -n "$TEST_SERVER_DOMAIN" port-forward deployment/proxy 19205:9205 >> /tmp/proxy-readyz-portforward.log 2>&1
sleep 1
done
) &
@@ -331,7 +398,7 @@ jobs:
--admin-username admin \
--admin-password admin \
--skip-ocis-run \
-n ocis-server &
-n "$TEST_SERVER_DOMAIN" &
- name: Prepare expected failures
if: startsWith( matrix.suite, 'core' )
@@ -348,7 +415,7 @@ jobs:
if: startsWith( matrix.suite, 'api' )
env:
TEST_SERVER_URL: ${{ env.TEST_SERVER_URL }}
TEST_SERVER_FED_URL: https://federation-ocis-server
TEST_SERVER_FED_URL: ${{ env.FED_SERVER_URL }}
STORAGE_DRIVER: ${{ env.STORAGE_DRIVER }}
BEHAT_SUITES: ${{ matrix.suite }}
BEHAT_FILTER_TAGS: "~@skip&&~@skipOnGraph&&~@skipOnOcis-OCIS-Storage"
@@ -376,3 +443,172 @@ jobs:
WITH_REMOTE_PHP: "false"
K8S: ${{ env.K8S }}
run: make test-acceptance-api
e2e-tests:
name: e2e-${{ matrix.suite }}-k8s
runs-on: ubuntu-latest
timeout-minutes: 60
if: >-
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
contains(github.event.pull_request.title || '', 'k8s'))
strategy:
fail-fast: false
matrix:
include:
- suite: smoke
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
# 24.16.0 breaks playwright install (yauzl zip extraction hangs); pin to last known good.
# https://github.com/microsoft/playwright/issues/40724
node-version: "24.15.0"
- name: Enable pnpm
run: |
corepack enable && corepack prepare pnpm@10.33.3 --activate
pnpm config set store-dir ./.pnpm-store
- name: Cache Playwright Chromium
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/ms-playwright
key: playwright-chromium-${{ hashFiles('web/pnpm-lock.yaml') }}
- name: Download k3d
run: |
curl -L \
-o k3d \
https://github.com/k3d-io/k3d/releases/download/${{ env.K3D_VERSION }}/k3d-linux-amd64
echo "dbaa79a76ace7f4ca230a1ff41dc7d8a5036a8ad0309e9c54f9bf3836dbe853e k3d" | sha256sum --check
chmod +x k3d
sudo mv k3d /usr/local/bin/
k3d version
- name: Install Helm
run: |
curl -fsSL -o helm-${{ env.HELM_VERSION }}-linux-amd64.tar.gz https://get.helm.sh/helm-${{ env.HELM_VERSION }}-linux-amd64.tar.gz
tar -zxvf helm-${{ env.HELM_VERSION }}-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
helm version --short
- name: Prepare hosts
run: |
echo "127.0.0.1 $TEST_SERVER_DOMAIN clamav email collabora onlyoffice fakeoffice tika $FED_SERVER_DOMAIN keycloak" \
| sudo tee -a /etc/hosts
- name: Spin up K3d Cluster
run: make -C tests/config/k8s create-cluster
- name: Prepare Helm Charts
run: make -C tests/config/k8s prepare-charts
- name: Deploy oCIS
run: |
cd tests/config/k8s
kubectl get pods -n "$TEST_SERVER_DOMAIN" -Aw &
make deploy-ocis
- name: Wait for oCIS to be ready
env:
FILE_URL: ${{ env.TEST_SERVER_URL }}/remote.php/dav/files/admin/hello1.txt
run: |
kubectl wait \
--namespace "$TEST_SERVER_DOMAIN" \
--for=condition=Available \
deployment \
--all \
--timeout=10m
kubectl wait \
--namespace "$TEST_SERVER_DOMAIN" \
--for=condition=Ready \
pod \
--all \
--timeout=10m
kubectl get pods -n "$TEST_SERVER_DOMAIN"
retry() {
local label=$1
shift
for i in {1..30}; do
if "$@"; then
echo "$label succeeded"
return 0
fi
echo "$label attempt $i failed, retrying in 10s..."
sleep 10
done
echo "$label failed after 30 attempts"
return 1
}
echo "Creating test file in oCIS..."
request() {
local method=$1
shift
curl -ks -o /dev/null -w "%{http_code}" \
-X "$method" \
-u admin:admin \
"$@" \
"$FILE_URL"
}
put_file() {
request PUT \
-H "Content-Type: text/plain" \
--data "Hello from GitHub Actions!"
}
delete_file() {
request DELETE
}
check_status() {
local expected=$1
shift
status=$("$@")
[ "$status" = "$expected" ]
}
echo "Creating test file..."
retry "create file (HTTP 201)" check_status 201 put_file || exit 1
echo "Deleting test file..."
retry "delete file (HTTP 204)" check_status 204 delete_file || exit 1
- name: Run e2e ${{ matrix.suite }} tests
env:
E2E_ARGS: "--suites ${{ matrix.suite }}"
K8S: ${{ env.K8S }}
TEST_SERVER_URL: ${{ env.TEST_SERVER_URL }}
run: python3 tests/acceptance/run-e2e.py
- name: Upload Playwright traces
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-traces-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
path: web/reports/e2e
retention-days: 7
- name: Upload a11y result
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-a11y-result-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
path: web/reports/e2e/a11y-report.json
retention-days: 7
- name: Upload oCIS logs
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ocis-logs-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
path: tests/config/k8s/logs
retention-days: 7
+2 -2
View File
@@ -26,10 +26,10 @@ jobs:
working-directory: web
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24.15.0
registry-url: "https://registry.npmjs.org"
+17 -17
View File
@@ -30,7 +30,7 @@ jobs:
is_prerelease: ${{ steps.info.outputs.is_prerelease }}
docker_repos: ${{ steps.info.outputs.docker_repos }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: ${{ github.ref_type == 'branch' || (github.event_name == 'workflow_dispatch' && inputs.version_override == '') }}
with:
fetch-depth: 0
@@ -97,11 +97,11 @@ jobs:
timeout-minutes: 60
needs: [determine-release-type]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
- run: npm install --silent -g yarn npx --force
@@ -138,7 +138,7 @@ jobs:
arch: [amd64, arm64]
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: generated-code
@@ -149,7 +149,7 @@ jobs:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: goversion
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- run: |
@@ -214,7 +214,7 @@ jobs:
arch: [amd64]
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
id: trivy
continue-on-error: true
@@ -272,7 +272,7 @@ jobs:
matrix:
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
@@ -289,12 +289,12 @@ jobs:
matrix:
os: [linux, darwin]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: generated-code
path: .
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- run: |
@@ -313,7 +313,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
@@ -327,15 +327,15 @@ jobs:
timeout-minutes: 60
needs: [determine-release-type, generate-code]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: generated-code
path: .
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- run: npm install --silent -g yarn npx "pnpm@$PNPM_VERSION" --force
@@ -357,10 +357,10 @@ jobs:
timeout-minutes: 15
needs: [determine-release-type]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- run: |
@@ -417,7 +417,7 @@ jobs:
- generate-changelog
- create-github-release
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: binaries-linux
+3 -3
View File
@@ -14,7 +14,7 @@ jobs:
web-changed: ${{ steps.check.outputs.web-changed }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
@@ -57,7 +57,7 @@ jobs:
working-directory: web
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
@@ -65,7 +65,7 @@ jobs:
version: 10.33.3
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24.15.0
cache: pnpm
+1 -1
View File
@@ -19,7 +19,7 @@ jobs:
container: golang:1.25-alpine
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Run CI Reporter
working-directory: tools/ci-reporter
+11
View File
@@ -181,6 +181,17 @@ go-mod-tidy:
$(MAKE) --no-print-directory -C $$mod go-mod-tidy || exit 1; \
done
# Opt in to vips-tagged sources: `ENABLE_VIPS=true
# make test` compiles files behind `//go:build enable_vips` (e.g. thumbnails).
TAGS ?=
ifdef ENABLE_VIPS
ifeq ($(strip $(TAGS)),)
TAGS := enable_vips
else
TAGS := $(TAGS),enable_vips
endif
endif
.PHONY: test
test:
@go test -v -tags '$(TAGS)' -coverprofile coverage.out ./...
@@ -0,0 +1,12 @@
Bugfix: Announce status messages to screen readers
Status messages such as "copied to clipboard" or "file restored successfully"
were not reliably read out by screen readers. The underlying announcement
area was never cleared between messages, so a repeated or rapid message
could be silently dropped, especially when combined with a focus change
elsewhere on the page.
The announcement area is now cleared before each new message and refilled
after a short delay, so status messages are announced consistently.
https://github.com/owncloud/ocis/pull/13024
@@ -0,0 +1,13 @@
Bugfix: fixed missing accessible name on button loading spinner
`OcButton`'s loading spinner is a `role="img"` element, but it had no
accessible name. This tripped an axe `role-img-alt` violation on any
page whose e2e a11y check ran while a button was in its loading state,
such as the public link password page's "Continue" button.
The spinner now gets a real accessible name ("Loading") via
`OcSpinner`'s `ariaLabel` prop, marked `aria-live="polite"` so it is
actively announced to screen reader users instead of only being
described if focus happens to already be on the button.
https://github.com/owncloud/ocis/pull/13018
@@ -0,0 +1,11 @@
Bugfix: Do not allow credentials for wildcard CORS origins
CORS responses no longer send `Access-Control-Allow-Credentials: true` when the
configured origins permit any origin: an empty list, `*`, or a wildcard pattern
such as `https://*`. In those cases credentials are dropped and a warning is
logged. This applies across all CORS paths (the shared HTTP middleware, the reva
interceptor used by the frontend and ocm services, ocdav, and the tus upload
handler). Explicitly configured origins are unaffected and keep credentials, so
intended cross-origin setups continue to work.
https://github.com/owncloud/ocis/pull/12983
@@ -0,0 +1,12 @@
Bugfix: fixed low color contrast on disabled danger buttons
Disabled buttons using the "danger" styling, such as the "Empty trash bin"
button when there is nothing to delete, showed their label text with very
low contrast against the button background, making the text hard to read.
The muted background color used for these buttons in a disabled state has
been darkened, and the fading effect applied to disabled buttons no longer
washes out the danger button background, restoring readable contrast
between the label and the background.
https://github.com/owncloud/ocis/pull/12992
@@ -0,0 +1,11 @@
Bugfix: Keep keyboard focus on the trigger when a dropdown closes
Dropdown and context menus that close on item click (e.g. the per-file "..."
menu) removed the clicked item from the page as they closed, so keyboard
focus fell back to the page body. Screen readers then re-announced the
whole page, drowning out any status message the action had just triggered.
The dropdown now returns focus to the button that opened it when it closes,
unless the clicked action already moved focus somewhere else on its own.
https://github.com/owncloud/ocis/pull/13025
@@ -0,0 +1,12 @@
Bugfix: fixed low color contrast on dropdown menu item hover text
Items in dropdown menus, such as the "New" file/folder menu, changed
their text to a color meant for use as a background rather than as
text when hovered. On top of the generic hover background used
across the app, this produced poor contrast in some themes.
Hovered menu items now keep the same text color already used before
hovering, which reads correctly against the hover background in
every theme.
https://github.com/owncloud/ocis/pull/12994
@@ -0,0 +1,11 @@
Bugfix: fixed low color contrast on file name in editor topbar
The file name and extension shown in the topbar when a file is open,
for example in an editor, were displayed in white on top of a light
brand-colored background in some theme variants, making the text
hard to read.
The text now uses a dark color instead, restoring readable contrast
against that background.
https://github.com/owncloud/ocis/pull/12997
@@ -0,0 +1,12 @@
Bugfix: fixed low color contrast on disabled danger button text
Disabled filled danger buttons, such as the "Empty trash bin" button
in the deleted files view, displayed their text and icon in a color
too close to the background fill, making them hard to read.
The disabled text and icon color is now forced to white, restoring
readable contrast against the button's background. The vault light
theme's muted danger color was also darkened, since it was too light
to meet contrast requirements against white text.
https://github.com/owncloud/ocis/pull/12998
@@ -0,0 +1,12 @@
Bugfix: fixed low color contrast on nav and primary button hover states
Non-active sidebar navigation items, as well as buttons using the
"primary" styling, showed their text and icons in black on top of a
dark hover background in some themes, making them hard to read while
hovering.
The hover state for these elements now switches to a light color
instead of always using black, restoring readable contrast between
the text and the background while hovering.
https://github.com/owncloud/ocis/pull/12993
@@ -0,0 +1,11 @@
Bugfix: fixed low color contrast on notification bell badge
The unread notification count badge on the notification bell used a
hardcoded red background with white text, which fell below the
WCAG AA contrast requirement for text that size.
The badge now uses the design system's danger color tokens instead,
which are already tuned to keep sufficient contrast with their
paired text color across all theme variants.
https://github.com/owncloud/ocis/pull/13000
@@ -0,0 +1,12 @@
Bugfix: notification bell now announces the unread count
The notification bell's accessible name was a static "Notifications"
string regardless of how many unread notifications there were. Since
that label overrides all other content for assistive technology, screen
reader users never heard the unread count that sighted users see on the
bell's badge.
The bell's accessible name and tooltip now include the exact unread
count, with correct singular/plural wording.
https://github.com/owncloud/ocis/pull/13003
@@ -0,0 +1,12 @@
Bugfix: fixed arrow-key navigation in the notification dropdown
Opening the notification bell's dropdown did not move keyboard focus into
it. Arrow-key navigation only started working after an extra, unrelated
Tab press, and pressing an arrow key too early scrolled the page instead,
which looked like the dropdown had closed.
The dropdown now moves focus to its first item as soon as it opens, so
arrow keys work immediately, matching the behavior of other click-triggered
dropdowns in the application.
https://github.com/owncloud/ocis/pull/13002
@@ -0,0 +1,12 @@
Bugfix: fixed low color contrast on share permission dropdown hover text
The share permission dropdown's role options, such as "Can view" or
"Can edit", showed their hovered text in a color too close in
lightness to the hover background in the dark theme, making it hard
to read.
The hover text color has been lightened slightly, restoring
readable contrast between the text and the background while
hovering.
https://github.com/owncloud/ocis/pull/12995
@@ -0,0 +1,14 @@
Bugfix: added a keyboard shortcut to move focus out of the text editor
Opening the text/markdown editor moved keyboard focus straight into the
edit area, but Tab is bound to indenting rather than moving focus, so
there was no reliable way to reach the toolbar without leaving the file
entirely. The editor's own built-in escape hatch for this doesn't work
on a standard Mac keyboard, since the key combo it relies on is consumed
by macOS as a diacritic shortcut before it reaches the page.
Pressing Ctrl+M now moves focus from the edit area to the toolbar, the
same way on every platform. The editor's accessible description also
announces this shortcut for assistive technology users.
https://github.com/owncloud/ocis/pull/13004
@@ -0,0 +1,7 @@
Bugfix: Text and BMP file previews failed where libvips has no ImageMagick
Downloading the preview of a text or BMP file failed with a `500 could not get thumbnail` error on systems where libvips comes without ImageMagick support, such as minimal container images. The rendered text image was passed through a BMP encoding round-trip first, and uploaded BMP files were handed to libvips as bytes; libvips can only load BMP images via ImageMagick.
The rendered text image is now handed over to libvips directly from memory, and BMP files are decoded in Go before the handover, so both no longer depend on ImageMagick being installed alongside libvips.
https://github.com/owncloud/ocis/pull/12961
@@ -0,0 +1,12 @@
Bugfix: Return a retryable 503 when the OIDC userinfo call fails transiently
A transient failure of the OIDC userinfo call (a timeout, a network error or a
5xx/429 from the IdP) was mapped to HTTP 401. Clients read the 401 as an invalid
session and logged the user out on a brief IdP slowdown.
The proxy now distinguishes a transient IdP failure from an authentication
failure and returns a retryable 503 (with Retry-After) for the former, so clients
retry and keep their session. A genuinely invalid or expired token still returns
401.
https://github.com/owncloud/ocis/pull/12999
@@ -0,0 +1,15 @@
Bugfix: Open Safe permanent links from outside the Safe
A permanent link to a file in the Safe, opened in a regular Drive tab, showed
"An error occurred while resolving the private link" instead of the file. The
Web frontend recognized Safe files by a storage provider id that the server
only sends to sessions already inside the Safe, so a Drive tab never redirected
the link into the Safe.
The Safe storage provider id is fixed, so the frontend now uses it as a
constant, like the share jail and OCM ids. This also keeps Safe notifications
out of the Drive view and lets the invite form recognize Safe resources in
Drive mode. The `vaultStorageProvider` getter of the web-pkg capability store
is removed; use `VAULT_STORAGE_PROVIDER_ID` from web-client instead.
https://github.com/owncloud/ocis/pull/13001
@@ -0,0 +1,17 @@
Bugfix: Hide "Shared via link" when public sharing is disabled
The Shares navigation (the desktop tab list and the mobile drop-down) always
offered a "Shared via link" entry, even when public link sharing was disabled
for the account — for example in the Vault, where the backend rejects public
link creation and the capability `files_sharing.public.enabled` reported
`false`. The entry led to a page that could never contain anything.
The Shares navigation was changed to hide the "Shared via link" entry
whenever `files_sharing.public.enabled` is `false`. Anyone who still reached
the via-link route directly, including through the legacy
`/list/shared-via-link` redirect, was redirected to "Shared with me" at
navigation time, keeping the current route scope (e.g. `vault`) intact. When
public sharing was enabled, all three Shares navigation entries continued to
behave exactly as before.
https://github.com/owncloud/ocis/pull/13005
+31 -31
View File
@@ -10,7 +10,7 @@ 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.7.1
github.com/beevik/etree v1.8.1
github.com/blevesearch/bleve/v2 v2.6.0
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cenkalti/backoff/v5 v5.0.3
@@ -35,7 +35,7 @@ require (
github.com/go-micro/plugins/v4/store/nats-js-kv v0.0.0-20240726082623-6831adfdcdc4
github.com/go-micro/plugins/v4/wrapper/monitoring/prometheus v1.2.0
github.com/go-micro/plugins/v4/wrapper/trace/opentelemetry v1.2.0
github.com/go-playground/validator/v10 v10.30.4
github.com/go-playground/validator/v10 v10.30.5
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/golang/protobuf v1.5.4
@@ -58,16 +58,16 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/mna/pigeon v1.3.0
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/nats-io/nats-server/v2 v2.14.6
github.com/nats-io/nats.go v1.53.1
github.com/nats-io/nats-server/v2 v2.15.0
github.com/nats-io/nats.go v1.54.0
github.com/olekukonko/tablewriter v1.1.4
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.32.1
github.com/onsi/gomega v1.43.0
github.com/onsi/ginkgo/v2 v2.33.0
github.com/onsi/gomega v1.44.0
github.com/open-policy-agent/opa v1.19.0
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-20260917145219-ba14a94a3c7a
github.com/owncloud/reva/v2 v2.0.0-20261006130333-e8a7c20b6b93
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.12
github.com/prometheus/client_golang v1.24.1
@@ -83,7 +83,7 @@ require (
github.com/test-go/testify v1.1.4
github.com/thejerf/suture/v4 v4.0.6
github.com/tidwall/gjson v1.19.0
github.com/tus/tusd/v2 v2.10.0
github.com/tus/tusd/v2 v2.10.1
github.com/unrolled/secure v1.17.0
github.com/urfave/cli/v2 v2.27.7
github.com/xhit/go-simple-mail/v2 v2.16.0
@@ -97,16 +97,16 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0
go.opentelemetry.io/otel/sdk v1.46.0
go.opentelemetry.io/otel/trace v1.46.0
golang.org/x/crypto v0.56.0
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f
golang.org/x/crypto v0.57.0
golang.org/x/exp v0.0.0-20260611194520-c48552f49976
golang.org/x/image v0.45.0
golang.org/x/net v0.58.0
golang.org/x/oauth2 v0.36.0
golang.org/x/sync v0.22.0
golang.org/x/term v0.45.0
golang.org/x/text v0.41.0
golang.org/x/oauth2 v0.37.0
golang.org/x/sync v0.23.0
golang.org/x/term v0.46.0
golang.org/x/text v0.42.0
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688
google.golang.org/grpc v1.83.2
google.golang.org/grpc v1.84.0
google.golang.org/protobuf v1.36.12
gopkg.in/yaml.v2 v2.4.0
gotest.tools/v3 v3.5.2
@@ -128,7 +128,7 @@ require (
github.com/ajg/form v1.5.1 // indirect
github.com/alexedwards/argon2id v1.0.0 // indirect
github.com/amoghe/go-crypt v0.0.0-20220222110647-20eada5f5964 // indirect
github.com/antithesishq/antithesis-sdk-go v0.7.2-default-no-op // indirect
github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go v1.55.8 // indirect
@@ -199,7 +199,7 @@ require (
github.com/go-micro/plugins/v4/store/nats-js v1.2.1 // indirect
github.com/go-micro/plugins/v4/store/redis v1.2.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/universal-translator v0.18.2 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-resty/resty/v2 v2.17.2 // indirect
github.com/go-sql-driver/mysql v1.10.1 // indirect
@@ -220,7 +220,7 @@ require (
github.com/gomodule/redigo v1.9.3 // indirect
github.com/google/go-querystring v1.2.0 // indirect
github.com/google/go-tpm v0.9.8 // indirect
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
github.com/google/pprof v0.0.0-20260604005048-7023385849c0 // indirect
github.com/google/renameio/v2 v2.0.2 // indirect
github.com/gookit/goutil v0.8.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
@@ -228,7 +228,7 @@ require (
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.8.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/huandu/xstrings v1.6.1 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -238,7 +238,7 @@ require (
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
github.com/juliangruber/go-intersect v1.1.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.19.2 // indirect
github.com/klauspost/compress v1.20.0 // indirect
github.com/klauspost/cpuid/v2 v2.4.0 // indirect
github.com/klauspost/crc32 v1.3.0 // indirect
github.com/kovidgoyal/go-parallel v1.1.1 // indirect
@@ -255,10 +255,10 @@ require (
github.com/longsleep/go-metrics v1.0.0 // indirect
github.com/longsleep/rndm v1.2.0 // indirect
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.21 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mattn/go-runewidth v0.0.23 // indirect
github.com/mattn/go-sqlite3 v1.14.50 // indirect
github.com/mattn/go-sqlite3 v1.14.52 // indirect
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b // indirect
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 // indirect
github.com/miekg/dns v1.1.72 // indirect
@@ -290,7 +290,7 @@ require (
github.com/pierrec/lz4/v4 v4.1.26 // indirect
github.com/pjbgf/sha1cd v0.6.0 // indirect
github.com/pquerna/cachecontrol v0.2.0 // indirect
github.com/prometheus/alertmanager v0.34.0 // indirect
github.com/prometheus/alertmanager v0.34.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.70.1 // indirect
github.com/prometheus/procfs v0.21.1 // indirect
@@ -326,9 +326,9 @@ require (
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yashtewari/glob-intersection v0.2.0 // indirect
github.com/zeebo/xxh3 v1.1.0 // indirect
go.etcd.io/etcd/api/v3 v3.7.1 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.7.1 // indirect
go.etcd.io/etcd/client/v3 v3.7.1 // indirect
go.etcd.io/etcd/api/v3 v3.7.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.7.2 // indirect
go.etcd.io/etcd/client/v3 v3.7.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 // indirect
@@ -338,11 +338,11 @@ require (
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/mod v0.40.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/mod v0.41.0 // indirect
golang.org/x/sys v0.48.0 // indirect
golang.org/x/time v0.16.0 // indirect
golang.org/x/tools v0.49.0 // indirect
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 // indirect
google.golang.org/genproto v0.0.0-20260622175928-b703f567277d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/ini.v1 v1.67.3 // indirect
+62 -62
View File
@@ -90,8 +90,8 @@ github.com/amoghe/go-crypt v0.0.0-20220222110647-20eada5f5964 h1:I9YN9WMo3SUh7p/
github.com/amoghe/go-crypt v0.0.0-20220222110647-20eada5f5964/go.mod h1:eFiR01PwTcpbzXtdMces7zxg6utvFM5puiWHpWB8D/k=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/antithesishq/antithesis-sdk-go v0.7.2-default-no-op h1:p2zFsAzvhIpFya8AIOHIbWf7NGvO34QpLGclyf7nXj8=
github.com/antithesishq/antithesis-sdk-go v0.7.2-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op h1:1BOWQJweNyvZMlpAHXGLiZQn9S+QXGcz3xh94lC0w6E=
github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
@@ -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.7.1 h1:xBlSFAjlMfZkrCNKCEdZ2MSN9pfQYeRBaISDnAVi4Ek=
github.com/beevik/etree v1.7.1/go.mod h1:bh4zJxiIr62SOf9pRzN7UUYaEDa9HEKafK25+sLc0Gc=
github.com/beevik/etree v1.8.1 h1:MchsAnqPGCGsfQezhwcouHPlAHlcAOqWpyCVZoyWfjU=
github.com/beevik/etree v1.8.1/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=
@@ -357,10 +357,10 @@ github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lY
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.30.4 h1:9Rcod2ZPO6mOEG6b4GqyoHE/H6//Ze0RuhOo1hT1x0w=
github.com/go-playground/validator/v10 v10.30.4/go.mod h1:numpT+RPLE91R9oYWMY/R9zRgJBewr3IXHko4OISPpk=
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
github.com/go-playground/validator/v10 v10.30.5 h1:YyCXvVShZbs2Sm3Mb53eNOlhRXctSOzW5QJAouCTZL4=
github.com/go-playground/validator/v10 v10.30.5/go.mod h1:wEqiaov48pXX1kjhc3Da8y0M0Dtg/BK7gurFBLgwFrQ=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk=
@@ -475,8 +475,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg=
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
github.com/google/pprof v0.0.0-20260604005048-7023385849c0 h1:h1QTMDl6q9wDvDCJVpKQSjgleGFYnd2fOxmg2K+6BGE=
github.com/google/pprof v0.0.0-20260604005048-7023385849c0/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio/v2 v2.0.2 h1:qKZs+tfn+arruZZhQ7TKC/ergJunuJicWS6gLDt/dGw=
github.com/google/renameio/v2 v2.0.2/go.mod h1:OX+G6WHHpHq3NVj7cAOleLOwJfcQ1s3uUJQCrr78SWo=
@@ -512,8 +512,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.6.1 h1:yYdKSd6Sjv3fNZt9BDjl1FDsPNfQEaYi19L5LzK2JKs=
github.com/huandu/xstrings v1.6.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
@@ -573,8 +573,8 @@ github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.19.2 h1:hMRETovs/pu/dVWN7zIT1PGG8t509MwT6bO7XSi26R8=
github.com/klauspost/compress v1.19.2/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
@@ -641,16 +641,16 @@ github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs=
github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mattn/go-sqlite3 v1.14.50 h1:dmdFvo1XG4MPzA4IkAmE9upVz/Nj31uRoM5+jC8hYbY=
github.com/mattn/go-sqlite3 v1.14.50/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
github.com/mattn/go-sqlite3 v1.14.52 h1:wVbm2Qnf4OXkqhBTSPuCRZDRnxfbVrrmiCEroVdog8U=
github.com/mattn/go-sqlite3 v1.14.52/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQDDHyXaxZ6pUl0I9uyD6Z6uKFK3ocX6LzI=
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus=
@@ -696,10 +696,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc=
github.com/nats-io/jwt/v2 v2.8.2/go.mod h1:Ag/56sq9OblL4JgdYufDd16Egb17Kr/8WwwuO/forVc=
github.com/nats-io/nats-server/v2 v2.14.6 h1:dHjEHa49lUTxIb5jrsk5kz/AmOyOQ4T9ti8djcBumDQ=
github.com/nats-io/nats-server/v2 v2.14.6/go.mod h1:u/0bNBzN/m5orQGz7q2NNzxCQ6PWdwaOSwPNDADZn/A=
github.com/nats-io/nats.go v1.53.1 h1:Otsq3uLc/kLdjmkNHkXH0jBqwUquwdKFoe3fq6/3/Xo=
github.com/nats-io/nats.go v1.53.1/go.mod h1:26HypzazeOkyO3/mqd1zZd53STJN0EjCYF9Uy2ZOBno=
github.com/nats-io/nats-server/v2 v2.15.0 h1:M99yf0y05rTr46/qc/Is6ZAowI58Ryp2SjufLCUeVJc=
github.com/nats-io/nats-server/v2 v2.15.0/go.mod h1:5qLF4CDGzZVFt//3fUrY1ePpwbi05r7QHPNroSUtolk=
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
@@ -721,12 +721,12 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.32.1 h1:6tlvcDm/3sE8lGJbZ4+d4mO3RLy24/tQWOFzVSQNIfw=
github.com/onsi/ginkgo/v2 v2.32.1/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
github.com/onsi/ginkgo/v2 v2.33.0 h1:C8gBA6Uc2ZEubiV+SXiu5tZnMTwEmXHgkJwGozKtZf8=
github.com/onsi/ginkgo/v2 v2.33.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.43.0 h1:VlG/1FxqNxhSO+lq/OHBNaaqwiBK/mO8JbVkX9Y+FeU=
github.com/onsi/gomega v1.43.0/go.mod h1:REff/hsDsodHoKlWsP2mAPhu1+5/6hVYNf9rIEBpeSg=
github.com/onsi/gomega v1.44.0 h1:eAiGl3Pw5jz5GQdDff0BcxYpAX1JxW8xD7mFUuwNfZQ=
github.com/onsi/gomega v1.44.0/go.mod h1:e/C2HwaZ1DhvjzXXuFhcR7hY7Sh9pl7MmoWKEjzwcdA=
github.com/open-policy-agent/opa v1.19.0 h1:+j2OCsjMezZEML2T1lI9giJdGJS/PL1XFKgkHPGIhpo=
github.com/open-policy-agent/opa v1.19.0/go.mod h1:pb6Y6klyf7X7X8uXNDflruA9dQC2gMqWROXI5w/kvv0=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
@@ -736,8 +736,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-20260917145219-ba14a94a3c7a h1:QnKAz6PPmeMgF+w5UJ70InpsrtUeW/6GX+ikkb61XVs=
github.com/owncloud/reva/v2 v2.0.0-20260917145219-ba14a94a3c7a/go.mod h1:VohDRQV33rVDiofWNngHqQK7tsgtYJpQBNWsn41j/LM=
github.com/owncloud/reva/v2 v2.0.0-20261006130333-e8a7c20b6b93 h1:oq264ouHPdZkMkAVlApVncbY+9uK5pIlwlD5XmNl2FA=
github.com/owncloud/reva/v2 v2.0.0-20261006130333-e8a7c20b6b93/go.mod h1:lr0ehPvNrODohFll0kJa/sIi2T6YskJLPjmR2tC2q2U=
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=
@@ -767,8 +767,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/cachecontrol v0.2.0 h1:vBXSNuE5MYP9IJ5kjsdo8uq+w41jSPgvba2DEnkRx9k=
github.com/pquerna/cachecontrol v0.2.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI=
github.com/prometheus/alertmanager v0.34.0 h1:z75n0NoypggESmt3HD4JlTXOaOZj1EBz1ACHO4Z6EUk=
github.com/prometheus/alertmanager v0.34.0/go.mod h1:/qF39A6Vb1MMoDM1SxcySobb7wmpBZha8COwULiKUUo=
github.com/prometheus/alertmanager v0.34.1 h1:qtIIP4s20duq2fbafHIti5NYJGaZNh7irXKbJwe/W/E=
github.com/prometheus/alertmanager v0.34.1/go.mod h1:XlyJZycGA13e2hrjPMNrrB4C2tzsenmpt2Prya4taws=
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
@@ -909,8 +909,8 @@ github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 h1:PM5hJF7HVfNWmCjM
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns=
github.com/trustelem/zxcvbn v1.0.1 h1:mp4JFtzdDYGj9WYSD3KQSkwwUumWNFzXaAjckaTYpsc=
github.com/trustelem/zxcvbn v1.0.1/go.mod h1:zonUyKeh7sw6psPf/e3DtRqkRyZvAbOfjNz/aO7YQ5s=
github.com/tus/tusd/v2 v2.10.0 h1:2yOGmkrDl9RQmRIt/00DR2WvYWOoiEu3CoygILb+WRw=
github.com/tus/tusd/v2 v2.10.0/go.mod h1:T/OuJHIAC2NHpkEUyQyyaoWyDNRDcQVpJzWl8tX5GY4=
github.com/tus/tusd/v2 v2.10.1 h1:hO312j4rT0unhaF4Ga7izNaYGbPOKI2kVIXbKgtv1W8=
github.com/tus/tusd/v2 v2.10.1/go.mod h1:33RsdwtbXdqb3esrge+95TT7XUHl45uSO1vvA96fNbc=
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
github.com/valyala/fastjson v1.6.10 h1:/yjJg8jaVQdYR3arGxPE2X5z89xrlhS0eGXdv+ADTh4=
@@ -950,12 +950,12 @@ github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
go.etcd.io/bbolt v1.5.0 h1:S7GAl7Fxv12yohbwFfIbQCGDWbQbtDGPET4P/bD4lxU=
go.etcd.io/bbolt v1.5.0/go.mod h1:mkltfYE5aUHQxUct9N9V+Kp7aSjFqjgrhcXIS70Lrdk=
go.etcd.io/etcd/api/v3 v3.7.1 h1:KJG0/DcWGfe3Y1otDf/fsBf0TSSgpxZ5RO/L8SFt73E=
go.etcd.io/etcd/api/v3 v3.7.1/go.mod h1:8bXIpCMeV7E3/XL0Ix123ATn3dB+0V7d9zklHbB0m78=
go.etcd.io/etcd/client/pkg/v3 v3.7.1 h1:rKYsj3pRkR0eK3yjT3XOgrhqfmIfj9pzNgxjh7mfFv4=
go.etcd.io/etcd/client/pkg/v3 v3.7.1/go.mod h1:cnzZGIUzSfjEwLC6UBVsSXlEK1eepS/JUD7wE6PLRT0=
go.etcd.io/etcd/client/v3 v3.7.1 h1:0PEMMC0KuZmVIN+RAbdqfkZ45pYTgKVtmBEbRCvZFUg=
go.etcd.io/etcd/client/v3 v3.7.1/go.mod h1:ffNqALa8tRCYhYo1F9oR489y23K39Gz+BSR3ApAGYq0=
go.etcd.io/etcd/api/v3 v3.7.2 h1:xgt/6el1LsPWWYNLkhMAK4tZm6dF+1sCqDecpE5gdbk=
go.etcd.io/etcd/api/v3 v3.7.2/go.mod h1:RoRCBRt9BfBff1pIGZLUVMiz7wu3bY+b2qLysGu1HY4=
go.etcd.io/etcd/client/pkg/v3 v3.7.2 h1:SVtlR7tiSVAYOQ4nWPIyFXb4RMgEcnzeAG9RQ8MoNDU=
go.etcd.io/etcd/client/pkg/v3 v3.7.2/go.mod h1:HsSux/B3ahgyw/D5+d4YbZqicOi0mEbuxm6lIUdjAoI=
go.etcd.io/etcd/client/v3 v3.7.2 h1:Z66GqDQDI7zPDfVSsIBqGSK4mJYLtv8ESwXa4mPf+wY=
go.etcd.io/etcd/client/v3 v3.7.2/go.mod h1:x03t1qMs4tGZirCDJlMuzPBJdQffXJImIyEjLhNBCsY=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@@ -1016,8 +1016,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.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y=
golang.org/x/crypto v0.56.0/go.mod h1:OMW5y6CY9l38uPLmxU6l6pwcXp1obtLo3e6gT7gQR2I=
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
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=
@@ -1028,8 +1028,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM=
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY=
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.45.0 h1:FMb1nTbH5H9vF55SriQHgFw5GnNL9Jg6L25BwXKzhB0=
@@ -1055,8 +1055,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.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs=
golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE=
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
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=
@@ -1109,8 +1109,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/oauth2 v0.37.0 h1:JUlcxA8oAtauLfiH8FX2/FkAWHAdi0QtGCGc+hofE98=
golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1125,8 +1125,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.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
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=
@@ -1189,8 +1189,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.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
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=
@@ -1198,8 +1198,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.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
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=
@@ -1211,13 +1211,13 @@ 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.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
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=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE=
golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -1325,8 +1325,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 h1:XzmzkmB14QhVhgnawEVsOn6OFsnpyxNPRY9QV01dNB0=
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:L43LFes82YgSonw6iTXTxXUX1OlULt4AQtkik4ULL/I=
google.golang.org/genproto v0.0.0-20260622175928-b703f567277d h1:CP5omUq8AJTiWMrPKM1WRLJ7zZeXd9OPcQD3TbBNAyY=
google.golang.org/genproto v0.0.0-20260622175928-b703f567277d/go.mod h1:DrwuGJgFSEVNpv3S5Q5VxhRTvdnjauw9GtvwVOEARfA=
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI=
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 h1:1VUiZAXyC+zmiFYi+WLtBzr68Cj8wOofHjjrA/kkizc=
@@ -1344,8 +1344,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.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU=
google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8=
google.golang.org/grpc v1.84.0 h1:soMyaPJ8pAak5PIQ0DGBUir0XRo2fRoMqhNWMLlLxO0=
google.golang.org/grpc v1.84.0/go.mod h1:ljCht0DrxQrXBDRTZp52Qxh3Ffk8CdYm2sj4O2QN2C0=
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=
+17
View File
@@ -1,6 +1,8 @@
package cors
import (
"strings"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
)
@@ -66,3 +68,18 @@ func AllowCredentials(allow bool) Option {
o.AllowCredentials = allow
}
}
// AllowsAnyOrigin reports whether the origins permit any origin: an empty list,
// a bare "*", or any wildcard-pattern entry (e.g. "https://*"). Such origins must
// not be combined with credentials. Matching is lower-cased and trimmed.
func AllowsAnyOrigin(origins []string) bool {
if len(origins) == 0 {
return true
}
for _, o := range origins {
if strings.Contains(strings.ToLower(strings.TrimSpace(o)), "*") {
return true
}
}
return false
}
+29
View File
@@ -0,0 +1,29 @@
package cors
import "testing"
func TestAllowsAnyOrigin(t *testing.T) {
testCases := []struct {
name string
origins []string
want bool
}{
{"nil list", nil, true},
{"empty list", []string{}, true},
{"bare wildcard", []string{"*"}, true},
{"padded wildcard", []string{"* "}, true},
{"wildcard scheme pattern", []string{"https://*"}, true},
{"wildcard subdomain pattern", []string{"*.example.com"}, true},
{"wildcard among concrete origins", []string{"https://a.example", "https://*"}, true},
{"single concrete origin", []string{"https://a.example"}, false},
{"multiple concrete origins", []string{"https://a.example", "https://b.example"}, false},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if got := AllowsAnyOrigin(tc.origins); got != tc.want {
t.Errorf("AllowsAnyOrigin(%q) = %v, want %v", tc.origins, got, tc.want)
}
})
}
}
+12 -2
View File
@@ -25,17 +25,27 @@ func NoCache(next http.Handler) http.Handler {
func Cors(opts ...cors.Option) func(http.Handler) http.Handler {
options := cors.NewOptions(opts...)
logger := options.Logger
allowCredentials := options.AllowCredentials
// A wildcard origin must not be combined with credentials.
if allowCredentials && cors.AllowsAnyOrigin(options.AllowedOrigins) {
logger.Warn().
Strs("allowed_origins", options.AllowedOrigins).
Msg("cors: refusing to allow credentials together with a wildcard origin, disabling allow_credentials")
allowCredentials = false
}
logger.Debug().
Str("allowed_origins", strings.Join(options.AllowedOrigins, ", ")).
Str("allowed_methods", strings.Join(options.AllowedMethods, ", ")).
Str("allowed_headers", strings.Join(options.AllowedHeaders, ", ")).
Bool("allow_credentials", options.AllowCredentials).
Bool("allow_credentials", allowCredentials).
Msg("setup cors middleware")
c := rscors.New(rscors.Options{
AllowedOrigins: options.AllowedOrigins,
AllowedMethods: options.AllowedMethods,
AllowedHeaders: options.AllowedHeaders,
AllowCredentials: options.AllowCredentials,
AllowCredentials: allowCredentials,
})
return c.Handler
}
+107
View File
@@ -0,0 +1,107 @@
package middleware
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
)
// TestCorsWildcardOriginDropsCredentials verifies that a wildcard/allow-all
// origin is never combined with Access-Control-Allow-Credentials: true.
func TestCorsWildcardOriginDropsCredentials(t *testing.T) {
testCases := []struct {
name string
allowedOrigins []string
allowCredentials bool
requestOrigin string
wantAllowOrigin string
wantCredentials bool
}{
{
name: "wildcard origin with credentials drops credentials",
allowedOrigins: []string{"*"},
allowCredentials: true,
requestOrigin: "https://other.example",
wantAllowOrigin: "*",
wantCredentials: false,
},
{
name: "empty origins (allow all) with credentials drops credentials",
allowedOrigins: []string{},
allowCredentials: true,
requestOrigin: "https://other.example",
wantAllowOrigin: "*",
wantCredentials: false,
},
{
// Wildcard-pattern origins are reflected verbatim rather than answered with "*".
name: "wildcard-pattern origin with credentials drops credentials",
allowedOrigins: []string{"https://*"},
allowCredentials: true,
requestOrigin: "https://other.example",
wantAllowOrigin: "https://other.example",
wantCredentials: false,
},
{
name: "wildcard origin without credentials stays wildcard",
allowedOrigins: []string{"*"},
allowCredentials: false,
requestOrigin: "https://other.example",
wantAllowOrigin: "*",
wantCredentials: false,
},
{
name: "explicit whitelisted origin keeps credentials",
allowedOrigins: []string{"https://cloud.example.com"},
allowCredentials: true,
requestOrigin: "https://cloud.example.com",
wantAllowOrigin: "https://cloud.example.com",
wantCredentials: true,
},
{
name: "non-whitelisted origin is not reflected",
allowedOrigins: []string{"https://cloud.example.com"},
allowCredentials: true,
requestOrigin: "https://other.example",
wantAllowOrigin: "",
wantCredentials: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
handler := Cors(
cors.Logger(log.NewLogger()),
cors.AllowedOrigins(tc.allowedOrigins),
cors.AllowedMethods([]string{"GET", "OPTIONS"}),
cors.AllowedHeaders([]string{"Authorization"}),
cors.AllowCredentials(tc.allowCredentials),
)(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}))
// Exercise the actual (non-preflight) request path.
req := httptest.NewRequest(http.MethodGet, "/", nil)
req.Header.Set("Origin", tc.requestOrigin)
rec := httptest.NewRecorder()
handler.ServeHTTP(rec, req)
gotOrigin := rec.Header().Get("Access-Control-Allow-Origin")
if gotOrigin != tc.wantAllowOrigin {
t.Errorf("Access-Control-Allow-Origin = %q, want %q", gotOrigin, tc.wantAllowOrigin)
}
gotCredentials := rec.Header().Get("Access-Control-Allow-Credentials") == "true"
if gotCredentials != tc.wantCredentials {
t.Errorf("Access-Control-Allow-Credentials = %v, want %v", gotCredentials, tc.wantCredentials)
}
if gotOrigin == "*" && gotCredentials {
t.Error("insecure CORS: wildcard origin combined with credentials")
}
})
}
}
+29 -14
View File
@@ -115,17 +115,21 @@ func (c *oidcClient) lookupWellKnownOpenidConfiguration(ctx context.Context) err
}
resp, err := c.httpClient.Do(req.WithContext(ctx))
if err != nil {
return err
return classifyTransport(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("unable to read response body: %v", err)
return classifyTransport(err)
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s: %s", resp.Status, body)
err := fmt.Errorf("%s: %s", resp.Status, body)
if statusIsTransient(resp.StatusCode) {
return errors.Join(ErrTemporarilyUnavailable, err)
}
return err
}
var p ProviderMetadata
@@ -150,7 +154,7 @@ func (c *oidcClient) lookupWellKnownOpenidConfiguration(ctx context.Context) err
return nil
}
func (c *oidcClient) getKeyfunc() *keyfunc.JWKS {
func (c *oidcClient) getKeyfunc() (*keyfunc.JWKS, error) {
c.jwksLock.Lock()
defer c.jwksLock.Unlock()
if c.JWKS == nil {
@@ -170,10 +174,10 @@ func (c *oidcClient) getKeyfunc() *keyfunc.JWKS {
if err != nil {
c.JWKS = nil
c.Logger.Error().Err(err).Msg("Failed to create JWKS from resource at the given URL.")
return nil
return nil, err
}
}
return c.JWKS
return c.JWKS, nil
}
type stringAsBool bool
@@ -239,15 +243,19 @@ func (c *oidcClient) UserInfo(ctx context.Context, tokenSource oauth2.TokenSourc
resp, err := c.httpClient.Do(req.WithContext(ctx))
if err != nil {
return nil, err
return nil, classifyTransport(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
return nil, classifyTransport(err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s: %s", resp.Status, body)
err := fmt.Errorf("%s: %s", resp.Status, body)
if statusIsTransient(resp.StatusCode) {
return nil, errors.Join(ErrTemporarilyUnavailable, err)
}
return nil, err
}
ct := resp.Header.Get("Content-Type")
@@ -293,7 +301,11 @@ func (c *oidcClient) VerifyAccessToken(ctx context.Context, token string) (RegCl
func (c *oidcClient) verifyAccessTokenJWT(token string) (RegClaimsWithSID, jwt.MapClaims, error) {
var claims RegClaimsWithSID
mapClaims := jwt.MapClaims{}
jwks := c.getKeyfunc()
jwks, err := c.getKeyfunc()
if err != nil {
// A JWKS fetch timeout/network error is transient (503), not a bad token (401).
return claims, mapClaims, classifyTransport(err)
}
if jwks == nil {
return claims, mapClaims, errors.New("error initializing jwks keyfunc")
}
@@ -305,9 +317,9 @@ func (c *oidcClient) verifyAccessTokenJWT(token string) (RegClaimsWithSID, jwt.M
issuer = c.provider.AccessTokenIssuer
}
_, err := jwt.ParseWithClaims(token, &claims, jwks.Keyfunc, jwt.WithIssuer(issuer))
_, err = jwt.ParseWithClaims(token, &claims, jwks.Keyfunc, jwt.WithIssuer(issuer))
if err != nil {
return claims, mapClaims, err
return claims, mapClaims, classifyTransport(err)
}
_, _, err = new(jwt.Parser).ParseUnverified(token, mapClaims)
// TODO: decode mapClaims to sth readable
@@ -358,7 +370,10 @@ func (c *oidcClient) VerifyLogoutToken(ctx context.Context, rawToken string) (*L
if err := c.lookupWellKnownOpenidConfiguration(ctx); err != nil {
return nil, err
}
jwks := c.getKeyfunc()
jwks, err := c.getKeyfunc()
if err != nil {
return nil, classifyTransport(err)
}
if jwks == nil {
return nil, errors.New("error initializing jwks keyfunc")
}
@@ -373,7 +388,7 @@ func (c *oidcClient) VerifyLogoutToken(ctx context.Context, rawToken string) (*L
supportedSigAlgs = []string{RS256}
}
_, err := jwt.ParseWithClaims(rawToken, &claims, jwks.Keyfunc, jwt.WithValidMethods(supportedSigAlgs), jwt.WithIssuer(c.issuer))
_, err = jwt.ParseWithClaims(rawToken, &claims, jwks.Keyfunc, jwt.WithValidMethods(supportedSigAlgs), jwt.WithIssuer(c.issuer))
if err != nil {
c.Logger.Debug().Err(err).Msg("Failed to parse logout token")
return nil, err
+66
View File
@@ -4,12 +4,16 @@ import (
"context"
"crypto/rand"
"crypto/rsa"
"errors"
"net/http"
"net/http/httptest"
"testing"
"github.com/MicahParks/keyfunc/v2"
"github.com/golang-jwt/jwt/v5"
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
"github.com/owncloud/ocis/v2/services/proxy/pkg/config"
"golang.org/x/oauth2"
)
type signingKey struct {
@@ -301,6 +305,68 @@ func TestVerifyAccessTokenAudience(t *testing.T) {
}
}
// A userinfo call that returns a transient status (429/5xx) must be classified as
// temporarily unavailable so the proxy answers 503, not 401 (#12999). A genuine
// auth status (401/403) must stay a plain error that maps to 401.
func TestUserInfoStatusClassification(t *testing.T) {
tests := []struct {
status int
transient bool
}{
{http.StatusUnauthorized, false},
{http.StatusForbidden, false},
{http.StatusInternalServerError, true},
{http.StatusBadGateway, true},
{http.StatusServiceUnavailable, true},
{http.StatusTooManyRequests, true},
}
for _, tt := range tests {
t.Run(http.StatusText(tt.status), func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(tt.status)
}))
defer srv.Close()
c := oidc.NewOIDCClient(
oidc.WithProviderMetadata(&oidc.ProviderMetadata{UserinfoEndpoint: srv.URL}),
oidc.WithHTTPClient(srv.Client()),
)
_, err := c.UserInfo(context.Background(),
oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "t"}))
if err == nil {
t.Fatalf("expected an error for status %d", tt.status)
}
if got := errors.Is(err, oidc.ErrTemporarilyUnavailable); got != tt.transient {
t.Fatalf("status %d: transient = %v, want %v (err=%v)", tt.status, got, tt.transient, err)
}
})
}
}
// A transient failure while discovering the IdP (well-known/JWKS) during access-token
// verification must be classified as temporarily unavailable, not surfaced as a 401 (#12999).
func TestVerifyAccessTokenTransientDiscovery(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusServiceUnavailable)
}))
defer srv.Close()
c := oidc.NewOIDCClient(
oidc.WithOidcIssuer(srv.URL),
oidc.WithHTTPClient(srv.Client()),
oidc.WithAccessTokenVerifyMethod(config.AccessTokenVerificationJWT),
)
_, _, err := c.VerifyAccessToken(context.Background(), "any.token.here")
if err == nil {
t.Fatal("expected an error for a 503 during discovery")
}
if !errors.Is(err, oidc.ErrTemporarilyUnavailable) {
t.Fatalf("discovery 503 must be transient, got %v", err)
}
}
func newRSAKey(t testing.TB) *signingKey {
priv, err := rsa.GenerateKey(rand.Reader, 1028)
if err != nil {
+40
View File
@@ -0,0 +1,40 @@
package oidc
import (
"context"
"errors"
"net"
"net/http"
)
// ErrTemporarilyUnavailable marks a transient IdP failure (timeout, network error
// or 5xx/429), which callers should treat as retryable (503) rather than as an
// authentication failure (401).
var ErrTemporarilyUnavailable = errors.New("oidc: identity provider temporarily unavailable")
func classifyTransport(err error) error {
if err == nil {
return nil
}
// context.Canceled means the caller hung up or the server is shutting down, not an IdP outage.
var netErr net.Error
if errors.Is(err, context.DeadlineExceeded) || errors.As(err, &netErr) {
return errors.Join(ErrTemporarilyUnavailable, err)
}
return err
}
// statusIsTransient lists the retryable statuses explicitly so a permanent 5xx
// (501, 505) fails fast instead of being retried forever.
func statusIsTransient(status int) bool {
switch status {
case http.StatusTooManyRequests,
http.StatusInternalServerError,
http.StatusBadGateway,
http.StatusServiceUnavailable,
http.StatusGatewayTimeout:
return true
default:
return false
}
}
+69
View File
@@ -0,0 +1,69 @@
package oidc
import (
"context"
"errors"
"net"
"net/http"
"testing"
)
type timeoutErr struct{}
func (timeoutErr) Error() string { return "i/o timeout" }
func (timeoutErr) Timeout() bool { return true }
func (timeoutErr) Temporary() bool { return true }
var _ net.Error = timeoutErr{}
func TestClassifyTransport(t *testing.T) {
tests := []struct {
name string
err error
transient bool
}{
{"nil", nil, false},
{"deadline exceeded", context.DeadlineExceeded, true},
{"canceled", context.Canceled, false},
{"wrapped deadline", errors.Join(errors.New("get userinfo"), context.DeadlineExceeded), true},
{"net error", timeoutErr{}, true},
{"plain error", errors.New("token revoked"), false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := classifyTransport(tt.err)
if tt.err == nil {
if got != nil {
t.Fatalf("expected nil, got %v", got)
}
return
}
if errors.Is(got, ErrTemporarilyUnavailable) != tt.transient {
t.Fatalf("transient = %v, want %v (err=%v)", !tt.transient, tt.transient, got)
}
if !errors.Is(got, tt.err) {
t.Fatalf("classifyTransport dropped the underlying error: %v", got)
}
})
}
}
func TestStatusIsTransient(t *testing.T) {
tests := map[int]bool{
http.StatusUnauthorized: false,
http.StatusForbidden: false,
http.StatusNotFound: false,
http.StatusTooManyRequests: true,
http.StatusInternalServerError: true,
http.StatusBadGateway: true,
http.StatusServiceUnavailable: true,
http.StatusGatewayTimeout: true,
http.StatusNotImplemented: false,
http.StatusHTTPVersionNotSupported: false,
}
for status, want := range tests {
if got := statusIsTransient(status); got != want {
t.Errorf("statusIsTransient(%d) = %v, want %v", status, got, want)
}
}
}
@@ -36,7 +36,7 @@ func DefaultConfig() *config.Config {
Driver: "",
Drivers: config.Drivers{
WOPI: config.WOPIDriver{
WopiFolderURLBaseURL: "https://localhost:9200/",
WopiFolderURLBaseURL: "https://localhost:9200",
WopiFolderURLPathTemplate: "/f/{{.ResourceID}}",
},
},
@@ -2,6 +2,8 @@
package revaconfig
import (
"strings"
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config"
)
@@ -38,7 +40,7 @@ func AppProviderConfigFromStruct(cfg *config.Config) map[string]interface{} {
"iop_secret": cfg.Drivers.WOPI.IopSecret,
"jwt_secret": cfg.TokenManager.JWTSecret,
"wopi_url": cfg.Drivers.WOPI.WopiURL,
"wopi_folder_url_base_url": cfg.Drivers.WOPI.WopiFolderURLBaseURL,
"wopi_folder_url_base_url": strings.TrimRight(cfg.Drivers.WOPI.WopiFolderURLBaseURL, "/") + "/", // ensure it ends with "/"
"wopi_folder_url_path_template": cfg.Drivers.WOPI.WopiFolderURLPathTemplate,
},
},
@@ -61,14 +61,14 @@ func DefaultConfig() *config.Config {
PoolSize: 5,
PoolCheckoutTimeout: 30 * time.Second,
UserSchema: config.LDAPUserSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "displayname",
DisplayName: "displayName",
Username: "uid",
Enabled: "ownCloudUserEnabled",
},
GroupSchema: config.LDAPGroupSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "cn",
Groupname: "cn",
+10 -1
View File
@@ -12,6 +12,7 @@ import (
"github.com/owncloud/ocis/v2/ocis-pkg/capabilities"
"github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
"github.com/owncloud/ocis/v2/services/frontend/pkg/config"
@@ -87,6 +88,14 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
changePasswordDisabled = true
}
corsAllowCredentials := cfg.HTTP.CORS.AllowCredentials
if corsAllowCredentials && cors.AllowsAnyOrigin(cfg.HTTP.CORS.AllowedOrigins) {
logger.Warn().
Strs("allowed_origins", cfg.HTTP.CORS.AllowedOrigins).
Msg("cors: refusing to allow credentials together with a wildcard origin, disabling allow_credentials")
corsAllowCredentials = false
}
return map[string]interface{}{
"shared": map[string]interface{}{
"jwt_secret": cfg.TokenManager.JWTSecret,
@@ -102,7 +111,7 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
"allowed_origins": cfg.HTTP.CORS.AllowedOrigins,
"allowed_methods": cfg.HTTP.CORS.AllowedMethods,
"allowed_headers": cfg.HTTP.CORS.AllowedHeaders,
"allow_credentials": cfg.HTTP.CORS.AllowCredentials,
"allow_credentials": corsAllowCredentials,
// currently unused
//"options_passthrough": ,
//"debug": ,
@@ -105,7 +105,7 @@ func DefaultConfig() *config.Config {
UserNameAttribute: "uid",
// FIXME: switch this to some more widely available attribute by default
// ideally this needs to be constant for the lifetime of a users
UserIDAttribute: "owncloudUUID",
UserIDAttribute: "ownCloudUUID",
UserTypeAttribute: "ownCloudUserType",
UserEnabledAttribute: "ownCloudUserEnabled",
ExternalIDAttribute: "owncloudExternalID",
@@ -117,7 +117,7 @@ func DefaultConfig() *config.Config {
GroupObjectClass: "groupOfNames",
GroupNameAttribute: "cn",
GroupMemberAttribute: "member",
GroupIDAttribute: "owncloudUUID",
GroupIDAttribute: "ownCloudUUID",
EducationResourcesEnabled: false,
// 1 minute
InstanceMapperCacheTTL: 60,
@@ -105,7 +105,7 @@ func newSchoolAttributeMap() schoolAttributeMap {
return schoolAttributeMap{
displayName: "ou",
schoolNumber: "ocEducationSchoolNumber",
id: "owncloudUUID",
id: "ownCloudUUID",
terminationDate: "ocEducationSchoolTerminationTimestamp",
}
}
@@ -45,21 +45,21 @@ var schoolEntry = ldap.NewEntry("ou=Test School",
map[string][]string{
"ou": {"Test School"},
"ocEducationSchoolNumber": {"0123"},
"owncloudUUID": {"abcd-defg"},
"ownCloudUUID": {"abcd-defg"},
})
var schoolEntry1 = ldap.NewEntry("ou=Test School1",
map[string][]string{
"ou": {"Test School1"},
"ocEducationSchoolNumber": {"0042"},
"owncloudUUID": {"hijk-defg"},
"ownCloudUUID": {"hijk-defg"},
})
var (
filterSchoolSearchByIdExisting = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=abcd-defg)(ocEducationSchoolNumber=abcd-defg)))"
filterSchoolSearchByIdNonexistant = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=xxxx-xxxx)(ocEducationSchoolNumber=xxxx-xxxx)))"
filterSchoolSearchByNumberExisting = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=0123)(ocEducationSchoolNumber=0123)))"
filterSchoolSearchByNumberNonexistant = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=3210)(ocEducationSchoolNumber=3210)))"
filterSchoolSearchByIdExisting = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=abcd-defg)(ocEducationSchoolNumber=abcd-defg)))"
filterSchoolSearchByIdNonexistant = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=xxxx-xxxx)(ocEducationSchoolNumber=xxxx-xxxx)))"
filterSchoolSearchByNumberExisting = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=0123)(ocEducationSchoolNumber=0123)))"
filterSchoolSearchByNumberNonexistant = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=3210)(ocEducationSchoolNumber=3210)))"
)
func TestCreateEducationSchool(t *testing.T) {
@@ -119,7 +119,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: "(&(objectClass=ocEducationSchool)(ocEducationSchoolNumber=0123))",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", schoolNumberSearchRequest).
@@ -133,7 +133,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: "(&(objectClass=ocEducationSchool)(ocEducationSchoolNumber=0666))",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", existingSchoolNumberSearchRequest).
@@ -147,7 +147,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: "(&(objectClass=ocEducationSchool)(ocEducationSchoolNumber=1111))",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", schoolNumberSearchRequestError).
@@ -161,7 +161,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 0,
SizeLimit: 1,
Filter: "(objectClass=ocEducationSchool)",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", schoolLookupAfterCreate).
@@ -347,7 +347,7 @@ func TestDeleteEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: tt.filter,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
if tt.expectedItemNotFound {
@@ -416,7 +416,7 @@ func TestGetEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: tt.filter,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
if tt.expectedItemNotFound {
@@ -450,7 +450,7 @@ func TestGetEducationSchools(t *testing.T) {
Scope: 2,
SizeLimit: 0,
Filter: "(objectClass=ocEducationSchool)",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", sr1).Return(&ldap.SearchResult{Entries: []*ldap.Entry{schoolEntry, schoolEntry1}}, nil)
@@ -467,7 +467,7 @@ var schoolByIDSearch1 *ldap.SearchRequest = &ldap.SearchRequest{
Scope: 2,
SizeLimit: 1,
Filter: filterSchoolSearchByIdExisting,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
@@ -476,7 +476,7 @@ var schoolByNumberSearch *ldap.SearchRequest = &ldap.SearchRequest{
Scope: 2,
SizeLimit: 1,
Filter: filterSchoolSearchByNumberExisting,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
@@ -377,7 +377,7 @@ func TestCreateGroupSynthesizesWhenNotServerUUID(t *testing.T) {
// synthesized entry must carry the id under that attribute for the model builder.
c := lconfig
c.UseServerUUID = false
c.GroupIDAttribute = "owncloudUUID"
c.GroupIDAttribute = "ownCloudUUID"
var written *ldap.AddRequest
l := &mocks.Client{}
@@ -446,7 +446,7 @@ func TestCreateEducationClassSynthesizesWhenNotServerUUID(t *testing.T) {
c := eduConfig
c.UseServerUUID = false
c.GroupIDAttribute = "owncloudUUID"
c.GroupIDAttribute = "ownCloudUUID"
var written *ldap.AddRequest
l := &mocks.Client{}
@@ -603,7 +603,7 @@ func TestUpdateEducationSchoolFoldsNoReadBack(t *testing.T) {
preRead := ldap.NewEntry("ou=Test School", map[string][]string{
"ou": {"Test School"},
"ocEducationSchoolNumber": {"0123"},
"owncloudUUID": {"abcd-defg"},
"ownCloudUUID": {"abcd-defg"},
})
l := &mocks.Client{}
@@ -668,7 +668,7 @@ func TestUpdateEducationClassFoldPreservesClassificationAndExternalID(t *testing
}
// TestCreateGroupSynthesizesWithNonDefaultIDAttribute guards the fix for the
// hardcoded "owncloudUUID" id write: the generated id must be stored under 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) {
@@ -676,7 +676,7 @@ func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
c := lconfig
c.UseServerUUID = false
c.GroupIDAttribute = "entryUUID" // non-default: previously the id was written to owncloudUUID only
c.GroupIDAttribute = "entryUUID" // non-default: previously the id was written to ownCloudUUID only
var written *ldap.AddRequest
l := &mocks.Client{}
@@ -697,7 +697,7 @@ func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
// 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"
// the AddRequest carries the id under the configured attribute, not "ownCloudUUID"
var idFromConfigured, idFromHardcoded string
for _, a := range written.Attributes {
switch a.Type {
@@ -705,14 +705,14 @@ func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
if len(a.Vals) > 0 {
idFromConfigured = a.Vals[0]
}
case "owncloudUUID":
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.Empty(t, idFromHardcoded, "id must not be written under a hardcoded ownCloudUUID")
assert.Equal(t, idFromConfigured, newGroup.GetId())
l.AssertNotCalled(t, "Search", mock.Anything)
}
@@ -68,10 +68,10 @@ var _ = Describe("Users changing their own password", func() {
UserDisplayNameAttribute: "displayName",
UserNameAttribute: "uid",
UserEmailAttribute: "mail",
UserIDAttribute: "ownclouduuid",
UserIDAttribute: "ownCloudUUID",
UserSearchScope: "sub",
GroupNameAttribute: "cn",
GroupIDAttribute: "ownclouduuid",
GroupIDAttribute: "ownCloudUUID",
GroupSearchScope: "sub",
}
loggger := log.NewLogger()
+57 -39
View File
@@ -9,8 +9,14 @@ import (
settingsmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/settings/v0"
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
"github.com/owncloud/reva/v2/pkg/permission"
"golang.org/x/sync/errgroup"
)
// maxConcurrentVaultEligibilityChecks bounds how many per-user role assignment lookups
// applyFilterVaultEligible runs at once, so a large search result doesn't fan out into an
// unbounded number of concurrent settings service calls.
const maxConcurrentVaultEligibilityChecks = 10
const (
appRoleID = "appRoleId"
appRoleAssignments = "appRoleAssignments"
@@ -259,64 +265,76 @@ func (g Graph) applyFilterEq(ctx context.Context, req *godata.GoDataRequest, ope
// applyFilterVaultEligible resolves `vaultEligible eq true`, the filter the share recipient
// picker sends while sharing a vault resource. Only `true` is accepted: enumerating the users
// who may not enter the vault is not a use case the picker has.
//
// Eligibility is checked only for the users the directory search actually returned, not for
// every account in the system: the search runs first, and a per-user role assignment lookup
// follows only for the (usually few) users it matched. This keeps the cost proportional to the
// search result instead of the number of accounts in the whole deployment.
func (g Graph) applyFilterVaultEligible(ctx context.Context, req *godata.GoDataRequest, operand *godata.ParseNode) ([]*libregraph.User, error) {
if operand.Token.Type != godata.ExpressionTokenBoolean || operand.Token.Value != "true" {
return nil, unsupportedFilterError()
}
// This is the share recipient search, and clients only send it once a few characters have
// been typed (FRONTEND_SEARCH_MIN_LENGTH). We therefore expect a handful of matching users here,
// not the whole directory, which is what makes checking each of them individually below cheap.
users, err := g.identityBackend.GetUsers(ctx, req)
if err != nil {
return nil, err
}
eligible, err := g.vaultEligibleAccountIDs(ctx)
if err != nil {
return nil, err
if len(users) == 0 {
return users, nil
}
filteredUsers := make([]*libregraph.User, 0, len(users))
for _, user := range users {
if _, ok := eligible[user.GetId()]; ok {
filteredUsers = append(filteredUsers, user)
}
}
return filteredUsers, nil
}
// vaultEligibleAccountIDs returns the accounts holding the vault mode permission, found by
// inverting the assignments of every role that grants it. That is one call per granting role,
// rather than one permission check per user the search returned.
func (g Graph) vaultEligibleAccountIDs(ctx context.Context) (map[string]struct{}, error) {
roles, err := g.roleService.ListRoles(ctx, &settingssvc.ListBundlesRequest{})
if err != nil {
return nil, err
}
accounts := make(map[string]struct{})
vaultGrantingRoles := make(map[string]struct{})
for _, role := range roles.GetBundles() {
if !roleGrantsVaultMode(role) {
continue
}
assignments, err := g.roleService.ListRoleAssignmentsFiltered(
ctx,
&settingssvc.ListRoleAssignmentsFilteredRequest{
Filters: []*settingsmsg.UserRoleAssignmentFilter{
{
Type: settingsmsg.UserRoleAssignmentFilter_TYPE_ROLE,
Term: &settingsmsg.UserRoleAssignmentFilter_RoleId{RoleId: role.GetId()},
},
},
},
)
if err != nil {
return nil, err
}
for _, assignment := range assignments.GetAssignments() {
accounts[assignment.GetAccountUuid()] = struct{}{}
if roleGrantsVaultMode(role) {
vaultGrantingRoles[role.GetId()] = struct{}{}
}
}
return accounts, nil
if len(vaultGrantingRoles) == 0 {
return []*libregraph.User{}, nil
}
// eligible preserves the directory search's order: each slot is written at most once, by
// the goroutine checking that same index, so concurrent execution cannot reorder the result.
eligible := make([]bool, len(users))
eg, egCtx := errgroup.WithContext(ctx)
eg.SetLimit(maxConcurrentVaultEligibilityChecks)
for i, user := range users {
eg.Go(func() error {
assignments, err := g.roleService.ListRoleAssignments(egCtx, &settingssvc.ListRoleAssignmentsRequest{
AccountUuid: user.GetId(),
})
if err != nil {
return err
}
for _, assignment := range assignments.GetAssignments() {
if _, ok := vaultGrantingRoles[assignment.GetRoleId()]; ok {
eligible[i] = true
break
}
}
return nil
})
}
if err := eg.Wait(); err != nil {
return nil, err
}
filteredUsers := make([]*libregraph.User, 0, len(users))
for i, user := range users {
if eligible[i] {
filteredUsers = append(filteredUsers, user)
}
}
return filteredUsers, nil
}
// roleGrantsVaultMode reports whether a role bundle carries the vault mode permission.
+137 -39
View File
@@ -707,6 +707,7 @@ var _ = Describe("Users", func() {
vaultLessRole = "ordinary-role-ID"
eligibleUser = "25cb7bc0-3168-4a0c-adbe-396f478ad494"
otherUser = "2713f1d5-6822-42bd-ad56-9f6c55a3a8fa"
thirdUser = "3a6e6e0e-3f8b-4e3e-9f8b-1a2b3c4d5e6f"
)
// expectRoles makes the settings service report both roles, only one of which
@@ -738,6 +739,32 @@ var _ = Describe("Users", func() {
}, nil)
}
// expectAssignments stubs ListRoleAssignments (the per-account assignment lookup)
// for a single account.
expectAssignments := func(accountUUID string, assignments []*settingsmsg.UserRoleAssignment, err error) {
roleService.On("ListRoleAssignments", mock.Anything, mock.MatchedBy(
func(in *settings.ListRoleAssignmentsRequest) bool {
return in.GetAccountUuid() == accountUUID
}), mock.Anything).Return(&settings.ListRoleAssignmentsResponse{Assignments: assignments}, err)
}
// requestVaultEligibleUsers builds a GetUsers request for filter, executes it against
// svc, and unmarshals a successful response body into a userList. It fails the test
// if the response isn't 200.
requestVaultEligibleUsers := func(filter string) userList {
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/users?$filter="+url.QueryEscape(filter), nil)
r = r.WithContext(revactx.SetMFA(r.Context()))
svc.GetUsers(rr, r)
Expect(rr.Code).To(Equal(http.StatusOK))
data, err := io.ReadAll(rr.Body)
Expect(err).ToNot(HaveOccurred())
res := userList{}
Expect(json.Unmarshal(data, &res)).To(Succeed())
return res
}
BeforeEach(func() {
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settings.GetPermissionByIDResponse{
Permission: &settingsmsg.Permission{
@@ -756,55 +783,63 @@ var _ = Describe("Users", func() {
DescribeTable("returns only the users assigned to a role that grants vault mode",
func(filter string) {
expectRoles()
// Only the assignments of the vault granting role may be asked for, and only
// the eligible user holds one.
roleService.On("ListRoleAssignmentsFiltered", mock.Anything, mock.MatchedBy(
func(in *settings.ListRoleAssignmentsFilteredRequest) bool {
return in.GetFilters()[0].GetRoleId() == vaultRole
}), mock.Anything).Return(&settings.ListRoleAssignmentsResponse{
Assignments: []*settingsmsg.UserRoleAssignment{
{Id: "assignment-ID", AccountUuid: eligibleUser, RoleId: vaultRole},
},
// Only the eligible user's own assignments hold the vault-granting role;
// the other user holds a role that doesn't grant it.
expectAssignments(eligibleUser, []*settingsmsg.UserRoleAssignment{
{Id: "assignment-ID", AccountUuid: eligibleUser, RoleId: vaultRole},
}, nil)
expectAssignments(otherUser, []*settingsmsg.UserRoleAssignment{
{Id: "other-assignment-ID", AccountUuid: otherUser, RoleId: vaultLessRole},
}, nil)
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/users?$filter="+url.QueryEscape(filter), nil)
r = r.WithContext(revactx.SetMFA(r.Context()))
svc.GetUsers(rr, r)
Expect(rr.Code).To(Equal(http.StatusOK))
data, err := io.ReadAll(rr.Body)
Expect(err).ToNot(HaveOccurred())
res := userList{}
Expect(json.Unmarshal(data, &res)).To(Succeed())
res := requestVaultEligibleUsers(filter)
Expect(res.Value).To(HaveLen(1))
Expect(res.Value[0].GetId()).To(Equal(eligibleUser))
roleService.AssertNotCalled(GinkgoT(), "ListRoleAssignmentsFiltered", mock.Anything, mock.Anything, mock.Anything)
},
Entry("plain", "vaultEligible eq true"),
Entry("parenthesized", "(vaultEligible eq true)"),
)
It("returns nobody when no role grants vault mode", func() {
It("drops a user with no role assignments at all, as a normal (non-error) outcome", func() {
expectRoles()
expectAssignments(eligibleUser, []*settingsmsg.UserRoleAssignment{
{Id: "assignment-ID", AccountUuid: eligibleUser, RoleId: vaultRole},
}, nil)
expectAssignments(otherUser, nil, nil)
res := requestVaultEligibleUsers("vaultEligible eq true")
Expect(res.Value).To(HaveLen(1))
Expect(res.Value[0].GetId()).To(Equal(eligibleUser))
})
It("returns nobody when no role grants vault mode, without listing anyone's assignments", func() {
roleService.On("ListRoles", mock.Anything, mock.Anything, mock.Anything).Return(&settings.ListBundlesResponse{
Bundles: []*settingsmsg.Bundle{{Id: vaultLessRole, Type: settingsmsg.Bundle_TYPE_ROLE}},
}, nil)
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/users?$filter="+url.QueryEscape("vaultEligible eq true"), nil)
r = r.WithContext(revactx.SetMFA(r.Context()))
svc.GetUsers(rr, r)
Expect(rr.Code).To(Equal(http.StatusOK))
data, err := io.ReadAll(rr.Body)
Expect(err).ToNot(HaveOccurred())
res := userList{}
Expect(json.Unmarshal(data, &res)).To(Succeed())
res := requestVaultEligibleUsers("vaultEligible eq true")
Expect(res.Value).To(BeEmpty())
roleService.AssertNotCalled(GinkgoT(), "ListRoleAssignments", mock.Anything, mock.Anything, mock.Anything)
roleService.AssertNotCalled(GinkgoT(), "ListRoleAssignmentsFiltered", mock.Anything, mock.Anything, mock.Anything)
})
It("fails the request when the role assignments cannot be listed", func() {
expectRoles()
roleService.On("ListRoleAssignmentsFiltered", mock.Anything, mock.Anything, mock.Anything).
It("makes no calls to the role service when the directory search returns no users", func() {
identityBackend.On("GetUsers", mock.Anything, mock.Anything).Unset()
identityBackend.On("GetUsers", mock.Anything, mock.Anything).Return([]*libregraph.User{}, nil)
res := requestVaultEligibleUsers("vaultEligible eq true")
Expect(res.Value).To(BeEmpty())
roleService.AssertNotCalled(GinkgoT(), "ListRoles", mock.Anything, mock.Anything, mock.Anything)
roleService.AssertNotCalled(GinkgoT(), "ListRoleAssignments", mock.Anything, mock.Anything, mock.Anything)
roleService.AssertNotCalled(GinkgoT(), "ListRoleAssignmentsFiltered", mock.Anything, mock.Anything, mock.Anything)
})
It("fails the request when the role list cannot be fetched", func() {
roleService.On("ListRoles", mock.Anything, mock.Anything, mock.Anything).
Return(nil, errors.New("settings service unavailable"))
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/users?$filter="+url.QueryEscape("vaultEligible eq true"), nil)
@@ -814,6 +849,71 @@ var _ = Describe("Users", func() {
Expect(rr.Code).ToNot(Equal(http.StatusOK))
})
It("fails the request when a per-user role assignment check fails", func() {
expectRoles()
expectAssignments(eligibleUser, []*settingsmsg.UserRoleAssignment{
{Id: "assignment-ID", AccountUuid: eligibleUser, RoleId: vaultRole},
}, nil)
expectAssignments(otherUser, nil, errors.New("settings service unavailable"))
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/users?$filter="+url.QueryEscape("vaultEligible eq true"), nil)
r = r.WithContext(revactx.SetMFA(r.Context()))
svc.GetUsers(rr, r)
Expect(rr.Code).ToNot(Equal(http.StatusOK))
})
It("preserves the directory search's original order under concurrent completion, dropping a middle ineligible user", func() {
identityBackend.On("GetUsers", mock.Anything, mock.Anything).Unset()
first := &libregraph.User{}
first.SetId(thirdUser)
second := &libregraph.User{}
second.SetId(eligibleUser)
third := &libregraph.User{}
third.SetId(otherUser)
// Deliberately not alphabetical/sorted, so that a concurrency bug that
// reorders results would be caught.
identityBackend.On("GetUsers", mock.Anything, mock.Anything).Return([]*libregraph.User{first, second, third}, nil)
expectRoles()
// Force the first user's lookup to finish last: it blocks on lastDone, which the
// last user's lookup closes only after it has already returned. Since SetLimit
// is 10, all three per-user goroutines run concurrently (the middle and last
// lookups aren't blocked waiting on the first), so this reliably makes completion
// order (third, second, first) the reverse of directory order (first, second,
// third) without any sleeps.
lastDone := make(chan struct{})
roleService.On("ListRoleAssignments", mock.Anything, mock.MatchedBy(
func(in *settings.ListRoleAssignmentsRequest) bool {
return in.GetAccountUuid() == thirdUser
}), mock.Anything).Run(func(mock.Arguments) {
<-lastDone
}).Return(&settings.ListRoleAssignmentsResponse{Assignments: []*settingsmsg.UserRoleAssignment{
{Id: "assignment-1", AccountUuid: thirdUser, RoleId: vaultRole},
}}, nil)
// The middle user holds no vault-granting role, so it must be dropped from the
// result rather than just reordered.
expectAssignments(eligibleUser, []*settingsmsg.UserRoleAssignment{
{Id: "assignment-2", AccountUuid: eligibleUser, RoleId: vaultLessRole},
}, nil)
roleService.On("ListRoleAssignments", mock.Anything, mock.MatchedBy(
func(in *settings.ListRoleAssignmentsRequest) bool {
return in.GetAccountUuid() == otherUser
}), mock.Anything).Run(func(mock.Arguments) {
close(lastDone)
}).Return(&settings.ListRoleAssignmentsResponse{Assignments: []*settingsmsg.UserRoleAssignment{
{Id: "assignment-3", AccountUuid: otherUser, RoleId: vaultRole},
}}, nil)
res := requestVaultEligibleUsers("vaultEligible eq true")
Expect(res.Value).To(HaveLen(2))
Expect(res.Value[0].GetId()).To(Equal(thirdUser))
Expect(res.Value[1].GetId()).To(Equal(otherUser))
})
DescribeTable("rejects everything but 'eq true'",
func(filter string, status int) {
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/users?$filter="+url.QueryEscape(filter), nil)
@@ -831,12 +931,10 @@ var _ = Describe("Users", func() {
// otherwise restricts unprivileged users to 'userType eq ...'.
It("is allowed for an unprivileged user", func() {
expectRoles()
roleService.On("ListRoleAssignmentsFiltered", mock.Anything, mock.Anything, mock.Anything).
Return(&settings.ListRoleAssignmentsResponse{
Assignments: []*settingsmsg.UserRoleAssignment{
{Id: "assignment-ID", AccountUuid: eligibleUser, RoleId: vaultRole},
},
}, nil)
expectAssignments(eligibleUser, []*settingsmsg.UserRoleAssignment{
{Id: "assignment-ID", AccountUuid: eligibleUser, RoleId: vaultRole},
}, nil)
expectAssignments(otherUser, nil, nil)
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Unset()
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).
Return(&settings.GetPermissionByIDResponse{}, nil)
@@ -59,13 +59,13 @@ func DefaultConfig() *config.Config {
PoolSize: 5,
PoolCheckoutTimeout: 30 * time.Second,
UserSchema: config.LDAPUserSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "displayname",
DisplayName: "displayName",
Username: "uid",
},
GroupSchema: config.LDAPGroupSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "cn",
Groupname: "cn",
@@ -210,7 +210,7 @@ func (b *CS3Backend) DestroySession(_ context.Context, sessionRef *string) error
// for the user specified by the userID.
func (b *CS3Backend) UserClaims(_ string, _ map[string]bool) map[string]interface{} {
return nil
// TODO should we return the "ownclouduuid" as a claim? there is also "LibgreGraph.UUID" / lico.ScopeUniqueUserID
// TODO should we return the "ownCloudUUID" as a claim? there is also "LibgreGraph.UUID" / lico.ScopeUniqueUserID
}
// ScopesSupported implements the Backend interface, providing supported scopes
+10 -1
View File
@@ -7,6 +7,7 @@ import (
"github.com/owncloud/ocis/v2/ocis-pkg/broker"
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
"github.com/owncloud/ocis/v2/ocis-pkg/runner"
ohttp "github.com/owncloud/ocis/v2/ocis-pkg/service/http"
@@ -57,13 +58,21 @@ func Server(cfg *config.Config) *cli.Command {
if err := sharedconf.Decode(sc); err != nil {
logger.Error().Err(err).Msg("error decoding shared config for ocdav")
}
corsAllowCredentials := cfg.HTTP.CORS.AllowCredentials
if corsAllowCredentials && cors.AllowsAnyOrigin(cfg.HTTP.CORS.AllowedOrigins) {
logger.Warn().
Strs("allowed_origins", cfg.HTTP.CORS.AllowedOrigins).
Msg("cors: refusing to allow credentials together with a wildcard origin, disabling allow_credentials")
corsAllowCredentials = false
}
opts := []ocdav.Option{
ocdav.Name(cfg.HTTP.Namespace + "." + cfg.Service.Name),
ocdav.Version(version.GetString()),
ocdav.Context(ctx),
ocdav.Logger(logger.Logger),
ocdav.Address(cfg.HTTP.Addr),
ocdav.AllowCredentials(cfg.HTTP.CORS.AllowCredentials),
ocdav.AllowCredentials(corsAllowCredentials),
ocdav.AllowedMethods(cfg.HTTP.CORS.AllowedMethods),
ocdav.AllowedHeaders(cfg.HTTP.CORS.AllowedHeaders),
ocdav.AllowedOrigins(cfg.HTTP.CORS.AllowedOrigins),
+16 -4
View File
@@ -3,7 +3,9 @@ package revaconfig
import (
"math"
"net/url"
"path/filepath"
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/ocm/pkg/config"
)
@@ -23,6 +25,14 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
providerDomain = u.Host
}
corsAllowCredentials := cfg.HTTP.CORS.AllowCredentials
if corsAllowCredentials && cors.AllowsAnyOrigin(cfg.HTTP.CORS.AllowedOrigins) {
logger.Warn().
Strs("allowed_origins", cfg.HTTP.CORS.AllowedOrigins).
Msg("cors: refusing to allow credentials together with a wildcard origin, disabling allow_credentials")
corsAllowCredentials = false
}
return map[string]interface{}{
"shared": map[string]interface{}{
"jwt_secret": cfg.TokenManager.JWTSecret,
@@ -37,7 +47,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
"allowed_origins": cfg.HTTP.CORS.AllowedOrigins,
"allowed_methods": cfg.HTTP.CORS.AllowedMethods,
"allowed_headers": cfg.HTTP.CORS.AllowedHeaders,
"allow_credentials": cfg.HTTP.CORS.AllowCredentials,
"allow_credentials": corsAllowCredentials,
// currently unused
//"options_passthrough": ,
//"debug": ,
@@ -91,8 +101,9 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
"service_account_secret": cfg.ServiceAccount.Secret,
},
"dataprovider": map[string]interface{}{
"prefix": "data",
"driver": "ocmreceived",
"prefix": "data",
"driver": "ocmreceived",
"upload_directory": filepath.Join(cfg.OCMStorageProvider.StorageRoot, "uploads"),
"drivers": map[string]interface{}{
"ocmreceived": map[string]interface{}{
"insecure": cfg.OCMStorageProvider.Insecure,
@@ -181,7 +192,8 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
},
},
"storageprovider": map[string]interface{}{
"driver": "ocmreceived",
"driver": "ocmreceived",
"upload_directory": filepath.Join(cfg.OCMStorageProvider.StorageRoot, "uploads"),
"drivers": map[string]interface{}{
"ocmreceived": map[string]interface{}{
"insecure": cfg.OCMStorageProvider.Insecure,
+7 -7
View File
@@ -18,21 +18,21 @@ type AppAuthAuthenticator struct {
}
// Authenticate implements the authenticator interface to authenticate requests via app auth.
func (m AppAuthAuthenticator) Authenticate(r *http.Request) (*http.Request, bool) {
func (m AppAuthAuthenticator) Authenticate(r *http.Request) (*http.Request, error) {
if isPublicPath(r.URL.Path) {
// The authentication of public path requests is handled by another authenticator.
// Since we can't guarantee the order of execution of the authenticators, we better
// implement an early return here for paths we can't authenticate in this authenticator.
return nil, false
return nil, ErrAuthenticationFailed
}
username, password, ok := r.BasicAuth()
if !ok {
return nil, false
return nil, ErrAuthenticationFailed
}
next, err := m.RevaGatewaySelector.Next()
if err != nil {
return nil, false
return nil, ErrAuthenticationFailed
}
authenticateResponse, err := next.Authenticate(r.Context(), &gateway.AuthenticateRequest{
@@ -41,11 +41,11 @@ func (m AppAuthAuthenticator) Authenticate(r *http.Request) (*http.Request, bool
ClientSecret: password,
})
if err != nil {
return nil, false
return nil, ErrAuthenticationFailed
}
if authenticateResponse.GetStatus().GetCode() != cs3rpc.Code_CODE_OK {
// TODO: log???
return nil, false
return nil, ErrAuthenticationFailed
}
r.Header.Set(revactx.TokenHeader, authenticateResponse.GetToken())
@@ -60,5 +60,5 @@ func (m AppAuthAuthenticator) Authenticate(r *http.Request) (*http.Request, bool
}
r = r.WithContext(oidc.NewContext(r.Context(), claims))
return r, true
return r, nil
}
@@ -62,9 +62,9 @@ var _ = Describe("Authenticating requests", Label("AppAuthAuthenticator"), func(
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("test-user", "AppPassword")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
Expect(req2.Header.Get("x-access-token")).To(Equal("reva-token"))
@@ -82,9 +82,9 @@ var _ = Describe("Authenticating requests", Label("AppAuthAuthenticator"), func(
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("test-user", "WrongAppPassword")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(false))
Expect(err).To(HaveOccurred())
Expect(req2).To(BeNil())
})
})
@@ -1,18 +1,23 @@
package middleware
import (
"errors"
"fmt"
"io"
"net/http"
"regexp"
"strings"
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
"github.com/owncloud/ocis/v2/services/proxy/pkg/router"
"github.com/owncloud/ocis/v2/services/proxy/pkg/webdav"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// ErrAuthenticationFailed maps to an HTTP 401 challenge.
var ErrAuthenticationFailed = errors.New("authentication failed")
var (
// SupportedAuthStrategies stores configured challenges.
SupportedAuthStrategies []string
@@ -42,10 +47,10 @@ const (
// Authenticator is the common interface implemented by all request authenticators.
type Authenticator interface {
// Authenticate is used to authenticate incoming HTTP requests.
// The Authenticator may augment the request with user info or anything related to the
// authentication and return the augmented request.
Authenticate(*http.Request) (*http.Request, bool)
// Authenticate authenticates incoming HTTP requests, returning the augmented request.
// nil error means authenticated; ErrAuthenticationFailed (or an unhandled request) maps
// to 401; an error wrapping oidc.ErrTemporarilyUnavailable maps to a retryable 503.
Authenticate(*http.Request) (*http.Request, error)
}
// Authentication is a higher order authentication middleware.
@@ -65,12 +70,24 @@ func Authentication(auths []Authenticator, opts ...Option) func(next http.Handle
return
}
var temporarilyUnavailable bool
for _, a := range auths {
if req, ok := a.Authenticate(r); ok {
req, err := a.Authenticate(r)
if err == nil {
next.ServeHTTP(w, req)
return
}
if errors.Is(err, oidc.ErrTemporarilyUnavailable) {
temporarilyUnavailable = true
}
}
if temporarilyUnavailable {
w.Header().Set("Retry-After", "3")
w.WriteHeader(http.StatusServiceUnavailable)
return
}
if !isPublicPath(r.URL.Path) {
// Failed basic authentication attempts receive the Www-Authenticate header in the response
var touch bool
@@ -2,6 +2,8 @@ package middleware
import (
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"time"
@@ -214,4 +216,127 @@ var _ = Describe("Authenticating requests", Label("Authentication"), func() {
Expect(rr).To(HaveHTTPStatus(http.StatusOK))
})
})
When("the userinfo call to the IdP times out", func() {
It("returns a retryable status, not 401, for a transient backend failure", func() {
logger := log.NewLogger()
timingOutClient := oidcmocks.OIDCClient{}
timingOutClient.On("VerifyAccessToken", mock.Anything, mock.Anything).Return(
oidc.RegClaimsWithSID{
SessionID: "a-session-id",
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Unix(1147483647, 0)),
},
}, jwt.MapClaims{
"sid": "a-session-id",
"exp": 1147483647,
},
nil,
)
// what the oidc client returns for a userinfo timeout
timingOutClient.On("UserInfo", mock.Anything, mock.Anything).Return(
(*oidc.UserInfo)(nil),
errors.Join(oidc.ErrTemporarilyUnavailable,
fmt.Errorf("Get \"http://idp.example.com/userinfo\": %w", context.DeadlineExceeded)),
)
authenticators := []Authenticator{
&OIDCAuthenticator{
OIDCIss: "http://idp.example.com",
Logger: logger,
oidcClient: &timingOutClient,
userInfoCache: store.NewMemoryStore(),
skipUserInfo: false,
},
}
req := httptest.NewRequest(http.MethodGet, "http://example.com/graph/v1.0/me/drives", http.NoBody)
req = req.WithContext(router.SetRoutingInfo(context.Background(), router.RoutingInfo{}))
req.Header.Set(_headerAuthorization, "Bearer jwt.token.sig")
handler := Authentication(authenticators,
EnableBasicAuth(false),
)
testHandler := handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Fail("next handler must not be reached when userinfo times out")
}))
rr := httptest.NewRecorder()
testHandler.ServeHTTP(rr, req)
Expect(rr).To(HaveHTTPStatus(http.StatusServiceUnavailable))
})
It("still returns 401 when userinfo fails without a transient signal", func() {
logger := log.NewLogger()
failingClient := oidcmocks.OIDCClient{}
failingClient.On("VerifyAccessToken", mock.Anything, mock.Anything).Return(
oidc.RegClaimsWithSID{
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Unix(1147483647, 0)),
},
}, jwt.MapClaims{"exp": 1147483647}, nil,
)
failingClient.On("UserInfo", mock.Anything, mock.Anything).Return(
(*oidc.UserInfo)(nil),
fmt.Errorf("401 Unauthorized: token revoked"),
)
authenticators := []Authenticator{
&OIDCAuthenticator{
OIDCIss: "http://idp.example.com",
Logger: logger,
oidcClient: &failingClient,
userInfoCache: store.NewMemoryStore(),
skipUserInfo: false,
},
}
req := httptest.NewRequest(http.MethodGet, "http://example.com/graph/v1.0/me/drives", http.NoBody)
req = req.WithContext(router.SetRoutingInfo(context.Background(), router.RoutingInfo{}))
req.Header.Set(_headerAuthorization, "Bearer jwt.token.sig")
handler := Authentication(authenticators, EnableBasicAuth(false))
testHandler := handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Fail("next handler must not be reached for a failed authentication")
}))
rr := httptest.NewRecorder()
testHandler.ServeHTTP(rr, req)
Expect(rr).To(HaveHTTPStatus(http.StatusUnauthorized))
})
It("returns 401 for an invalid/malformed token", func() {
logger := log.NewLogger()
invalidTokenClient := oidcmocks.OIDCClient{}
invalidTokenClient.On("VerifyAccessToken", mock.Anything, mock.Anything).Return(
oidc.RegClaimsWithSID{}, jwt.MapClaims{}, jwt.ErrTokenMalformed,
)
authenticators := []Authenticator{
&OIDCAuthenticator{
OIDCIss: "http://idp.example.com",
Logger: logger,
oidcClient: &invalidTokenClient,
userInfoCache: store.NewMemoryStore(),
skipUserInfo: true,
},
}
req := httptest.NewRequest(http.MethodGet, "http://example.com/graph/v1.0/me/drives", http.NoBody)
req = req.WithContext(router.SetRoutingInfo(context.Background(), router.RoutingInfo{}))
req.Header.Set(_headerAuthorization, "Bearer invalid.token.sig")
handler := Authentication(authenticators, EnableBasicAuth(false))
testHandler := handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Fail("next handler must not be reached for an invalid token")
}))
rr := httptest.NewRecorder()
testHandler.ServeHTTP(rr, req)
Expect(rr).To(HaveHTTPStatus(http.StatusUnauthorized))
})
})
})
+5 -5
View File
@@ -17,17 +17,17 @@ type BasicAuthenticator struct {
}
// Authenticate implements the authenticator interface to authenticate requests via basic auth.
func (m BasicAuthenticator) Authenticate(r *http.Request) (*http.Request, bool) {
func (m BasicAuthenticator) Authenticate(r *http.Request) (*http.Request, error) {
if isPublicPath(r.URL.Path) && isPublicWithShareToken(r) {
// The authentication of public path requests is handled by another authenticator.
// Since we can't guarantee the order of execution of the authenticators, we better
// implement an early return here for paths we can't authenticate in this authenticator.
return nil, false
return nil, ErrAuthenticationFailed
}
login, password, ok := r.BasicAuth()
if !ok {
return nil, false
return nil, ErrAuthenticationFailed
}
user, _, err := m.UserProvider.Authenticate(r.Context(), login, password)
@@ -37,7 +37,7 @@ func (m BasicAuthenticator) Authenticate(r *http.Request) (*http.Request, bool)
Str("authenticator", "basic").
Str("path", r.URL.Path).
Msg("failed to authenticate request")
return nil, false
return nil, ErrAuthenticationFailed
}
// fake oidc claims
@@ -58,5 +58,5 @@ func (m BasicAuthenticator) Authenticate(r *http.Request) (*http.Request, bool)
Str("authenticator", "basic").
Str("path", r.URL.Path).
Msg("successfully authenticated request")
return r.WithContext(oidc.NewContext(r.Context(), claims)), true
return r.WithContext(oidc.NewContext(r.Context(), claims)), nil
}
@@ -44,17 +44,17 @@ var _ = Describe("Authenticating requests", Label("BasicAuthenticator"), func()
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("testuser", "testpassword")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
})
It("adds claims to the request context", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("testuser", "testpassword")
req2, valid := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
req2, err := authenticator.Authenticate(req)
Expect(err).ToNot(HaveOccurred())
claims := oidc.FromContext(req2.Context())
Expect(claims).ToNot(BeNil())
+8 -5
View File
@@ -178,17 +178,17 @@ func (m OIDCAuthenticator) shouldServe(req *http.Request) bool {
}
// Authenticate implements the authenticator interface to authenticate requests via oidc auth.
func (m *OIDCAuthenticator) Authenticate(r *http.Request) (*http.Request, bool) {
func (m *OIDCAuthenticator) Authenticate(r *http.Request) (*http.Request, error) {
// there is no bearer token on the request,
if !m.shouldServe(r) {
// The authentication of public path requests is handled by another authenticator.
// Since we can't guarantee the order of execution of the authenticators, we better
// implement an early return here for paths we can't authenticate in this authenticator.
return nil, false
return nil, ErrAuthenticationFailed
}
token := strings.TrimPrefix(r.Header.Get(_headerAuthorization), _bearerPrefix)
if token == "" {
return nil, false
return nil, ErrAuthenticationFailed
}
claims, newSession, err := m.getClaims(token, r)
@@ -203,7 +203,10 @@ func (m *OIDCAuthenticator) Authenticate(r *http.Request) (*http.Request, bool)
Str("network.peer.address", host).
Str("network.peer.port", port).
Msg("failed to authenticate the request")
return nil, false
if errors.Is(err, oidc.ErrTemporarilyUnavailable) {
return nil, err
}
return nil, ErrAuthenticationFailed
}
m.Logger.Debug().
Str("authenticator", "oidc").
@@ -215,5 +218,5 @@ func (m *OIDCAuthenticator) Authenticate(r *http.Request) (*http.Request, bool)
ctx = oidc.NewContextSessionFlag(ctx, true)
}
return r.WithContext(oidc.NewContext(ctx, claims)), true
return r.WithContext(oidc.NewContext(ctx, claims)), nil
}
+10 -10
View File
@@ -70,18 +70,18 @@ var _ = Describe("Authenticating requests", Label("OIDCAuthenticator"), func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.Header.Set(_headerAuthorization, "Bearer jwt.token.sig")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
})
It("should successfully authenticate", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/dav/public-files", http.NoBody)
req.Header.Set(_headerAuthorization, "Bearer jwt.token.sig")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
})
It("should skip authenticate if the header ShareToken is set", func() {
@@ -89,24 +89,24 @@ var _ = Describe("Authenticating requests", Label("OIDCAuthenticator"), func() {
req.Header.Set(_headerAuthorization, "Bearer jwt.token.sig")
req.Header.Set(headerShareToken, "sharetoken")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
// TODO Should the authentication of public path requests is handled by another authenticator?
//Expect(valid).To(Equal(false))
//Expect(err).To(HaveOccurred())
//Expect(req2).To(BeNil())
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
})
It("should skip authenticate if the 'public-token' is set", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/dav/public-files/?public-token=sharetoken", http.NoBody)
req.Header.Set(_headerAuthorization, "Bearer jwt.token.sig")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
// TODO Should the authentication of public path requests is handled by another authenticator?
//Expect(valid).To(Equal(false))
//Expect(err).To(HaveOccurred())
//Expect(req2).To(BeNil())
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
})
})
@@ -57,9 +57,9 @@ func isPublicWithShareToken(r *http.Request) bool {
}
// Authenticate implements the authenticator interface to authenticate requests via public share auth.
func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request, bool) {
func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request, error) {
if !isPublicPath(r.URL.Path) && !isPublicShareArchive(r) && !isPublicShareAppOpen(r) {
return nil, false
return nil, ErrAuthenticationFailed
}
query := r.URL.Query()
@@ -71,7 +71,7 @@ func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request,
if shareToken == "" {
// If the share token is not set then we don't need to inject the user to
// the request context so we can just continue with the request.
return r, true
return r, nil
}
var sharePassword string
@@ -81,7 +81,7 @@ func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request,
expiration := query.Get(_paramExpiration)
if expiration == "" {
a.Logger.Warn().Str("signature", signature).Msg("cannot do signature auth without the expiration")
return nil, false
return nil, ErrAuthenticationFailed
}
sharePassword = strings.Join([]string{"signature", signature, expiration}, "|")
} else {
@@ -102,7 +102,7 @@ func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request,
Str("public_share_token", shareToken).
Str("path", r.URL.Path).
Msg("could not select next gateway client")
return nil, false
return nil, ErrAuthenticationFailed
}
// The brute force protection counts failed public link password attempts.
@@ -129,7 +129,7 @@ func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request,
Str("public_share_token", shareToken).
Str("path", r.URL.Path).
Msg("failed to authenticate request")
return nil, false
return nil, ErrAuthenticationFailed
}
r.Header.Add(_headerRevaAccessToken, authResp.Token)
@@ -138,5 +138,5 @@ func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request,
Str("authenticator", "public_share").
Str("path", r.URL.Path).
Msg("successfully authenticated request")
return r, true
return r, nil
}
@@ -63,9 +63,9 @@ var _ = Describe("Authenticating requests", Label("PublicShareAuthenticator"), f
req := httptest.NewRequest(http.MethodGet, "http://example.com/dav/public-files/?public-token=sharetoken", http.NoBody)
req.SetBasicAuth("public", "examples3cr3t")
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
h := req2.Header
@@ -76,9 +76,9 @@ var _ = Describe("Authenticating requests", Label("PublicShareAuthenticator"), f
It("should successfully authenticate", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/dav/public-files/?public-token=sharetoken&signature=examplesignature&expiration=exampleexpiration", http.NoBody)
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
h := req2.Header
@@ -90,9 +90,9 @@ var _ = Describe("Authenticating requests", Label("PublicShareAuthenticator"), f
Context("using a public-token", func() {
It("should successfully authenticate", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/archiver?public-token=sharetoken", http.NoBody)
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(true))
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
h := req2.Header
@@ -102,9 +102,9 @@ var _ = Describe("Authenticating requests", Label("PublicShareAuthenticator"), f
Context("not using a public-token", func() {
It("should fail to authenticate", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/archiver", http.NoBody)
req2, valid := authenticator.Authenticate(req)
req2, err := authenticator.Authenticate(req)
Expect(valid).To(Equal(false))
Expect(err).To(HaveOccurred())
Expect(req2).To(BeNil())
})
})
@@ -219,9 +219,9 @@ func (m SignedURLAuthenticator) createSignature(url string, signingKey []byte) s
}
// Authenticate implements the authenticator interface to authenticate requests via signed URL auth.
func (m SignedURLAuthenticator) Authenticate(r *http.Request) (*http.Request, bool) {
func (m SignedURLAuthenticator) Authenticate(r *http.Request) (*http.Request, error) {
if !m.shouldServe(r) {
return nil, false
return nil, ErrAuthenticationFailed
}
user, _, err := m.UserProvider.GetUserByClaims(r.Context(), "username", r.URL.Query().Get(_paramOCCredential))
@@ -231,7 +231,7 @@ func (m SignedURLAuthenticator) Authenticate(r *http.Request) (*http.Request, bo
Str("authenticator", "signed_url").
Str("path", r.URL.Path).
Msg("Could not get user by claim")
return nil, false
return nil, ErrAuthenticationFailed
}
user, err = m.UserRoleAssigner.ApplyUserRole(r.Context(), user)
@@ -241,7 +241,7 @@ func (m SignedURLAuthenticator) Authenticate(r *http.Request) (*http.Request, bo
Str("authenticator", "signed_url").
Str("path", r.URL.Path).
Msg("Could not get user by claim")
return nil, false
return nil, ErrAuthenticationFailed
}
ctx := revactx.ContextSetUser(r.Context(), user)
@@ -255,7 +255,7 @@ func (m SignedURLAuthenticator) Authenticate(r *http.Request) (*http.Request, bo
Str("path", r.URL.Path).
Str("url", r.URL.String()).
Msg("Could not get user by claim")
return nil, false
return nil, ErrAuthenticationFailed
}
// TODO: set user in context
@@ -263,5 +263,5 @@ func (m SignedURLAuthenticator) Authenticate(r *http.Request) (*http.Request, bo
Str("authenticator", "signed_url").
Str("path", r.URL.Path).
Msg("successfully authenticated request")
return r, true
return r, nil
}
@@ -5,12 +5,19 @@ import (
"strconv"
"strings"
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
"github.com/owncloud/ocis/v2/ocis-pkg/generators"
"github.com/owncloud/ocis/v2/services/storage-users/pkg/config"
)
// StorageUsersConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
// Credentials must not be combined with a wildcard origin.
corsAllowCredentials := cfg.HTTP.CORS.AllowCredentials
if corsAllowCredentials && cors.AllowsAnyOrigin(cfg.HTTP.CORS.AllowedOrigins) {
corsAllowCredentials = false
}
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"graceful_shutdown_timeout": cfg.GracefulShutdownTimeout,
@@ -80,6 +87,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
"prefix": cfg.HTTP.Prefix,
"driver": cfg.Driver,
"drivers": DataProviderDrivers(cfg),
"mount_id": cfg.MountID,
"nats_address": cfg.Events.Addr,
"nats_clusterID": cfg.Events.ClusterID,
"nats_tls_insecure": cfg.Events.TLSInsecure,
@@ -105,7 +113,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
"cors_enabled": true,
// allow_origin is configured as a regex in tusd, so we concatenate the configured values into a regex
"cors_allow_origin": "(" + strings.ReplaceAll(strings.Join(cfg.HTTP.CORS.AllowedOrigins, "|"), "*", ".*") + ")",
"cors_allow_credentials": cfg.HTTP.CORS.AllowCredentials,
"cors_allow_credentials": corsAllowCredentials,
"cors_allow_methods": strings.Join(cfg.HTTP.CORS.AllowedMethods, ","),
"cors_allow_headers": strings.Join(cfg.HTTP.CORS.AllowedHeaders, ","),
"cors_max_age": strconv.FormatUint(uint64(cfg.HTTP.CORS.MaxAge), 10),
@@ -15,6 +15,7 @@ import (
"strings"
"github.com/pkg/errors"
"golang.org/x/image/bmp"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
"golang.org/x/image/math/fixed"
@@ -178,6 +179,19 @@ Scan: // Label for the scanner loop, so we can break it easily
return img, scanner.Err()
}
// BmpDecoder is a converter for bmp files. BMP bytes must not go through
// libvips, which loads them via ImageMagick, missing on minimal runtimes.
type BmpDecoder struct{}
// Convert reads the bmp file and returns the decoded image
func (b BmpDecoder) Convert(r io.Reader) (interface{}, error) {
img, err := bmp.Decode(r)
if err != nil {
return nil, errors.Wrap(err, `could not decode the bmp image`)
}
return img, nil
}
// GGPStruct is the layout of a ggp file (which is basically json)
type GGPStruct struct {
Sections []struct {
@@ -321,6 +335,10 @@ func ForType(mimeType string, opts map[string]interface{}) FileConverter {
fallthrough
case "audio/ogg":
return AudioDecoder{}
case "image/bmp":
fallthrough
case "image/x-ms-bmp":
return BmpDecoder{}
default:
return ImageDecoder{}
}
@@ -151,6 +151,25 @@ var _ = Describe("ImageDecoder", func() {
})
})
Describe("should decode bmp", func() {
It("should decode a bmp", func() {
fileContent, err := os.ReadFile("test_assets/bmp_test.bmp")
if err != nil {
panic(err)
}
decoder := BmpDecoder{}
img, err := decoder.Convert(bytes.NewReader(fileContent))
Expect(err).ToNot(HaveOccurred())
Expect(img).ToNot(BeNil())
})
It("should return an error if the bmp is invalid", func() {
decoder := BmpDecoder{}
img, err := decoder.Convert(bytes.NewReader([]byte("not a bmp")))
Expect(err).To(HaveOccurred())
Expect(img).To(BeNil())
})
})
Describe("test ForType", func() {
It("should return an ImageDecoder for image types", func() {
decoder := ForType("image/png", nil)
@@ -178,6 +197,16 @@ var _ = Describe("ImageDecoder", func() {
Expect(decoder).To(BeAssignableToTypeOf(TxtToImageConverter{}))
})
It("should return a BmpDecoder for bmp types", func() {
decoder := ForType("image/bmp", nil)
Expect(decoder).To(BeAssignableToTypeOf(BmpDecoder{}))
})
It("should return a BmpDecoder for x-ms-bmp types", func() {
decoder := ForType("image/x-ms-bmp", nil)
Expect(decoder).To(BeAssignableToTypeOf(BmpDecoder{}))
})
It("should return an ImageDecoder for unknown types", func() {
decoder := ForType("unknown", nil)
Expect(decoder).To(BeAssignableToTypeOf(ImageDecoder{}))
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@@ -3,13 +3,11 @@
package thumbnail
import (
"bytes"
"image"
"strings"
"github.com/davidbyttow/govips/v2/vips"
"github.com/owncloud/ocis/v2/services/thumbnails/pkg/errors"
"golang.org/x/image/bmp"
)
// SimpleGenerator is the default image generator and is used for all image types expect gif.
@@ -42,13 +40,10 @@ func (g SimpleGenerator) Generate(size image.Rectangle, img interface{}) (interf
var m *vips.ImageRef
var err error
switch img.(type) {
case *image.RGBA:
// This comes from the txt preprocessor
var buf bytes.Buffer
if err = bmp.Encode(&buf, img.(*image.RGBA)); err != nil {
return nil, err
}
m, err = vips.NewImageFromReader(&buf)
case image.Image:
// Direct import: encoded BMP bytes need the ImageMagick loader,
// missing on minimal runtimes. Covers the txt render and BMP sources.
m, err = vips.NewImageFromGoImage(img.(image.Image))
if err != nil {
return nil, err
}
@@ -72,8 +67,8 @@ func (g SimpleGenerator) Generate(size image.Rectangle, img interface{}) (interf
func (g SimpleGenerator) Dimensions(img interface{}) (image.Rectangle, error) {
switch img.(type) {
case *image.RGBA:
m := img.(*image.RGBA)
case image.Image:
m := img.(image.Image)
return m.Bounds(), nil
case *vips.ImageRef:
m := img.(*vips.ImageRef)
@@ -0,0 +1,88 @@
//go:build enable_vips
package thumbnail
import (
"bytes"
"image"
"image/draw"
"os"
"testing"
"github.com/davidbyttow/govips/v2/vips"
"github.com/owncloud/ocis/v2/services/thumbnails/pkg/preprocessor"
"github.com/stretchr/testify/require"
"golang.org/x/image/bmp"
)
// Start vips once for the package.
func TestMain(m *testing.M) {
if err := vips.Startup(nil); err != nil {
panic(err)
}
os.Exit(m.Run())
}
// Guards the txt-preview path: the preprocessor hands us *image.RGBA and the
// vips generator must import it without any encoded round-trip (BMP bytes
// need the ImageMagick loader, absent from minimal libvips runtimes).
func TestSimpleGenerator_TxtRGBA(t *testing.T) {
src := image.NewRGBA(image.Rect(0, 0, 640, 480))
draw.Draw(src, src.Bounds(), image.White, image.Point{}, draw.Src)
gen, err := NewSimpleGenerator("png", "fit")
require.NoError(t, err)
dims, err := gen.Dimensions(src)
require.NoError(t, err)
require.Equal(t, image.Rect(0, 0, 640, 480), dims)
got, err := gen.Generate(image.Rect(0, 0, 32, 32), src)
require.NoError(t, err)
m, ok := got.(*vips.ImageRef)
require.True(t, ok, "expected *vips.ImageRef, got %T", got)
require.Equal(t, 32, m.Width())
var pngBuf bytes.Buffer
require.NoError(t, PngEncoder{}.Encode(&pngBuf, m))
require.NotEmpty(t, pngBuf.Bytes())
var jpgBuf bytes.Buffer
require.NoError(t, JpegEncoder{}.Encode(&jpgBuf, m))
require.NotEmpty(t, jpgBuf.Bytes())
}
// Guards BMP sources: decoded in Go by BmpDecoder, imported without the
// magick loader that minimal libvips runtimes lack.
func TestSimpleGenerator_BmpSource(t *testing.T) {
src := image.NewRGBA(image.Rect(0, 0, 32, 32))
draw.Draw(src, src.Bounds(), image.White, image.Point{}, draw.Src)
var buf bytes.Buffer
require.NoError(t, bmp.Encode(&buf, src))
img, err := preprocessor.ForType("image/bmp", nil).Convert(&buf)
require.NoError(t, err)
require.NotNil(t, img)
gen, err := NewSimpleGenerator("jpg", "fit")
require.NoError(t, err)
dims, err := gen.Dimensions(img)
require.NoError(t, err)
require.Equal(t, image.Rect(0, 0, 32, 32), dims)
got, err := gen.Generate(image.Rect(0, 0, 32, 32), img)
require.NoError(t, err)
m, ok := got.(*vips.ImageRef)
require.True(t, ok, "expected *vips.ImageRef, got %T", got)
require.Equal(t, 32, m.Width())
var pngBuf bytes.Buffer
require.NoError(t, PngEncoder{}.Encode(&pngBuf, m))
require.NotEmpty(t, pngBuf.Bytes())
var jpgBuf bytes.Buffer
require.NoError(t, JpegEncoder{}.Encode(&jpgBuf, m))
require.NotEmpty(t, jpgBuf.Bytes())
}
@@ -62,14 +62,14 @@ func DefaultConfig() *config.Config {
PoolSize: 5,
PoolCheckoutTimeout: 30 * time.Second,
UserSchema: config.LDAPUserSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "displayname",
DisplayName: "displayName",
Username: "uid",
Enabled: "ownCloudUserEnabled",
},
GroupSchema: config.LDAPGroupSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "cn",
Groupname: "cn",
@@ -95,7 +95,7 @@
"swatch-danger-contrast": "#ffffff",
"swatch-danger-default": "rgb(197, 48, 48)",
"swatch-danger-hover": "#b12b2b",
"swatch-danger-muted": "rgb(204, 117, 117)",
"swatch-danger-muted": "rgb(180, 90, 90)",
"swatch-inverse-default": "#ffffff",
"swatch-inverse-hover": "#ffffff",
"swatch-inverse-muted": "#bfbfbf",
@@ -197,7 +197,7 @@
"swatch-danger-contrast": "#ffffff",
"swatch-danger-default": "rgb(197, 48, 48)",
"swatch-danger-hover": "#b12b2b",
"swatch-danger-muted": "rgb(204, 117, 117)",
"swatch-danger-muted": "rgb(180, 90, 90)",
"swatch-inverse-default": "#000000",
"swatch-inverse-hover": "#555555",
"swatch-inverse-muted": "#bfbfbf",
@@ -508,8 +508,8 @@
"swatch-danger-contrast": "#ffffff",
"swatch-danger-default": "rgb(197, 48, 48)",
"swatch-danger-hover": "#b12b2b",
"swatch-danger-muted": "rgb(204, 117, 117)",
"swatch-inverse-default": "#ffffff",
"swatch-danger-muted": "rgb(180, 90, 90)",
"swatch-inverse-default": "#000000",
"swatch-inverse-hover": "#ffffff",
"swatch-inverse-muted": "#bfbfbf",
"swatch-passive-default": "#000000",
@@ -611,7 +611,7 @@
"swatch-danger-contrast": "#ffffff",
"swatch-danger-default": "rgb(197, 48, 48)",
"swatch-danger-hover": "#b12b2b",
"swatch-danger-muted": "rgb(204, 117, 117)",
"swatch-danger-muted": "rgb(180, 90, 90)",
"swatch-inverse-default": "#000000",
"swatch-inverse-hover": "#555555",
"swatch-inverse-muted": "#bfbfbf",
@@ -716,8 +716,8 @@
"swatch-inverse-hover": "",
"swatch-inverse-muted": "#696969",
"swatch-passive-default": "#F0AA39",
"swatch-passive-hover": "#CA912B",
"swatch-passive-hover-outline": "#CA912B",
"swatch-passive-hover": "#D49B35",
"swatch-passive-hover-outline": "#D49B35",
"swatch-passive-muted": "#bdbfc3",
"swatch-passive-contrast": "#000000",
"swatch-primary-default": "#F0AA39",
@@ -821,7 +821,7 @@
"swatch-brand-default": "#F0AA39",
"swatch-brand-hover": "#CA912B",
"swatch-brand-contrast": "#000000",
"swatch-inverse-default": "",
"swatch-inverse-default": "#000000",
"swatch-inverse-hover": "",
"swatch-inverse-muted": "#f8f8f8",
"swatch-passive-default": "#ffffff",
@@ -204,6 +204,10 @@ class HttpRequestHelper {
* @param int|null $timeout
* @param Client|null $client
* @param bool|null $isGivenStep
* @param bool $retryOn5xxForK8s Set to false when the caller already has its own
* retry-on-5xx loop (e.g. SearchContext::searchWithRetry),
* so this generic layer doesn't redundantly burn extra
* time retrying inside every one of the caller's attempts.
*
* @return ResponseInterface
*
@@ -223,6 +227,7 @@ class HttpRequestHelper {
?int $timeout = 0,
?Client $client = null,
?bool $isGivenStep = false,
bool $retryOn5xxForK8s = true,
): ResponseInterface {
if ((\getenv('DEBUG_ACCEPTANCE_RESPONSES') !== false) || (\getenv('DEBUG_ACCEPTANCE_API_CALLS') !== false)) {
$debugResponses = true;
@@ -270,7 +275,7 @@ class HttpRequestHelper {
$loopAgain = !$sendExceptionHappened && ($response->getStatusCode() === self::HTTP_TOO_EARLY ||
($response->getStatusCode() === self::HTTP_CONFLICT && $isGivenStep)) &&
$sendCount <= $sendRetryLimit;
if (OcisConfigHelper::isK8s()) {
if ($retryOn5xxForK8s && OcisConfigHelper::isK8s()) {
$loopAgain = $loopAgain || ($response->getStatusCode() >= HttpResponse::HTTP_INTERNAL_SERVER_ERROR &&
$sendCount <= $sendRetryLimit
&& $response->getStatusCode() !== HttpResponse::HTTP_INSUFFICIENT_STORAGE);
+49 -1
View File
@@ -324,6 +324,24 @@ class ArchiverContext implements Context {
];
}
/**
* @var array
*/
private array $publicLinkArchiveData = [];
/**
* @param string $password
*
* @return array
* @throws GuzzleException
*/
private function getPublicLinkArchiveData(string $password): array {
if ($this->publicLinkArchiveData === []) {
$this->publicLinkArchiveData = $this->fetchPublicLinkArchiveData($password);
}
return $this->publicLinkArchiveData;
}
/**
* @When /^the public downloads the archive of the last created public link with password "([^"]*)"$/
*
@@ -334,7 +352,7 @@ class ArchiverContext implements Context {
* @throws GuzzleException|Exception
*/
public function publicDownloadsTheArchiveOfTheLastCreatedPublicLink(string $password = ""): void {
$data = $this->fetchPublicLinkArchiveData($password);
$data = $this->getPublicLinkArchiveData($password);
$fileIds = $data['fileIds'];
$signature = $data['signature'];
$expiration = $data['expiration'];
@@ -360,6 +378,36 @@ class ArchiverContext implements Context {
);
}
/**
* @When the public downloads the archive of the last created public link with incorrect password :password
*
* @param string $password
*
* @return void
* @throws GuzzleException
*/
public function publicDownloadsTheArchiveOfTheLastCreatedPublicLinkUsingBasicAuth(string $password): void {
$data = $this->getPublicLinkArchiveData('%public%');
$fileIds = $data['fileIds'];
$token = $this->featureContext->isUsingSharingNG()
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$queryParts = ['public-token=' . urlencode($token)];
foreach ($fileIds as $fileId) {
$queryParts[] = "id=" . urlencode($fileId);
}
$this->featureContext->setResponse(
HttpRequestHelper::get(
$this->getArchiverUrl(\implode('&', $queryParts)),
'public',
$password,
),
);
}
/**
* @Then the downloaded :type archive should contain these files:
*
+49 -15
View File
@@ -1328,6 +1328,30 @@ class FeatureContext extends BehatVariablesContext {
$this->setResponse($this->sendingToWithDirectUrl($user, $verb, $endpoint));
}
/**
* @param string $method
* @param string $url
* @param string $password
*
* @return ResponseInterface
* @throws GuzzleException
*/
private function sendHttpMethodToUrlWithPassword(string $method, string $url, string $password): ResponseInterface {
$password = $this->getActualPassword($password);
$token = $this->shareNgGetLastCreatedLinkShareToken();
$fullUrl = $this->getBaseUrl() . $url;
$headers = [
'Public-Token' => $token,
];
return HttpRequestHelper::sendRequest(
$fullUrl,
$method,
"public",
$password,
$headers,
);
}
/**
* @When the public sends HTTP method :method to URL :url with password :password
*
@@ -1336,23 +1360,33 @@ class FeatureContext extends BehatVariablesContext {
* @param string $password
*
* @return void
* @throws GuzzleException
*/
public function thePublicSendsHttpMethodToUrlWithPassword(string $method, string $url, string $password): void {
$password = $this->getActualPassword($password);
$token = $this->shareNgGetLastCreatedLinkShareToken();
$fullUrl = $this->getBaseUrl() . $url;
$headers = [
'Public-Token' => $token,
];
$this->setResponse(
HttpRequestHelper::sendRequest(
$fullUrl,
$method,
"public",
$password,
$headers,
),
);
$this->setResponse($this->sendHttpMethodToUrlWithPassword($method, $url, $password));
}
/**
* @When the public sends HTTP method :method to URL :url with password :password for :attempts times
*
* @param string $method
* @param string $url
* @param string $password
* @param int $attempts
*
* @return void
* @throws GuzzleException
*/
public function thePublicSendsHttpMethodToUrlWithPasswordForTimes(
string $method,
string $url,
string $password,
int $attempts,
): void {
for ($i = 0; $i < $attempts; $i++) {
$this->setResponse($this->sendHttpMethodToUrlWithPassword($method, $url, $password));
$this->pushToLastHttpStatusCodesArray();
}
}
/**
@@ -213,6 +213,9 @@ class SearchContext implements Context {
$password,
$headers,
$body,
// this method's own caller (searchWithRetry) already retries on 5xx,
// so the generic k8s 5xx-retry here would just double up the wait
retryOn5xxForK8s: false,
);
}
+1
View File
@@ -469,6 +469,7 @@ default:
- SharingNgContext:
- CollaborationContext:
- TrashbinContext:
- OcisConfigContext:
apiServiceAvailability:
paths:
@@ -55,17 +55,6 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiGraphUser/getUser.feature:389](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUser/getUser.feature#L389)
- [apiGraphUser/getUser.feature:390](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUser/getUser.feature#L390)
#### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604)
- [apiGraphGroup/getGroup.feature:399](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L399)
- [apiGraphGroup/getGroup.feature:400](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L400)
- [apiGraphGroup/getGroup.feature:401](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L401)
- [apiGraphGroup/getGroup.feature:460](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L460)
- [apiGraphGroup/getGroup.feature:461](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L461)
- [apiGraphGroup/getGroup.feature:462](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L462)
- [apiGraphGroup/getGroup.feature:508](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L508)
- [apiGraphGroup/getGroup.feature:509](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L509)
- [apiGraphGroup/getGroup.feature:510](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphGroup/getGroup.feature#L510)
#### [Same users can be added in a group multiple time](https://github.com/owncloud/ocis/issues/5702)
@@ -1220,3 +1220,26 @@ Feature: collaboration (wopi)
| app | FakeOffice |
When the public sends a lock request with lock id "abcdef123" to the last opened file using wopi endpoint
Then the HTTP status code should be "200"
Scenario: brute-force protection must apply to max failed attempt on /app/open
And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt"
And we save it into "FILEID"
And user "Alice" has created the following resource link share:
| resource | simple.odt |
| space | Personal |
| permissionsRole | View |
| password | %public% |
When the public sends HTTP method "POST" to URL "/app/open?file_id=<<FILEID>>" with password "%public%"
Then the HTTP status code should be "200"
# For this test using the default STORAGE_PUBLICLINK_BRUTEFORCE_MAXATTEMPTS (5)
# instead of lowering it via an env-config restart: a restart wipes oCIS's in-memory,
# non-persistent app registry, and the FakeOffice/Collabora/OnlyOffice app providers this
# suite depends on only ever register once, at their own startup - they never
# re-register - so losing that registration here would permanently break every other
# scenario in this file for the rest of the test run
# After the exceeding max attempts the public request to /app/open with correct password should return 401
When the public sends HTTP method "POST" to URL "/app/open?file_id=<<FILEID>>" with password "wrong-pw" for 6 times
Then the HTTP status code of responses on each endpoint should be "401, 401, 401, 401, 401, 401" respectively
When the public sends HTTP method "POST" to URL "/app/open?file_id=<<FILEID>>" with password "%public%"
Then the HTTP status code should be "401"
@@ -370,27 +370,26 @@ Feature: get groups and their members
And user "Alice" has been added to group "tea-lover"
And user "Brian" has been added to group "tea-lover"
When user "Brian" gets all the members information of group "tea-lover" using the Graph API
Then the HTTP status code should be "403"
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"error"
"displayName",
"id"
],
"properties": {
"error": {
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"enum": ["Forbidden"]
}
}
"displayName": {
"const": "tea-lover"
},
"id": {
"type": "string",
"pattern": "^%group_id_pattern%$"
}
},
"not": {
"required": ["members"]
}
}
"""
@@ -431,27 +430,26 @@ Feature: get groups and their members
Given group "tea-lover" has been created
And the administrator has assigned the role "<user-role>" to user "Alice" using the Graph API
When user "Alice" gets details of the group "tea-lover" using the Graph API
Then the HTTP status code should be "403"
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"error"
"displayName",
"id"
],
"properties": {
"error": {
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"enum": ["Forbidden"]
}
}
"displayName": {
"const": "tea-lover"
},
"id": {
"type": "string",
"pattern": "^%group_id_pattern%$"
}
},
"not": {
"required": ["members"]
}
}
"""
@@ -502,7 +500,7 @@ Feature: get groups and their members
Scenario Outline: non-admin user tries to get group information of non-existing group
Given the administrator has assigned the role "<user-role>" to user "Alice" using the Graph API
When user "Alice" gets details of the group "non-existing" using the Graph API
Then the HTTP status code should be "403"
Then the HTTP status code should be "404"
Examples:
| user-role |
| Space Admin |
@@ -1428,3 +1428,27 @@ Feature: Send a drive invitations
}
}
"""
@env-config
Scenario: user has access to a space shared with LDAP group using posixGroup objectclass with uniqueMember schema
Given the following configs have been set:
| service | config | value |
| graph | OCIS_LDAP_GROUP_OBJECTCLASS | posixGroup |
| graph | OCIS_LDAP_GROUP_SCHEMA_MEMBER | uniqueMember |
| groups | OCIS_LDAP_GROUP_OBJECTCLASS | posixGroup |
| groups | OCIS_LDAP_GROUP_SCHEMA_MEMBER | uniqueMember |
| users | OCIS_LDAP_GROUP_OBJECTCLASS | posixGroup |
| users | OCIS_LDAP_GROUP_SCHEMA_MEMBER | uniqueMember |
| auth-basic | OCIS_LDAP_GROUP_OBJECTCLASS | posixGroup |
| auth-basic | OCIS_LDAP_GROUP_SCHEMA_MEMBER | uniqueMember |
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
And the administrator has created a group "grp1" using the Graph API
And the administrator has added a user "Brian" to the group "grp1" using the Graph API
When user "Alice" sends the following space share invitation using permissions endpoint of the Graph API:
| space | NewSpace |
| sharee | grp1 |
| shareType | group |
| permissionsRole | Space Viewer |
Then the HTTP status code should be "200"
And the user "Brian" should have a space called "NewSpace" granted to group "grp1" with role "viewer"
@@ -0,0 +1,47 @@
@env-config
Feature: brute-force protection for password protected public links
As the maintainer of a password protected public link
I want repeated wrong password guesses against that link to be rate limited
So that an attacker cannot brute-force the password regardless of which endpoint they use
Background:
Given these users have been created with default attributes:
| username |
| Alice |
And using spaces DAV path
And the config "STORAGE_PUBLICLINK_BRUTEFORCE_MAXATTEMPTS" has been set to "2" for "storage-publiclink" service
And using SharingNG
Scenario: brute-force protection must apply to max failed attempt on public WebDAV
Given user "Alice" has uploaded file with content "some content" to "testfile.txt"
When user "Alice" creates the following resource link share using the Graph API:
| resource | testfile.txt |
| space | Personal |
| permissionsRole | View |
| password | %public% |
Then the public download of file "testfile.txt" from inside the last public link shared folder using the public WebDAV API with password "%public%" should fail with HTTP status code "200"
And the public download of file "testfile.txt" from inside the last public link shared folder using the public WebDAV API with password "wrong-password" should fail with HTTP status code "401"
And the public download of file "testfile.txt" from inside the last public link shared folder using the public WebDAV API with password "wrong-password" should fail with HTTP status code "401"
And the public download of file "testfile.txt" from inside the last public link shared folder using the public WebDAV API with password "wrong-password" should fail with HTTP status code "429"
And the public download of file "testfile.txt" from inside the last public link shared folder using the public WebDAV API with password "%public%" should fail with HTTP status code "429"
Scenario: brute-force protection must apply to max failed attempt on /archiver
Given user "Alice" has created folder "public-folder"
And user "Alice" has uploaded file with content "some content" to "public-folder/testfile.txt"
And user "Alice" has created the following resource link share:
| resource | public-folder |
| space | Personal |
| permissionsRole | View |
| password | %public% |
When the public downloads the archive of the last created public link with password "%public%"
Then the HTTP status code should be "200"
When the public downloads the archive of the last created public link with incorrect password "wrong-pw"
Then the HTTP status code should be "401"
When the public downloads the archive of the last created public link with incorrect password "wrong-pw"
Then the HTTP status code should be "401"
When the public downloads the archive of the last created public link with incorrect password "wrong-pw"
Then the HTTP status code should be "401"
When the public downloads the archive of the last created public link with password "%public%"
Then the HTTP status code should be "401"
+40 -11
View File
@@ -4,6 +4,9 @@ Run Playwright e2e tests against a local OCIS instance.
Usage: E2E_ARGS='--run-part 1' python3 tests/acceptance/run-e2e.py
Optional: TIKA_NEEDED=true, KEYCLOAK_NEEDED=true
Optional: K8S=true, TEST_SERVER_URL=<url> - run against an already-deployed
k8s OCIS instance (see .github/workflows/k8s.yml) instead of starting one
locally. All other *_NEEDED flags are ignored in this mode.
"""
import json
@@ -120,6 +123,43 @@ def main() -> int:
file=sys.stderr)
return 1
repo_root = Path(__file__).resolve().parents[2]
web_dir = repo_root / "web"
if not (web_dir / "node_modules").exists():
pkg_manager = json.loads((web_dir / "package.json").read_text()).get("packageManager", "pnpm")
run(["npm", "install", "--silent", "--global", "--force", pkg_manager])
subprocess.run(["pnpm", "config", "set", "store-dir", "./.pnpm-store"],
cwd=web_dir, check=True)
subprocess.run(["pnpm", "install"], cwd=web_dir, check=True)
subprocess.run(["pnpm", "exec", "playwright", "install", "--with-deps", "chromium"],
cwd=web_dir, check=True)
if os.environ.get("K8S", "").lower() == "true":
# oCIS is already running as a Helm-deployed k8s cluster (see
# .github/workflows/k8s.yml) -- unlike the flow below, there's no local
# binary to build, init, or start. Just confirm it's up and point
# Playwright straight at it.
ocis_url = os.environ["TEST_SERVER_URL"]
wait_for(lambda: ocis_healthy(ocis_url), 120, "ocis")
print("ocis ready.")
playwright_env = {
**os.environ,
"BASE_URL_OCIS": ocis_url,
"HEADLESS": "true",
"RETRY": "3",
"REPORT_TRACING": "false",
"BROWSER": "chromium",
}
print(f"Running e2e: {e2e_args}")
result = subprocess.run(
["bash", "run-e2e.sh"] + shlex.split(e2e_args),
cwd=web_dir / "tests/e2e",
env=playwright_env,
)
return result.returncode
tika_needed = os.environ.get("TIKA_NEEDED", "").lower() == "true"
keycloak_needed = os.environ.get("KEYCLOAK_NEEDED", "").lower() == "true"
mfa_needed = os.environ.get("MFA_NEEDED", "").lower() == "true"
@@ -131,7 +171,6 @@ def main() -> int:
# MFA mode runs ocis behind keycloak with TOTP enforced
keycloak_needed = keycloak_needed or mfa_needed or vault_storage_needed
repo_root = Path(__file__).resolve().parents[2]
ocis_bin = repo_root / "ocis/bin/ocis"
wrapper_bin = repo_root / "tests/ociswrapper/bin/ociswrapper"
# The federated suite must address the primary as localhost instead of
@@ -141,7 +180,6 @@ def main() -> int:
# suite), which only lists localhost:9200.
ocis_url = "https://localhost:9200" if federated_needed else "https://127.0.0.1:9200"
ocis_config_dir = Path.home() / ".ocis/config"
web_dir = repo_root / "web"
# build ocis + ociswrapper only if not already provided (e.g. via artifact)
if not ocis_bin.exists():
@@ -150,15 +188,6 @@ def main() -> int:
run(["make", "-C", str(repo_root / "tests/ociswrapper"), "build"],
env={"GOWORK": "off"})
if not (web_dir / "node_modules").exists():
pkg_manager = json.loads((web_dir / "package.json").read_text()).get("packageManager", "pnpm")
run(["npm", "install", "--silent", "--global", "--force", pkg_manager])
subprocess.run(["pnpm", "config", "set", "store-dir", "./.pnpm-store"],
cwd=web_dir, check=True)
subprocess.run(["pnpm", "install"], cwd=web_dir, check=True)
subprocess.run(["pnpm", "exec", "playwright", "install", "--with-deps", "chromium"],
cwd=web_dir, check=True)
# init ocis
run([str(ocis_bin), "init", "--insecure", "true"])
# tests/config/ci/app-registry.yaml maps its one mimetype to "FakeOffice", the
+1 -1
View File
@@ -2,7 +2,7 @@
set -euo pipefail
NAMESPACE="${NAMESPACE:-ocis-server}"
NAMESPACE="${TEST_SERVER_DOMAIN:-ocis-server}"
declare -A DEBUG_PORTS=(
[activitylog]=9197
+1 -1
View File
@@ -4,7 +4,7 @@ set -e
HOST_IP=$(ip route get 1 | awk '{print $7}')
NAMESPACE="ocis-server"
NAMESPACE="${TEST_SERVER_DOMAIN:-ocis-server}"
while [[ $# -gt 0 ]]; do
case "$1" in
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
set -e
deploy_name=$1
service_port=$2
node_port=$3
namespace="${TEST_SERVER_DOMAIN:-ocis-server}"
if [[ -z "$deploy_name" ]] || [[ -z "$service_port" ]] || [[ -z "$node_port" ]]; then
echo "[ERROR] Missing arguments. Usage: $0 <deploy_name> <service_port> <node_port>"
exit 1
fi
service_name="${deploy_name}-${node_port}-np"
kubectl -n "$namespace" expose deployment "$deploy_name" --type=NodePort --port="$service_port" --name="$service_name"
kubectl -n "$namespace" patch svc "$service_name" -p "{\"spec\":{\"ports\":[{\"port\":${service_port},\"nodePort\":${node_port}}]}}"
+5
View File
@@ -69,6 +69,11 @@ if [[ "$ENABLE_WOPI" == "true" ]]; then
# patch collaboration service
# - allow dynamic wopi src
sed -i -E "s|value: http://.*:9300|value: {{ \$officeSuite.wopiSrc }}|" $TPL_DIR/collaboration/deployment.yaml
sed -i \
-e 's/{{- include "ocis.extraEnvs" \. | nindent 12 }}/{{- include "ocis.extraEnvs" $ | nindent 12 }}/' \
-e 's/{{- include "ocis.extraVolMounts" \. | nindent 12 }}/{{- include "ocis.extraVolMounts" $ | nindent 12 }}/' \
-e 's/{{- include "ocis.extraVolumes" \. | nindent 8 }}/{{- include "ocis.extraVolumes" $ | nindent 8 }}/' \
$TPL_DIR/collaboration/deployment.yaml
fi
if [[ "$ENABLE_OCM" == "true" ]]; then
+1 -1
View File
@@ -74,7 +74,7 @@ features:
ingress:
enabled: false
- name: 'OnlyOffice'
uri: 'https://onlyoffice'
uri: 'https://onlyoffice:7443'
wopiSrc: 'http://ocis-server:9302'
product: 'OnlyOffice'
enabled: true
+18 -3
View File
@@ -129,6 +129,9 @@ const (
// Always asserts that condition is true every time this function is called, and that it is called at least once. The corresponding test property will be viewable in the Antithesis SDK: Always group of your triage report.
func Always(condition bool, message string, details map[string]any) {
if trackerEmitted(message, condition) {
return
}
locationInfo := newLocationInfo(offsetAPICaller)
id := makeKey(message, locationInfo)
assertImpl(condition, message, details, locationInfo, wasHit, mustBeHit, universalTest, alwaysDisplay, id)
@@ -136,6 +139,9 @@ func Always(condition bool, message string, details map[string]any) {
// AlwaysOrUnreachable asserts that condition is true every time this function is called. The corresponding test property will pass if the assertion is never encountered (unlike Always assertion types). This test property will be viewable in the “Antithesis SDK: Always” group of your triage report.
func AlwaysOrUnreachable(condition bool, message string, details map[string]any) {
if trackerEmitted(message, condition) {
return
}
locationInfo := newLocationInfo(offsetAPICaller)
id := makeKey(message, locationInfo)
assertImpl(condition, message, details, locationInfo, wasHit, optionallyHit, universalTest, alwaysOrUnreachableDisplay, id)
@@ -143,6 +149,9 @@ func AlwaysOrUnreachable(condition bool, message string, details map[string]any)
// Sometimes asserts that condition is true at least one time that this function was called. (If the assertion is never encountered, the test property will therefore fail.) This test property will be viewable in the “Antithesis SDK: Sometimes” group.
func Sometimes(condition bool, message string, details map[string]any) {
if trackerEmitted(message, condition) {
return
}
locationInfo := newLocationInfo(offsetAPICaller)
id := makeKey(message, locationInfo)
assertImpl(condition, message, details, locationInfo, wasHit, mustBeHit, existentialTest, sometimesDisplay, id)
@@ -150,6 +159,9 @@ func Sometimes(condition bool, message string, details map[string]any) {
// Unreachable asserts that a line of code is never reached. The corresponding test property will fail if this function is ever called. (If it is never called the test property will therefore pass.) This test property will be viewable in the “Antithesis SDK: Reachablity assertions” group.
func Unreachable(message string, details map[string]any) {
if trackerEmitted(message, false) {
return
}
locationInfo := newLocationInfo(offsetAPICaller)
id := makeKey(message, locationInfo)
assertImpl(false, message, details, locationInfo, wasHit, optionallyHit, reachabilityTest, unreachableDisplay, id)
@@ -157,6 +169,9 @@ func Unreachable(message string, details map[string]any) {
// Reachable asserts that a line of code is reached at least once. The corresponding test property will pass if this function is ever called. (If it is never called the test property will therefore fail.) This test property will be viewable in the “Antithesis SDK: Reachablity assertions” group.
func Reachable(message string, details map[string]any) {
if trackerEmitted(message, true) {
return
}
locationInfo := newLocationInfo(offsetAPICaller)
id := makeKey(message, locationInfo)
assertImpl(true, message, details, locationInfo, wasHit, mustBeHit, reachabilityTest, reachableDisplay, id)
@@ -164,13 +179,13 @@ func Reachable(message string, details map[string]any) {
// AssertRaw is a low-level method designed to be used by third-party frameworks. Regular users of the assert package should not call it.
func AssertRaw(cond bool, message string, details map[string]any,
classname, funcname, filename string, line int,
classname, funcname, filename string, line int, column int,
hit bool, mustHit bool,
assertType string, displayType string,
id string,
) {
assertImpl(cond, message, details,
&locationInfo{classname, funcname, filename, line, columnUnknown},
&locationInfo{classname, funcname, filename, line, column},
hit, mustHit,
assertType, displayType,
id)
@@ -182,7 +197,7 @@ func assertImpl(cond bool, message string, details map[string]any,
assertType string, displayType string,
id string,
) {
trackerEntry := assertTracker.getTrackerEntry(id, loc.Filename, loc.Classname)
trackerEntry := getTrackerEntry(id, loc.Filename, loc.Classname)
// Always grab the Filename and Classname captured when the trackerEntry was established
// This provides the consistency needed between instrumentation-time and runtime
+1 -1
View File
@@ -8,7 +8,7 @@ func Sometimes(condition bool, message string, details map[string]any)
func Unreachable(message string, details map[string]any) {}
func Reachable(message string, details map[string]any) {}
func AssertRaw(cond bool, message string, details map[string]any,
classname, funcname, filename string, line int,
classname, funcname, filename string, line int, column int,
hit bool, mustHit bool,
assertType string, displayType string,
id string,
+13 -40
View File
@@ -8,43 +8,22 @@ import (
"github.com/antithesishq/antithesis-sdk-go/internal"
)
// TODO: Tracker is intended to prevent sending the same guidance
// more than once. In this case, we always send, so the tracker
// is not presently used.
type booleanGuidance struct {
n int
}
// TODO: Someday this tracker should also start deduplicating
// guidance, but there are some complicated policy questions
// to settle before we do that.
type booleanGuidance struct{}
type booleanGuidanceTracker map[string]*booleanGuidance
// booleanGuidanceTracker keeps the per-id entries: a grow-only map with
// stable keys, read on every rich-assert evaluation and written once per
// guidance id.
var booleanGuidanceTracker sync.Map // message key -> *booleanGuidance
var (
boolean_guidance_tracker booleanGuidanceTracker = make(booleanGuidanceTracker)
boolean_guidance_tracker_mutex sync.Mutex
boolean_guidance_info_mutex sync.Mutex
)
func (tracker booleanGuidanceTracker) getTrackerEntry(messageKey string) *booleanGuidance {
var trackerEntry *booleanGuidance
var ok bool
if tracker == nil {
return nil
func getBooleanGuidanceEntry(messageKey string) *booleanGuidance {
if entry, ok := booleanGuidanceTracker.Load(messageKey); ok {
return entry.(*booleanGuidance)
}
boolean_guidance_tracker_mutex.Lock()
defer boolean_guidance_tracker_mutex.Unlock()
if trackerEntry, ok = boolean_guidance_tracker[messageKey]; !ok {
trackerEntry = newBooleanGuidance()
tracker[messageKey] = trackerEntry
}
return trackerEntry
}
// Create a boolean guidance tracker
func newBooleanGuidance() *booleanGuidance {
trackerInfo := booleanGuidance{}
return &trackerInfo
entry, _ := booleanGuidanceTracker.LoadOrStore(messageKey, &booleanGuidance{})
return entry.(*booleanGuidance)
}
func (tI *booleanGuidance) send_value(bgI *booleanGuidanceInfo) {
@@ -52,12 +31,6 @@ func (tI *booleanGuidance) send_value(bgI *booleanGuidanceInfo) {
return
}
boolean_guidance_info_mutex.Lock()
defer boolean_guidance_info_mutex.Unlock()
// The tracker entry should be consulted to determine
// if this Guidance info has already been sent, or not.
emitBooleanGuidance(bgI)
}
+67 -78
View File
@@ -5,6 +5,7 @@ package assert
import (
"math"
"sync"
"sync/atomic"
"github.com/antithesishq/antithesis-sdk-go/internal"
)
@@ -45,35 +46,26 @@ func gapTypeForOperand[T Number](num T) numericGapType {
//
// --------------------------------------------------------------------------------
type numericGuidanceInfo struct {
gap any
descriminator numericGapType
maximize bool
// The best gap sent so far (a gapValue[uint64] or gapValue[float64],
// fixed per entry). Read lock-free on every evaluation; updated under mu.
gap atomic.Value
// Serializes improvements (compare, update, emit) so guidance emissions
// form an ordered monotone chain; the no-improvement fast path never
// takes it.
mu sync.Mutex
}
type numericGuidanceTracker map[string]*numericGuidanceInfo
var numericGuidanceTracker sync.Map // message key -> *numericGuidanceInfo
var (
numeric_guidance_tracker numericGuidanceTracker = make(numericGuidanceTracker)
numeric_guidance_tracker_mutex sync.Mutex
numeric_guidance_info_mutex sync.Mutex
)
func (tracker numericGuidanceTracker) getTrackerEntry(messageKey string, trackerType numericGapType, maximize bool) *numericGuidanceInfo {
var trackerEntry *numericGuidanceInfo
var ok bool
if tracker == nil {
return nil
func getNumericGuidanceEntry(messageKey string, trackerType numericGapType, maximize bool) *numericGuidanceInfo {
if entry, ok := numericGuidanceTracker.Load(messageKey); ok {
return entry.(*numericGuidanceInfo)
}
numeric_guidance_tracker_mutex.Lock()
defer numeric_guidance_tracker_mutex.Unlock()
if trackerEntry, ok = numeric_guidance_tracker[messageKey]; !ok {
trackerEntry = newNumericGuidanceInfo(trackerType, maximize)
tracker[messageKey] = trackerEntry
}
return trackerEntry
entry, _ := numericGuidanceTracker.LoadOrStore(messageKey,
newNumericGuidanceInfo(trackerType, maximize))
return entry.(*numericGuidanceInfo)
}
// Create an numeric guidance entry
@@ -88,8 +80,8 @@ func newNumericGuidanceInfo(trackerType numericGapType, maximize bool) *numericG
trackerInfo := numericGuidanceInfo{
maximize: maximize,
descriminator: trackerType,
gap: gap,
}
trackerInfo.gap.Store(gap)
return &trackerInfo
}
@@ -175,14 +167,51 @@ func is_less_than[T numConstraint](left gapValue[T], right gapValue[T]) bool {
return true
}
// The candidate gap for a pair of guidance operands, in the tracker's
// representation (nil when the operand type resolves to none).
func candidateGap(data any) any {
// Needs to have individual case statements to assist
// the compiler to infer the actual type of the var named 'operands'
switch operands := data.(type) {
case numericOperands[int32]:
return makeGap(operands)
case numericOperands[int64]:
return makeGap(operands)
case numericOperands[uint64]:
return makeGap(operands)
case numericOperands[float64]:
return makeFloatGap(operands)
}
return nil
}
// Whether candidate improves on the entry's tracked extremum.
func (tI *numericGuidanceInfo) improves(candidate any) bool {
maximize := tI.should_maximize()
switch prev := tI.gap.Load().(type) {
case gapValue[uint64]:
if gap, ok := candidate.(gapValue[uint64]); ok {
if maximize {
return is_greater_than(gap, prev)
}
return is_less_than(gap, prev)
}
case gapValue[float64]:
if gap, ok := candidate.(gapValue[float64]); ok {
if maximize {
return is_greater_than(gap, prev)
}
return is_less_than(gap, prev)
}
}
return false
}
func send_value_if_needed(tI *numericGuidanceInfo, gI *guidanceInfo) {
if tI == nil {
return
}
numeric_guidance_info_mutex.Lock()
defer numeric_guidance_info_mutex.Unlock()
// if this is a catalog entry (gI.hit is false)
// do not update the reference gap in the tracker (tI *numericGuidanceInfo)
if !gI.Hit {
@@ -190,59 +219,19 @@ func send_value_if_needed(tI *numericGuidanceInfo, gI *guidanceInfo) {
return
}
should_send := false
maximize := tI.should_maximize()
var gap gapValue[uint64]
var float_gap gapValue[float64]
// Needs to have individual case statements to assist
// the compiler to infer the actual type of the var named 'operands'
switch operands := (gI.Data).(type) {
case numericOperands[int32]:
gap = makeGap(operands)
case numericOperands[int64]:
gap = makeGap(operands)
case numericOperands[uint64]:
gap = makeGap(operands)
case numericOperands[float64]:
float_gap = makeFloatGap(operands)
// Most evaluations do not improve on the tracked extremum; that path is
// a lock-free load and compare. The mutex serializes only improvements.
candidate := candidateGap(gI.Data)
if !tI.improves(candidate) {
return
}
var prev_gap gapValue[uint64]
var prev_float_gap gapValue[float64]
has_prev_gap := false
has_prev_float_gap := false
prev_gap, has_prev_gap = tI.gap.(gapValue[uint64])
if !has_prev_gap {
prev_float_gap, has_prev_float_gap = tI.gap.(gapValue[float64])
}
if has_prev_gap {
if maximize {
should_send = is_greater_than(gap, prev_gap)
} else {
should_send = is_less_than(gap, prev_gap)
}
}
if has_prev_float_gap {
if maximize {
should_send = is_greater_than(float_gap, prev_float_gap)
} else {
should_send = is_less_than(float_gap, prev_float_gap)
}
}
if should_send {
if tI.is_integer_gap() {
tI.gap = gap
} else {
tI.gap = float_gap
}
emitGuidance(gI)
tI.mu.Lock()
defer tI.mu.Unlock()
if !tI.improves(candidate) {
return
}
tI.gap.Store(candidate)
emitGuidance(gI)
}
func emitGuidance(gI *guidanceInfo) error {
+42 -2
View File
@@ -139,13 +139,13 @@ func behavior_to_guidance(behavior string) guidanceFnType {
}
func numericGuidanceImpl[T Number](left, right T, message, id string, loc *locationInfo, guidanceFn guidanceFnType, hit bool) {
tI := numeric_guidance_tracker.getTrackerEntry(id, gapTypeForOperand(left), uses_maximize(guidanceFn))
tI := getNumericGuidanceEntry(id, gapTypeForOperand(left), uses_maximize(guidanceFn))
gI := build_numeric_guidance(guidanceFn, message, left, right, loc, id, hit)
send_value_if_needed(tI, gI)
}
func booleanGuidanceImpl(named_bools []NamedBool, message, id string, loc *locationInfo, guidanceFn guidanceFnType, hit bool) {
tI := boolean_guidance_tracker.getTrackerEntry(id)
tI := getBooleanGuidanceEntry(id)
bgI := build_boolean_guidance(guidanceFn, message, named_bools, loc, id, hit)
tI.send_value(bgI)
}
@@ -207,8 +207,27 @@ func add_boolean_details(details map[string]any, named_bools []NamedBool) map[st
return enhancedDetails
}
// Whether a numeric rich-assert evaluation can return before capturing its
// location or building its details: the assertion side has already emitted
// for this condition, and the guidance side does not improve the tracked
// extremum. Both checks are lock-free loads. False while the guidance entry
// does not exist, so the first evaluation still takes the full path.
func numericRichAssertSettled[T Number](left, right T, message string, condition bool) bool {
if !trackerEmitted(message, condition) {
return false
}
entry, ok := numericGuidanceTracker.Load(message)
if !ok {
return false
}
return !entry.(*numericGuidanceInfo).improves(candidateGap(newOperands(left, right)))
}
// Equivalent to asserting Always(left > right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func AlwaysGreaterThan[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left > right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left > right
@@ -220,6 +239,9 @@ func AlwaysGreaterThan[T Number](left, right T, message string, details map[stri
// Equivalent to asserting Always(left >= right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func AlwaysGreaterThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left >= right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left >= right
@@ -231,6 +253,9 @@ func AlwaysGreaterThanOrEqualTo[T Number](left, right T, message string, details
// Equivalent to asserting Sometimes(T left > T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func SometimesGreaterThan[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left > right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left > right
@@ -242,6 +267,9 @@ func SometimesGreaterThan[T Number](left, right T, message string, details map[s
// Equivalent to asserting Sometimes(T left >= T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func SometimesGreaterThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left >= right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left >= right
@@ -253,6 +281,9 @@ func SometimesGreaterThanOrEqualTo[T Number](left, right T, message string, deta
// Equivalent to asserting Always(left < right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func AlwaysLessThan[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left < right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left < right
@@ -264,6 +295,9 @@ func AlwaysLessThan[T Number](left, right T, message string, details map[string]
// Equivalent to asserting Always(left <= right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func AlwaysLessThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left <= right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left <= right
@@ -275,6 +309,9 @@ func AlwaysLessThanOrEqualTo[T Number](left, right T, message string, details ma
// Equivalent to asserting Sometimes(T left < T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func SometimesLessThan[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left < right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left < right
@@ -286,6 +323,9 @@ func SometimesLessThan[T Number](left, right T, message string, details map[stri
// Equivalent to asserting Sometimes(T left <= T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
func SometimesLessThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
if numericRichAssertSettled(left, right, message, left <= right) {
return
}
loc := newLocationInfo(offsetAPICaller)
id := makeKey(message, loc)
condition := left <= right
+41 -68
View File
@@ -3,54 +3,34 @@
package assert
import (
"runtime"
"sync"
"sync/atomic"
"github.com/antithesishq/antithesis-sdk-go/internal"
)
// Tracking info for one assertion id.
type trackerInfo struct {
Filename string
Classname string
PassCount int
FailCount int
passEmitted atomic.Bool
failEmitted atomic.Bool
// Serializes only first-emission attempts (including retries after an
// emission error); never taken once a flag is set.
emitMutex sync.Mutex
}
type emitTracker map[string]*trackerInfo
// assertTracker keeps track of the unique asserts evaluated.
var assertTracker sync.Map // message key -> *trackerInfo
// assert_tracker (global) keeps track of the unique asserts evaluated
var (
assertTracker emitTracker = make(emitTracker)
trackerMutex sync.Mutex
trackerInfoMutex sync.Mutex
)
func (tracker emitTracker) getTrackerEntry(messageKey string, filename, classname string) *trackerInfo {
var trackerEntry *trackerInfo
var ok bool
if tracker == nil {
return nil
func getTrackerEntry(messageKey string, filename string, classname string) *trackerInfo {
if entry, ok := assertTracker.Load(messageKey); ok {
return entry.(*trackerInfo)
}
trackerMutex.Lock()
defer trackerMutex.Unlock()
if trackerEntry, ok = tracker[messageKey]; !ok {
trackerEntry = newTrackerInfo(filename, classname)
tracker[messageKey] = trackerEntry
}
return trackerEntry
}
func newTrackerInfo(filename, classname string) *trackerInfo {
trackerInfo := trackerInfo{
PassCount: 0,
FailCount: 0,
Filename: filename,
Classname: classname,
}
return &trackerInfo
entry, _ := assertTracker.LoadOrStore(messageKey,
&trackerInfo{Filename: filename, Classname: classname})
return entry.(*trackerInfo)
}
func (ti *trackerInfo) emit(ai *assertInfo) {
@@ -59,53 +39,46 @@ func (ti *trackerInfo) emit(ai *assertInfo) {
}
// Registrations are just sent to voidstar
hit := ai.Hit
if !hit {
if !ai.Hit {
emitAssert(ai)
return
}
var err error
cond := ai.Condition
trackerInfoMutex.Lock()
defer trackerInfoMutex.Unlock()
if cond {
if ti.PassCount == 0 {
err = emitAssert(ai)
}
if err == nil {
ti.PassCount++
}
flag := &ti.passEmitted
if !ai.Condition {
flag = &ti.failEmitted
}
if flag.Load() {
return
}
if ti.FailCount == 0 {
err = emitAssert(ai)
ti.emitMutex.Lock()
defer ti.emitMutex.Unlock()
if flag.Load() {
return
}
if err == nil {
ti.FailCount++
// The flag is only set on success, so an assertion whose emission
// failed is retried on its next evaluation (as before).
if emitAssert(ai) == nil {
flag.Store(true)
}
}
func versionMessage() {
languageBlock := map[string]any{
"name": "Go",
"version": runtime.Version(),
// Whether this assertion id has already emitted for this condition — i.e.
// whether an evaluation can return before capturing its location.
func trackerEmitted(id string, condition bool) bool {
entry, ok := assertTracker.Load(id)
if !ok {
return false
}
versionBlock := map[string]any{
"language": languageBlock,
"sdk_version": internal.SDK_Version,
"protocol_version": internal.Protocol_Version,
ti := entry.(*trackerInfo)
if condition {
return ti.passEmitted.Load()
}
internal.Json_data(map[string]any{"antithesis_sdk": versionBlock})
return ti.failEmitted.Load()
}
// package-level flag
var hasEmitted atomic.Bool // initialzed to false
func emitAssert(ai *assertInfo) error {
if hasEmitted.CompareAndSwap(false, true) {
versionMessage()
}
// The version message is emitted by the internal package when the
// handler initializes, before any output can happen.
return internal.Json_data(wrappedAssertInfo{ai})
}
+87 -8
View File
@@ -3,10 +3,12 @@
package internal
import (
crand "crypto/rand"
"encoding/binary"
"encoding/json"
"log"
"math/rand"
"os"
"runtime"
)
func Json_data(v any) error {
@@ -26,6 +28,18 @@ func Notify(edge uint64) bool {
return handler.notify(edge)
}
// NotifyV2 reports a coverage hit through the lease ABI (linkage v2); ok is
// false when the loaded library does not support leases.
func NotifyV2(edge uint64, hits uint64) (uint64, bool) {
return handler.notify_v2(edge, hits)
}
// LeaseGeneration reads the lease revocation word; ok is false when the
// loaded library does not support leases.
func LeaseGeneration() (uint64, bool) {
return handler.lease_generation()
}
func InitCoverage(num_edges uint64, symbols string) uint64 {
return handler.init_coverage(num_edges, symbols)
}
@@ -34,6 +48,8 @@ type libHandler interface {
output(message string)
random() uint64
notify(edge uint64) bool
notify_v2(edge uint64, hits uint64) (uint64, bool)
lease_generation() (uint64, bool)
init_coverage(num_edges uint64, symbols string) uint64
}
@@ -43,6 +59,13 @@ const (
var handler libHandler
// Mirrors the no_antithesis_sdk implementation of random.GetRandom.
func osRandom() uint64 {
var tmp [8]byte
crand.Read(tmp[:])
return binary.LittleEndian.Uint64(tmp[:])
}
type localHandler struct {
outputFile *os.File // can be nil
}
@@ -58,13 +81,21 @@ func (h *localHandler) output(message string) {
}
func (h *localHandler) random() uint64 {
return rand.Uint64()
return osRandom()
}
func (h *localHandler) notify(edge uint64) bool {
return false
}
func (h *localHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) {
return 0, false
}
func (h *localHandler) lease_generation() (uint64, bool) {
return 0, false
}
func (h *localHandler) init_coverage(num_edges uint64, symbols string) uint64 {
return 0
}
@@ -75,9 +106,32 @@ func init() {
// Otherwise fallback to the local handler.
handler = openLocalHandler()
}
// The version message is the first output of every run, emitted when the
// handler comes up.
emitVersionMessage()
if sdkRunningInDegradedMode {
emitDegradedModeProperty()
}
}
// If `localOutputEnvVar` is set to a non-empty path, attempt to open that path and truncate the file
func emitVersionMessage() {
languageBlock := map[string]any{
"name": "Go",
"version": runtime.Version(),
}
versionBlock := map[string]any{
"language": languageBlock,
"sdk_version": SDK_Version,
"protocol_version": Protocol_Version,
}
if data, err := json.Marshal(map[string]any{"antithesis_sdk": versionBlock}); err == nil {
handler.output(string(data))
}
}
// If `localOutputEnvVar` is set to a non-empty path, attempt to open that path for appending
// to serve as the log file of the local handler.
// Otherwise, we don't have a log file, and logging is a no-op in the local handler.
func openLocalHandler() *localHandler {
@@ -86,15 +140,40 @@ func openLocalHandler() *localHandler {
return &localHandler{nil}
}
// Open the file R/W (create if needed and possible)
file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
// Open the file for writing (create if needed and possible, use O_APPEND to support concurrent writers)
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Printf("%s Failed to open path %s: %v", errorLogLinePrefix, path, err)
file = nil
} else if err = file.Truncate(0); err != nil {
log.Printf("%s Failed to truncate file at %s: %v", errorLogLinePrefix, path, err)
file = nil
}
return &localHandler{file}
}
const degradedModeProperty = "Go application under test compiled with CGO enabled"
func emitDegradedModeProperty() {
Json_data(map[string]any{
"antithesis_assert": map[string]any{
"hit": true,
"must_hit": true,
"assert_type": "always",
"display_type": "Always",
"message": degradedModeProperty,
"id": degradedModeProperty,
"condition": false,
"location": map[string]any{
"class": "",
"function": "",
"file": "",
"begin_line": 0,
"begin_column": 0,
},
"details": map[string]any{
"info": "This binary was built without CGO enabled, which is required for " +
"coverage-guided fuzzing and thread pausing. Rebuild with CGO_ENABLED=1 so the " +
"SDK can link " + defaultNativeLibraryPath + " to enable them.",
},
},
})
}
+8 -1
View File
@@ -3,10 +3,17 @@ package internal
// --------------------------------------------------------------------------------
// Versions
// --------------------------------------------------------------------------------
const SDK_Version = "0.7.2"
const SDK_Version = "0.8.0"
const Protocol_Version = "1.1.0"
// --------------------------------------------------------------------------------
// Environment Vars
// --------------------------------------------------------------------------------
const localOutputEnvVar = "ANTITHESIS_SDK_LOCAL_OUTPUT"
const outputDirEnvVar = "ANTITHESIS_OUTPUT_DIR"
// --------------------------------------------------------------------------------
// Paths
// --------------------------------------------------------------------------------
const defaultNativeLibraryPath = "/usr/lib/libvoidstar.so"
const fallbackOutputFilename = "sdk.jsonl"
@@ -5,6 +5,7 @@ package internal
import (
"fmt"
"os"
"sync/atomic"
"unsafe"
)
@@ -60,18 +61,36 @@ import (
// return ((go_init_coverage_fn)f)(num_edges, symbols);
// }
//
// typedef uint64_t (*go_notify_coverage_v2_fn)(size_t, uint64_t);
// uint64_t
// go_notify_coverage_v2(void *f, size_t edge, uint64_t hits) {
// return ((go_notify_coverage_v2_fn)f)(edge, hits);
// }
//
// typedef const uint64_t *(*go_lease_generation_addr_fn)(void);
// const uint64_t *
// go_lease_generation_addr(void *f) {
// return ((go_lease_generation_addr_fn)f)();
// }
//
// typedef uint64_t (*go_request_abi_version_fn)(uint64_t);
// uint64_t
// go_request_abi_version(void *f, uint64_t v) {
// return ((go_request_abi_version_fn)f)(v);
// }
//
import "C"
const (
defaultNativeLibraryPath = "/usr/lib/libvoidstar.so"
)
type voidstarHandler struct {
fuzzJsonData unsafe.Pointer
fuzzFlush unsafe.Pointer
fuzzGetRandom unsafe.Pointer
initCoverage unsafe.Pointer
notifyCoverage unsafe.Pointer
// Coverage-lease support (linkage ABI v2, instrumentation.h). Nil/zero
// when the loaded library predates the mechanism or negotiation failed.
notifyCoverageV2 unsafe.Pointer
leaseGeneration *uint64
}
func (h *voidstarHandler) output(message string) {
@@ -100,6 +119,23 @@ func (h *voidstarHandler) notify(edge uint64) bool {
return ival == 1
}
func (h *voidstarHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) {
if h.notifyCoverageV2 == nil {
return 0, false
}
return uint64(C.go_notify_coverage_v2(h.notifyCoverageV2, C.ulong(edge), C.uint64_t(hits))), true
}
func (h *voidstarHandler) lease_generation() (uint64, bool) {
if h.leaseGeneration == nil {
return 0, false
}
// The header requires this read to be non-hoistable out of hot loops;
// an atomic load has the required opaque semantics. The word lives for
// the life of the process and is only ever written by the fuzzer.
return atomic.LoadUint64(h.leaseGeneration), true
}
// Attempt to load libvoidstar and some symbols from `path`
func openSharedLib(path string) (*voidstarHandler, error) {
cstrPath := C.CString(path)
@@ -123,6 +159,17 @@ func openSharedLib(path string) (*voidstarHandler, error) {
return
}
// Symbols absent from older library vintages must resolve softly: no
// library version may fail the SDK's load (instrumentation.h, "Linkage
// ABI versioning").
loadOptional := func(name string) unsafe.Pointer {
cstrName := C.CString(name)
defer C.free(unsafe.Pointer(cstrName))
symbol := C.dlsym(sharedLib, cstrName)
C.dlerror() // clear any lookup error
return symbol
}
fuzzJsonData, err := loadFunc("fuzz_json_data")
if err != nil {
return nil, err
@@ -143,9 +190,32 @@ func openSharedLib(path string) (*voidstarHandler, error) {
if err != nil {
return nil, err
}
return &voidstarHandler{fuzzJsonData, fuzzFlush, fuzzGetRandom, initCoverage, notifyCoverage}, nil
handler := &voidstarHandler{
fuzzJsonData: fuzzJsonData,
fuzzFlush: fuzzFlush,
fuzzGetRandom: fuzzGetRandom,
initCoverage: initCoverage,
notifyCoverage: notifyCoverage,
}
// Negotiate for coverage leases: request ABI v2 and gate on the granted
// version (a grant above the request means "cannot negotiate").
requestAbi := loadOptional("instrumentation_request_abi_version")
notifyV2 := loadOptional("notify_coverage_v2")
leaseAddr := loadOptional("coverage_lease_generation_addr")
if requestAbi != nil && notifyV2 != nil && leaseAddr != nil {
if granted := uint64(C.go_request_abi_version(requestAbi, 2)); granted == 2 {
if addr := C.go_lease_generation_addr(leaseAddr); addr != nil {
handler.notifyCoverageV2 = notifyV2
handler.leaseGeneration = (*uint64)(unsafe.Pointer(addr))
}
}
}
return handler, nil
}
const sdkRunningInDegradedMode = false
// If we have a file at `defaultNativeLibraryPath`, we load the shared library
// (and panic on any error encountered during load).
func init_in_antithesis() libHandler {
@@ -0,0 +1,58 @@
//go:build enable_antithesis_sdk && linux && amd64 && !cgo
package internal
import (
"log"
"os"
"path/filepath"
)
const sdkRunningInDegradedMode = true
type inAntithesisWithoutCgoHandler struct {
outputFile *os.File
}
func (h *inAntithesisWithoutCgoHandler) output(message string) {
if len(message) == 0 {
return
}
h.outputFile.WriteString(message + "\n")
}
func (h *inAntithesisWithoutCgoHandler) random() uint64 {
return osRandom()
}
func (h *inAntithesisWithoutCgoHandler) notify(edge uint64) bool {
return false
}
func (h *inAntithesisWithoutCgoHandler) init_coverage(num_edges uint64, symbols string) uint64 {
return 0
}
func (h *inAntithesisWithoutCgoHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) {
return 0, false
}
func (h *inAntithesisWithoutCgoHandler) lease_generation() (uint64, bool) {
return 0, false
}
func init_in_antithesis() libHandler {
dir, is_set := os.LookupEnv(outputDirEnvVar)
if !is_set || len(dir) == 0 {
return nil
}
path := filepath.Join(dir, fallbackOutputFilename)
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Printf("%s Failed to open path %s: %v", errorLogLinePrefix, path, err)
return nil
}
return &inAntithesisWithoutCgoHandler{file}
}
@@ -1,7 +1,9 @@
//go:build enable_antithesis_sdk && (!linux || !amd64 || !cgo)
//go:build enable_antithesis_sdk && (!linux || !amd64)
package internal
const sdkRunningInDegradedMode = false
func init_in_antithesis() libHandler {
return nil
}
+19
View File
@@ -1,3 +1,22 @@
Release 1.8.1
=============
**Fixes**
* Fixed a panic-causing bug in all Remove functions.
Release 1.8.0
=============
**Changes**
* Added the `Remove` function to all token types, allowing for the easy
removal of a token from its parent element.
**Fixes**
* Cleaned up several comments for clarity and typo corrections.
Release 1.7.1
=============
+73 -26
View File
@@ -214,6 +214,7 @@ type Writer interface {
type Token interface {
Parent() *Element
Index() int
Remove() bool
WriteTo(w Writer, s *WriteSettings)
dup(parent *Element) Token
setParent(parent *Element)
@@ -1390,19 +1391,27 @@ func (e *Element) PrevSibling() *Element {
return nil
}
// Parent returns this element's parent element. It returns nil if this
// element has no parent.
// Parent returns the element's parent element, or nil if the element has no
// parent.
func (e *Element) Parent() *Element {
return e.parent
}
// Index returns the index of this element within its parent element's
// list of child tokens. If this element has no parent, then the function
// returns -1.
// Index returns the index of the element within its parent element's list of
// child tokens. If the element has no parent, the function returns -1.
func (e *Element) Index() int {
return e.index
}
// Remove attempts to remove the element from the parent element that contains
// it. If the element has no parent, the function returns false.
func (e *Element) Remove() bool {
if e.parent == nil {
return false
}
return e.parent.RemoveChild(e) != nil
}
// WriteTo serializes the element to the writer w.
func (e *Element) WriteTo(w Writer, s *WriteSettings) {
w.WriteByte('<')
@@ -1624,7 +1633,7 @@ func (c *CharData) SetData(text string) {
}
}
// IsCData returns true if this CharData token is contains a CDATA section. It
// IsCData returns true if this CharData token contains a CDATA section. It
// returns false if the CharData token contains simple text.
func (c *CharData) IsCData() bool {
return (c.flags & cdataFlag) != 0
@@ -1635,20 +1644,30 @@ func (c *CharData) IsWhitespace() bool {
return (c.flags & whitespaceFlag) != 0
}
// Parent returns this CharData token's parent element, or nil if it has no
// parent.
// Parent returns the CharData token's parent element, or nil if the token has
// no parent.
func (c *CharData) Parent() *Element {
return c.parent
}
// Index returns the index of this CharData token within its parent element's
// list of child tokens. If this CharData token has no parent, then the
// function returns -1.
// Index returns the index of the CharData token within its parent element's
// list of child tokens. If the CharData token has no parent, the function
// returns -1.
func (c *CharData) Index() int {
return c.index
}
// WriteTo serializes character data to the writer.
// Remove attempts to remove the CharData token from the parent element that
// contains it. If the CharData token has no parent, the function returns
// false.
func (c *CharData) Remove() bool {
if c.parent == nil {
return false
}
return c.parent.RemoveChild(c) != nil
}
// WriteTo serializes CharData token to the writer.
func (c *CharData) WriteTo(w Writer, s *WriteSettings) {
if c.IsCData() {
w.WriteString(`<![CDATA[`)
@@ -1719,19 +1738,28 @@ func (c *Comment) dup(parent *Element) Token {
}
}
// Parent returns comment token's parent element, or nil if it has no parent.
// Parent returns the comment's parent element, or nil if the comment has no
// parent.
func (c *Comment) Parent() *Element {
return c.parent
}
// Index returns the index of this Comment token within its parent element's
// list of child tokens. If this Comment token has no parent, then the
// function returns -1.
// Index returns the index of the comment within its parent element's list of
// child tokens. If the comment has no parent, the function returns -1.
func (c *Comment) Index() int {
return c.index
}
// WriteTo serialies the comment to the writer.
// Remove attempts to remove the comment from the parent element that contains
// it. If the comment has no parent, the function returns false.
func (c *Comment) Remove() bool {
if c.parent == nil {
return false
}
return c.parent.RemoveChild(c) != nil
}
// WriteTo serializes the comment to the writer.
func (c *Comment) WriteTo(w Writer, s *WriteSettings) {
w.WriteString("<!--")
sanitizeComment(w, c.Data)
@@ -1783,19 +1811,28 @@ func (d *Directive) dup(parent *Element) Token {
}
}
// Parent returns directive token's parent element, or nil if it has no
// Parent returns the XML directive's parent element, or nil if it has no
// parent.
func (d *Directive) Parent() *Element {
return d.parent
}
// Index returns the index of this Directive token within its parent element's
// list of child tokens. If this Directive token has no parent, then the
// function returns -1.
// Index returns the index of the XML directive within its parent element's
// list of child tokens. If the directive has no parent, the function returns
// -1.
func (d *Directive) Index() int {
return d.index
}
// Remove attempts to remove the XML directive from the parent element that
// contains it. If the directive has no parent, the function returns false.
func (d *Directive) Remove() bool {
if d.parent == nil {
return false
}
return d.parent.RemoveChild(d) != nil
}
// WriteTo serializes the XML directive to the writer.
func (d *Directive) WriteTo(w Writer, s *WriteSettings) {
w.WriteString("<!")
@@ -1851,20 +1888,30 @@ func (p *ProcInst) dup(parent *Element) Token {
}
}
// Parent returns processing instruction token's parent element, or nil if it
// Parent returns XML processing instruction's parent element, or nil if it
// has no parent.
func (p *ProcInst) Parent() *Element {
return p.parent
}
// Index returns the index of this ProcInst token within its parent element's
// list of child tokens. If this ProcInst token has no parent, then the
// function returns -1.
// Index returns the index of the XML processing instruction within its parent
// element's list of child tokens. If the processing instruction has no
// parent, the function returns -1.
func (p *ProcInst) Index() int {
return p.index
}
// WriteTo serializes the processing instruction to the writer.
// Remove attempts to remove the XML processing instruction from the parent
// element that contains it. If the processing instruction has no parent, the
// function returns false.
func (p *ProcInst) Remove() bool {
if p.parent == nil {
return false
}
return p.parent.RemoveChild(p) != nil
}
// WriteTo serializes the XML processing instruction to the writer.
func (p *ProcInst) WriteTo(w Writer, s *WriteSettings) {
w.WriteString("<?")
sanitizeProcInst(w, p.Target)
Loaded 100 of 434 files, more files were not shown because too many files have changed in this diff. Show more