Compare commits

..
Author SHA1 Message Date
dependabot[bot] 48e17bfa73 build(deps): bump github.com/KimMachineGun/automemlimit
Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.7.5 to 1.0.0.
- [Release notes](https://github.com/KimMachineGun/automemlimit/releases)
- [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.7.5...v1.0.0)

---
updated-dependencies:
- dependency-name: github.com/KimMachineGun/automemlimit
  dependency-version: 1.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-16 16:36:45 +00:00
13d3481cfb chore(ci): set dependabot cooldown for github-actions (#13177)
A 7-day cooldown is already imposed before a newly-released GitHub
action may be used, but Dependabot's default cooldown is only 3 days,
so it raises github-actions PRs whose CI fails. Same change as
owncloud/core#41905.

Signed-off-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com>
Co-authored-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 18:33:05 +02:00
Roman PerekhodandClaude Opus 4.8 ee5da2733f fix: [OCISDEV-1053] Warn when resetting a service user password locks out login (#13176)
fix(idm): sync bind config when resetting a service user password

Resetting an IDM service user password with `ocis idm resetpassword
--user-type service` only changed the entry in the IDM directory. Services
such as auth-basic, users and groups still bound to LDAP as the reva service
user using the old bind_password from their configuration, so after a restart
those binds failed and regular admin login started returning 401 Unauthorized.

The command now rewrites the matching bind_password and service_user_passwords
keys in ocis.yaml when it is present, and always prints the environment
variables that must carry the new password for env-var and distributed
deployments it cannot rewrite.

Fixes: https://github.com/owncloud/ocis/issues/12569

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-10-16 15:20:41 +00:00
Roman Perekhod 720e1ee0b3 fix: Remove the unmarshalable request body field from graph log messages (#12915) 2026-10-16 14:07:44 +00:00
Michal Klos 08b6313c8b fix(graph): [OCISDEV-1506] enforce $filter before cross-instance user resolution (#13154) 2026-10-16 14:39:40 +02:00
Prajwol Amatya 0cbd7d3401 [tests-only][full-ci][k8s] test: run e2e ocm test suite with k8s deployment (#13104)
test: run e2e ocm test suite with k8s deployment

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-10-16 16:54:21 +05:45
owncloud-translations-bot[bot] 342f5eb0f1 chore: update translations from transifex (#13163)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-10-16 07:51:57 +00:00
Matteo 70f4e504b6 fix(web): [OCISDEV-1539] show a clear error for deleted public links and files (#13156) 2026-10-16 08:03:15 +02:00
dependabot[bot] 2db76a1c4e build(deps): bump shivammathur/setup-php from 2.37.2 to 2.40.0 in the minor-and-patch group across 1 directory (#13116) 2026-10-15 23:03:02 +02:00
Matteo 408c41dc83 fix(web): [OCISDEV-1555] remove federated connections in the OCM connections panel (#13160) 2026-10-15 18:38:31 +02:00
Matteo c9856ef000 fix(web): [OCISDEV-1540] mark all notifications as read in the notifications menu (#13157) 2026-10-15 18:38:17 +02:00
Lukas Hirt 63fced12a6 fix(collaboration): retry rename and upload while file is processing (#13141)
* fix(collaboration): retry rename and upload while file is processing

RenameFile and PutFile failed with a 500 when the storage answered with CODE_TOO_EARLY because the file was still in postprocessing, e.g. right after PutRelativeFile. This made the wopi-builtin validator flaky. Share the retry-with-backoff logic that DeleteFile already had and apply it to Move and InitiateFileUpload as well. The retries are now bounded.

Signed-off-by: Lukas Hirt <info@hirt.cz>

* fix(collaboration): return context error when retry is cancelled

Return ctx.Err() from retryWhileTooEarly when the context is cancelled, document the intentional no-op after the wait, and add a test for it.

Signed-off-by: Lukas Hirt <info@hirt.cz>

---------

Signed-off-by: Lukas Hirt <info@hirt.cz>
2026-10-15 16:41:05 +02:00
Roman Perekhod e76dc49698 fix: [OCISDEV-1502] The global variable OCIS_CACHE_DATABASE was replaced (#13158) 2026-10-15 13:29:49 +02:00
Pradip Subedi c17c33b6d8 [full-ci][tests-only] test: fix flaky cliCommands tests (#13133)
* test: fix flaky blobstore test

* test: fix flaky backupconsistency test
2026-10-15 14:03:05 +05:45
owncloud-translations-bot[bot] 66e93ceaf3 chore: update translations from transifex (#13143)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-10-15 07:28:51 +00:00
Matteo fba139fdec fix(web): [OCISDEV-1543] show details preview for public link files with spaces in the name (#13150) 2026-10-14 14:03:08 +02:00
Lukas Hirt e0dd0e4348 fix(web): [OCISDEV-1527] disable vertical page overscroll in file apps (#13140)
Scrolling inside an app such as OnlyOffice could make the whole page bounce
with it, exposing the blank page background behind the app frame. Set
overscroll-behavior-y: none on the root element while AppWrapper is mounted
and restore the previous value on unmount. The logic lives in a new
useDisableRootOverscroll composable, which is covered by unit tests.

Signed-off-by: Lukas Hirt <info@hirt.cz>
2026-10-13 21:18:12 +02:00
Matteo 710bdf380a fix(web): [OCISDEV-1513] clean up trash view in the Safe (#13136) 2026-10-13 15:42:01 +02:00
Michal Klos 7b83f36060 fix(proxy): [OCISDEV-1517] add missing /vault/graph routes for activities and invitations (#13109) 2026-10-13 13:15:20 +00:00
Michal Klos 2a23956a8b fix(web): [OCISDEV-1518] show correct message when Safe access is denied for lacking permission (#13111)
* fix(web): [OCISDEV-1518] show correct message when Safe access is denied for lacking permission

* chore: changelog
2026-10-13 11:29:58 +00:00
Prajwol Amatya 9269643c0e [tests-only][full-ci][k8s] test: run e2e app-provider with k8s setup (#13046)
* test: run e2e app-provider with k8s setup

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>

* test: limit app-registry mimetypes

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>

* test: add host for onlyoffice

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>

* test: enable secure view

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>

* test: add available unified roles

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>

---------

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-10-13 16:23:20 +05:45
Matteo 6c8fe4ebf7 fix(web): [OCISDEV-1511] refresh files stuck in processing after upload or copy (#13134)
* fix(web): [OCISDEV-1511] refresh files stuck in processing after upload or copy

A postprocessing-finished event that arrives while a folder reload or a
fetch after copy is still in flight is dropped, because the resource is
not in the store yet. The response then adds the resource as processing
and nothing clears it until a page reload.

Remember finished items for a short time and refetch them when they show
up in the store as processing.

* chore: [OCISDEV-1511] add changelog
2026-10-13 12:22:01 +02:00
kobergjandClaude Opus 5 037ac76d26 ci(release): remove the disabled docker jobs from the release pipeline (#13129)
ci(release): remove the disabled docker jobs from the release pipeline (#13128)

Tagging v9.0.0-rc.1 produced a startup_failure: the workflow was rejected
before any job ran. owncloud pins Actions to an org allowlist
(owncloud/admin:actions-allowlist.yml, allowed_actions: selected with
sha_pinning_required), and three pins in this file are not on it:

  docker/setup-buildx-action @f87e5991 v4.4.1 (allowlist has v4.0.0)
  docker/login-action        @dbcb8138 v4.6.0 (allowlist has v4.1.0)
  docker/build-push-action   @c3c9e263 v7.4.0 (allowlist has v7.0.0)

Allowlist validation happens at parse time, so it does not care that all
three only appear in jobs already marked `if: false`.

Rather than pin them back, drop the jobs. Building, scanning and publishing
the production image moved to owncloud-docker/ocis, which is why these were
disabled in the first place; the image Trivy scan now runs there on every PR.
That leaves nothing to maintain here and removes all three offending pins.

Removes docker-build, docker-scan (dead too: it needs docker-build),
docker-manifest and docker-readme. Nothing outside that subgraph depended on
them, so the `docker_repos` and `is_production` outputs, the
PRODUCTION_RELEASE_TAGS / DOCKER_REPO_ROLLING / DOCKER_REPO_PRODUCTION env
vars and the REPOS computation go with them. is_prerelease stays, as
create-github-release still reads it.

The filesystem scan in security-scan-trivy is untouched.



(cherry picked from commit aab12d018e)

Signed-off-by: Julian Koberg <julian.koberg@kiteworks.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-10-13 09:12:10 +02:00
owncloud-translations-bot[bot] 9faaefa83a chore: update translations from transifex (#13130)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-10-13 07:11:18 +00:00
Prajwol Amatya 85700efcd1 [tests-ony][full-ci][k8s] test: update storageusersvault setup for k8s (#13131)
test: update storageusersvault settings for k8s

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-10-13 10:52:53 +05:45
dependabot[bot] 91a8c76bdb build(deps): bump actions/setup-node from 6.4.0 to 7.1.0 (#13118)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.4.0 to 7.1.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6.4.0...949feb2413d6458794dcd2491c4babbbce0c15c1)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 7.1.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-10-12 19:44:39 +02:00
dependabot[bot] 88e2780a54 build(deps): bump actions/upload-artifact from 4.6.2 to 7.0.2 (#13117)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.2 to 7.0.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.6.2...cf430e030ddbb5b0abf93d22962f4752f3646cd9)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.2
  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-10-12 16:22:42 +02:00
dependabot[bot] 60fcb2e214 build(deps): bump actions/download-artifact from 4.3.0 to 8.0.2 (#13119)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.3.0 to 8.0.2.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4.3.0...9000827ccba6bdab643e8b6fd33ac0654aef8333)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.2
  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-10-12 16:22:20 +02:00
dependabot[bot] c8224fd434 build(deps): bump the minor-and-patch group across 1 directory with 7 updates (#13126)
Bumps the minor-and-patch group with 7 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/go-chi/httprate](https://github.com/go-chi/httprate) | `0.16.0` | `0.16.1` |
| [github.com/go-ldap/ldap/v3](https://github.com/go-ldap/ldap) | `3.4.14` | `3.4.15` |
| [github.com/nats-io/nats-server/v2](https://github.com/nats-io/nats-server) | `2.15.0` | `2.15.1` |
| [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) | `1.24.1` | `1.25.0` |
| [github.com/tidwall/gjson](https://github.com/tidwall/gjson) | `1.19.1` | `1.20.0` |
| [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) | `0.71.0` | `0.72.0` |
| [golang.org/x/sync](https://github.com/golang/sync) | `0.23.0` | `0.24.0` |



Updates `github.com/go-chi/httprate` from 0.16.0 to 0.16.1
- [Release notes](https://github.com/go-chi/httprate/releases)
- [Commits](https://github.com/go-chi/httprate/compare/v0.16.0...v0.16.1)

Updates `github.com/go-ldap/ldap/v3` from 3.4.14 to 3.4.15
- [Release notes](https://github.com/go-ldap/ldap/releases)
- [Commits](https://github.com/go-ldap/ldap/compare/v3.4.14...v3.4.15)

Updates `github.com/nats-io/nats-server/v2` from 2.15.0 to 2.15.1
- [Release notes](https://github.com/nats-io/nats-server/releases)
- [Changelog](https://github.com/nats-io/nats-server/blob/main/RELEASES.md)
- [Commits](https://github.com/nats-io/nats-server/compare/v2.15.0...v2.15.1)

Updates `github.com/prometheus/client_golang` from 1.24.1 to 1.25.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/v1.25.0/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.24.1...v1.25.0)

Updates `github.com/tidwall/gjson` from 1.19.1 to 1.20.0
- [Commits](https://github.com/tidwall/gjson/compare/v1.19.1...v1.20.0)

Updates `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` from 0.71.0 to 0.72.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go-contrib/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go-contrib/compare/zpages/v0.71.0...zpages/v0.72.0)

Updates `golang.org/x/sync` from 0.23.0 to 0.24.0
- [Commits](https://github.com/golang/sync/compare/v0.23.0...v0.24.0)

---
updated-dependencies:
- dependency-name: github.com/go-chi/httprate
  dependency-version: 0.16.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: github.com/go-ldap/ldap/v3
  dependency-version: 3.4.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: github.com/nats-io/nats-server/v2
  dependency-version: 2.15.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.25.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: github.com/tidwall/gjson
  dependency-version: 1.20.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
  dependency-version: 0.72.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: golang.org/x/sync
  dependency-version: 0.24.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-12 16:13:34 +02:00
Firas Frikha 69433426be chore(deps): [OCISDEV-901] bump reva to the legacy upload removal (#13112)
Signed-off-by: Firas Frikha <firas.frikha@kiteworks.com>
2026-10-12 11:51:14 +02:00
Matteo 9015eec558 fix(vault): [OCISDEV-1503] fix signed URL downloads in vault mode (#13097)
Save the MFA status after the user is resolved so signed-URL downloads
inherit it, and check its age on read. Build the signing-key URL with
the URL API so it works with the vault base URL.
2026-10-12 10:28:49 +02:00
owncloud-translations-bot[bot] 5129853267 chore: update translations from transifex (#13114)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-10-12 09:36:26 +02:00
Michal Klos a669541b13 fix(notifications): [OCISDEV-1515] redact file/space names in vault share and membership emails (#13099) 2026-10-12 09:32:19 +02:00
Prajwol Amatya c0c15f8cab chore: bump golang.org/x/net version (#13120) 2026-10-12 09:31:15 +02:00
Roman PerekhodandClaude Sonnet 5 2e377bde67 fix: [OCISDEV-1476] fix AuthApp requests failing with a custom PROXY_… (#13078) (#13107)
* fix: [OCISDEV-1476] fix AuthApp requests failing with a custom PROXY_USER_OIDC_CLAIM

* fix: [OCISDEV-1476] map ErrAccountNotFound to 401 in verifyUser

AccountResolver.verifyUser only mapped ErrAccountDisabled to 401 before
falling through to a generic 500. The identity backend excludes disabled
accounts from by-username lookups and returns ErrAccountNotFound instead,
so a disabled user authenticating via AppAuth or basic auth got a 500
instead of a 401, caught by the acceptance test suite.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-09 13:37:34 +00:00
Roman PerekhodandClaude Sonnet 5 703bbe1113 fix: [OCISDEV-1523] fix the LDAP master-ID filter for an empty base filter (#13100)
* fix: [OCISDEV-1523] fix the LDAP master-ID filter for an empty base filter

EnhanceFilterWithMasterID replaced an empty LDAP filter with a master-ID-only
filter. This action restricted an unrestricted search to master-ID users
only. The bug broke the cross-instance user search in multi-instance
deployments. The function now keeps an empty filter unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix: [OCISDEV-1523] require an explicit LDAP user filter with a master ID

EnhanceFilterWithMasterID in ocis-pkg/ldap/filter.go now keeps an empty
LDAP filter unchanged instead of restricting it to master-ID users only.
The auth-basic, users, groups, and graph services reuse this function to
compute their default LDAP user filter at startup.

An unset filter now means these services resolve or authenticate every
user in the shared LDAP directory, not only master-ID users. This action
is a behavior change for a deployment that sets
OCIS_MULTI_INSTANCE_MASTER_ID without an explicit OCIS_LDAP_USER_FILTER.

Each service now rejects startup when OCIS_MULTI_INSTANCE_MASTER_ID is
set and its own user filter is empty. This action keeps a multi-instance
deployment scoped to its own users by default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* refactor: [OCISDEV-1523] simplify EnhanceFilterWithMasterID guard clauses

The function collapses three early-return guards into one condition.
This action removes a duplicated rationale comment between filter.go
and filter_test.go.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs: [OCISDEV-1523] point the changelog entry at the master backport PR

The changelog entry pointed at PR 13096, the stable-8.2 backport. This
commit points the entry at the master-branch PR number instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-09 15:27:27 +02:00
Paul FaureandClaude Opus 5.5 1347e3607d fix(proxy): don't log an error when create-home finds no user (#13102)
Requests on unprotected routes can carry a reva token without a resolved
user: reva's internal downloads to the data gateway (/data) are sent with
the caller's token. create_home logged "no user in context" at error level
for each of them, so every download added an error line. Log at debug with
the path instead; the request is passed on unchanged, as before.

Fixes #13101


Claude-Session: https://claude.ai/code/session_01WpoeSoKYEdgQcWjEzTVKpT

Signed-off-by: Paul Faure <paul@faure.ca>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:50:55 +02:00
isha 9e2a79d0f2 [full-ci][tests-only][k8s] test: run part-2 e2e suites on k8s deployment (#13037)
test: run e2e suites on k8s deployment
2026-10-09 17:08:00 +05:45
Matteo 841dd9b948 fix(web): [OCISDEV-1509] show error instead of empty message when space trash is not accessible (#13105) 2026-10-09 13:22:28 +02:00
887796c36d fix(audit): record the acting user in the audit log's User field (#13051)
The file and folder converters filled User from the event's Owner, which
reva does not set, so the field was empty on every upload, download, move,
delete, restore and version restore; where Owner was set it named the owner
instead of the actor. Space, user and group converters hard-coded User to
an empty string although every one of those events carries the Executant.

User now comes from the event's Executant everywhere an actor exists. The
Owner field of file events is unchanged; the failed public-link access
event has no actor and keeps an empty User.

Tests give the fixtures different owner and actor ids so they can tell the
two apart (they fail on the previous code), and add cases for the user and
group converters. The group member added/removed messages passed the user
and group ids in swapped order; fixed.

Fixes #4789

Signed-off-by: Paul Faure <paul@faure.ca>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Juan Pablo Villafañez <jpvillafanez@izertis.com>
2026-10-09 11:44:39 +02:00
owncloud-translations-bot[bot] 02c52130bb chore: update translations from transifex (#13103)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-10-09 08:25:48 +00:00
kobergjandClaude Opus 5 76a9cb8042 docs: replace envvar introductionVersion 8.3.0 with 9.0.0 (#13106)
The next oCIS release is 9.0.0, so all envvars that were annotated with
the previously planned 8.3.0 introduction version need to be updated.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-10-09 10:20:09 +02:00
Paul FaureandClaude Opus 5.5 b5f843e99b feat(search): add a --timeout flag to the index command (#13053)
* feat(search): add a --timeout flag to the index command

ocis search index called the search service with a hard-coded 10 minute
request timeout. The service walks the whole space inside that request, so
when the timeout expired the walk was cancelled (error walking the tree:
context canceled) and everything after that point stayed unindexed. A space
whose walk takes longer than ten minutes could never be fully indexed from
the command line.

The timeout is now a flag: --timeout takes a duration, default 10m so the
behaviour is unchanged out of the box; 0 waits indefinitely (go-micro treats
a zero RequestTimeout as an already-expired deadline, so a far-off one is
substituted).

Fixes #13052

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>

* docs(search): say the index command needs the running search service

The index command is a gRPC client of the search service and never opens
the Bleve index, so it works with the default exclusive lock
(SEARCH_ENGINE_BLEVE_SCALE=false) but needs the service running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpoeSoKYEdgQcWjEzTVKpT
Signed-off-by: Paul Faure <paul@faure.ca>

---------

Signed-off-by: Paul Faure <paul@faure.ca>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 09:54:38 +02:00
Paul FaureandClaude Opus 5.5 be21f76688 feat(audit): record tag changes in the audit log (#13055)
* feat(audit): record tag changes in the audit log

Graph publishes TagsAdded and TagsRemoved on every tag assign and unassign,
but only the search service listened, so a tag change left no trace in the
audit log.

The audit service now registers both events and logs them as file_tags_add
and file_tags_remove, with the acting user (Executant), the space owner, the
file id and path, and the comma-separated tags. Graph sets the Timestamp on
both events, which it left unset. Two test cases use different owner and
actor ids; the audit README documents the two actions.

Fixes #13054

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>

* fix(audit): record only the tags that actually changed; skip no-op tag events

Review follow-up for #13055:
- graph: TagsAdded/TagsRemoved now carry the tags that were actually added
  or removed (requesting an existing tag, or removing an absent one, is not
  a change). Search only uses the event's Ref, so it is unaffected.
- audit: skip tag events whose tag list is empty. Graph still publishes
  TagsRemoved for search when nothing was present; that is not an audit event.
- audit: document why User is the executant for tag events; describe Tags
  as carried by the event; remove a stray copy-pasted doc comment.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpoeSoKYEdgQcWjEzTVKpT
Signed-off-by: Paul Faure <paul@faure.ca>

* fix(audit): carry the requested tags in tag events, as before

Per review: TagsAdded/TagsRemoved go back to carrying the tags as
requested, and the audit log records every request, including tags that
were already present (or absent, for a removal), so repeated requests stay
visible. Computing the actual delta belongs in the tags package, not here.

Removes the graph-side tagsDiff helper and its test, and the audit
service's skip for empty tag lists. The other review fixes stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpoeSoKYEdgQcWjEzTVKpT
Signed-off-by: Paul Faure <paul@faure.ca>

---------

Signed-off-by: Paul Faure <paul@faure.ca>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 09:54:17 +02:00
Firas Frikha d90dfa7085 refactor(storage-users): [OCISDEV-1382] list upload sessions through the coordinator (#13098)
* refactor(storage-users): [OCISDEV-1382] list upload sessions through the coordinator

Signed-off-by: Firas Frikha <firas.frikha@kiteworks.com>

* fix(storage-users): [OCISDEV-1382] use a safe type assertion for the driver config

Signed-off-by: Firas Frikha <firas.frikha@kiteworks.com>

---------

Signed-off-by: Firas Frikha <firas.frikha@kiteworks.com>
2026-10-09 08:58:54 +02:00
Matteo f7453530f6 chore(web): [OCISDEV-1501] remove vault MFA session extension popup (#13085)
Remove the "Session expiring" extend/dismiss popup and its expiry
worker. Drop the frontend session_duration capability and config;
OCIS_MFA_SESSION_DURATION stays in use by the proxy.
2026-10-08 18:54:57 +02:00
Prajwol Amatya 29c01920f8 [tests-only][full-ci] test: fix flakiness in e2e-part-2 (#13092)
test: wait for password input field before A11y scan

Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
2026-10-08 14:44:02 +05:45
owncloud-translations-bot[bot] 0ffb415e89 chore: update translations from transifex (#13091)
Co-authored-by: owncloud-translations-bot[bot] <274778013+owncloud-translations-bot[bot]@users.noreply.github.com>
2026-10-08 08:51:49 +02:00
LarsJurgensenandFiras Frikha cc8c1c883f ci: [k6-test] [OCISDEV-900] Extract upload coordinator out of decomposedfs (#12913)
* chore(OCISDEV-900): bump reva to pr7-switchover, add upload_directory and mount_id to revaconfig

* chore(OCISDEV-900): bump reva to the switchover rebased on the upload write fix

* chore(OCISDEV-900): bump reva to main with the upload coordinator switchover

---------

Co-authored-by: Firas Frikha <firas.frikha@kiteworks.com>
2026-10-07 18:28:34 +02:00
Michal Klos 90d58ae47d feat: [OCISDEV-1437] show suggested expiry date of 30 days (#12988) 2026-10-07 16:03:09 +02:00
410 changed files with 30030 additions and 11245 deletions

No files matched your search

+2
View File
@@ -65,6 +65,8 @@ updates:
day: sunday
time: '22:00'
timezone: Etc/UTC
cooldown:
default-days: 7
open-pull-requests-limit: 5
groups:
minor-and-patch:
+26 -26
View File
@@ -62,14 +62,14 @@ jobs:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.33.3 --activate
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip, ldap, gd
@@ -165,7 +165,7 @@ jobs:
exit $FAILED
- name: Upload build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ocis-build-artifacts
path: |
@@ -231,7 +231,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip, ldap, gd
@@ -280,7 +280,7 @@ jobs:
'
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -294,7 +294,7 @@ jobs:
- name: Upload raw coverage data
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: api-coverage-${{ matrix.suite }}
path: ${{ env.GOCOVERDIR }}
@@ -315,7 +315,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip, ldap, gd
@@ -328,7 +328,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -342,7 +342,7 @@ jobs:
- name: Upload raw coverage data
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: api-coverage-cli-${{ matrix.suite }}
path: ${{ env.GOCOVERDIR }}
@@ -363,7 +363,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip, ldap, gd
@@ -376,7 +376,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -390,7 +390,7 @@ jobs:
- name: Upload raw coverage data
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: api-coverage-ldap-pool-${{ matrix.suite }}
path: ${{ env.GOCOVERDIR }}
@@ -419,7 +419,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip, ldap, gd
@@ -468,7 +468,7 @@ jobs:
'
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -485,7 +485,7 @@ jobs:
- name: Upload raw coverage data
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: api-coverage-core-${{ matrix.suite }}
path: ${{ env.GOCOVERDIR }}
@@ -534,7 +534,7 @@ jobs:
vault_storage: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
# 24.16.0 breaks playwright install (yauzl zip extraction hangs); pin to last known good.
# https://github.com/microsoft/playwright/issues/40724
@@ -551,7 +551,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -683,7 +683,7 @@ jobs:
- name: Upload tracing result
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-traces-${{ matrix.suite }}-${{ github.run_attempt }}
path: web/reports/e2e
@@ -691,7 +691,7 @@ jobs:
- name: Upload a11y result
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-a11y-result-${{ matrix.suite }}-${{ github.run_attempt }}
path: web/reports/e2e/a11y-report.json
@@ -712,7 +712,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -737,7 +737,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -762,7 +762,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -787,7 +787,7 @@ jobs:
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ocis-build-artifacts
@@ -809,7 +809,7 @@ jobs:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
@@ -842,7 +842,7 @@ jobs:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
@@ -876,7 +876,7 @@ jobs:
cache: true
- name: Download raw coverage data
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: api-coverage-*
path: ${{ env.GOCOVERDIR }}
+122 -9
View File
@@ -82,7 +82,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup PHP ${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: ${{ env.PHP_VERSION }}
extensions: curl, xml, mbstring, zip, ldap, gd
@@ -447,7 +447,7 @@ jobs:
e2e-tests:
name: e2e-${{ matrix.suite }}-k8s
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 120
if: >-
github.event_name == 'schedule' ||
@@ -459,14 +459,45 @@ jobs:
fail-fast: false
matrix:
include:
- suite: smoke
# - suite: part-1
# args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 1"
- suite: part-2
args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 2"
# - suite: part-3
# args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 3"
# - suite: part-4
# args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 4"
# - suite: search
# args: "--type playwright --suites search"
# tika: true
# - suite: keycloak
# args: "--type playwright --suites journeys,keycloak"
# keycloak: true
# - suite: mfa
# args: "--type playwright --suites mfa"
# mfa: true
# - suite: oidc
# args: "--type playwright specs/oidc/refreshToken.spec.ts"
# oidc: true
# - suite: oidc-iframe
# args: "--type playwright specs/oidc/iframeTokenRenewal.spec.ts"
# oidc_iframe: true
- suite: app-provider
args: "--type playwright --suites app-provider"
collaboration: true
- suite: ocm
args: "--type playwright --suites ocm"
federated: true
# - suite: vault-storage
# args: "--type playwright --suites vault-storage"
# vault_storage: true
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
# 24.16.0 breaks playwright install (yauzl zip extraction hangs); pin to last known good.
# https://github.com/microsoft/playwright/issues/40724
@@ -509,13 +540,92 @@ jobs:
run: make -C tests/config/k8s create-cluster
- name: Prepare Helm Charts
run: make -C tests/config/k8s prepare-charts
env:
ENABLE_WOPI: ${{ matrix.suite == 'app-provider' }}
ENABLE_OCM: ${{ matrix.suite == 'ocm' }}
run: |
cd tests/config/k8s
make prepare-charts
if [[ "${{ matrix.suite }}" == "ocm" ]]; then
OCM=true make prepare-charts
fi
- name: Deploy Suite-Specific External Backends
run: |
if [[ "${{ matrix.suite }}" == "app-provider" ]]; 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 \
--add-host "$TEST_SERVER_DOMAIN:host-gateway" \
-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 "$TEST_SERVER_DOMAIN" -Aw &
make deploy-ocis
if [[ "${{ matrix.suite }}" == "ocm" ]]; then
OCM=true make deploy-ocis
fi
- name: Expose node ports
if: ${{ matrix.suite == 'app-provider' }}
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:
@@ -584,14 +694,17 @@ jobs:
- name: Run e2e ${{ matrix.suite }} tests
env:
E2E_ARGS: "--suites ${{ matrix.suite }}"
E2E_ARGS: "${{ matrix.args }}"
K8S: ${{ env.K8S }}
TEST_SERVER_URL: ${{ env.TEST_SERVER_URL }}
COLLABORATION_NEEDED: ${{ matrix.collaboration == true && 'true' || 'false' }}
FED_SERVER_URL: ${{ env.FED_SERVER_URL }}
FEDERATED_NEEDED: ${{ matrix.federated == true && 'true' || 'false' }}
run: python3 tests/acceptance/run-e2e.py
- name: Upload Playwright traces
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-traces-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
path: web/reports/e2e
@@ -599,7 +712,7 @@ jobs:
- name: Upload a11y result
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-a11y-result-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
path: web/reports/e2e/a11y-report.json
@@ -607,7 +720,7 @@ jobs:
- name: Upload oCIS logs
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ocis-logs-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
path: tests/config/k8s/logs
+1 -1
View File
@@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.15.0
registry-url: "https://registry.npmjs.org"
+15 -186
View File
@@ -14,9 +14,6 @@ on:
default: ''
env:
PRODUCTION_RELEASE_TAGS: '5.0,7,8'
DOCKER_REPO_ROLLING: owncloud/ocis-rolling
DOCKER_REPO_PRODUCTION: owncloud/ocis
NODE_VERSION: '24'
PNPM_VERSION: '10.28.1'
GOLANG_BUILD_IMAGE: 'golang:1.26.8-alpine3.23@sha256:a8fa79c5bd40d880b52bd3b6d7669ecdcfd00e85facdd427d279efb5ddd79cb1'
@@ -27,9 +24,7 @@ jobs:
timeout-minutes: 10
outputs:
version: ${{ steps.info.outputs.version }}
is_production: ${{ steps.info.outputs.is_production }}
is_prerelease: ${{ steps.info.outputs.is_prerelease }}
docker_repos: ${{ steps.info.outputs.docker_repos }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: ${{ github.ref_type == 'branch' || (github.event_name == 'workflow_dispatch' && inputs.version_override == '') }}
@@ -75,23 +70,10 @@ jobs:
exit 1
fi
IS_PRODUCTION=false
for TAG in ${PRODUCTION_RELEASE_TAGS//,/ }; do
[[ "$VERSION" == "$TAG"* ]] && IS_PRODUCTION=true && break
done
[[ "$VERSION" == *"-"* ]] && IS_PRERELEASE=true || IS_PRERELEASE=false
if [[ "$IS_PRODUCTION" == "true" && "$IS_PRERELEASE" == "false" ]]; then
REPOS=[\"$DOCKER_REPO_ROLLING\",\"$DOCKER_REPO_PRODUCTION\"]
else
REPOS=[\"$DOCKER_REPO_ROLLING\"]
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_production=$IS_PRODUCTION" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
echo "docker_repos=$REPOS" >> $GITHUB_OUTPUT
generate-code:
runs-on: ubuntu-latest
@@ -102,7 +84,7 @@ jobs:
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
- run: npm install --silent -g yarn npx --force
@@ -119,7 +101,7 @@ jobs:
run: |
VERSION="${{ needs.determine-release-type.outputs.version }}"
sed -i "s/LatestTag = \".*\"/LatestTag = \"$VERSION\"/" ocis-pkg/version/version.go
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: generated-code
path: |
@@ -128,159 +110,6 @@ jobs:
!web
retention-days: 1
docker-build:
if: false
name: docker-build (${{ matrix.arch }}, ${{ matrix.repo }})
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
timeout-minutes: 120
needs: [determine-release-type, generate-code, security-scan-trivy]
strategy:
matrix:
arch: [amd64, arm64]
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: generated-code
path: .
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: goversion
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- run: |
ALPINE_VERSION=$(grep '^FROM.*alpine:' ocis/docker/Dockerfile.linux.${{ matrix.arch }} | grep -o 'alpine:[0-9.]*' | cut -d: -f2 | cut -d. -f1,2)
docker run --rm \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
"golang:${{ steps.goversion.outputs.go-version }}-alpine${ALPINE_VERSION}" \
sh -c "apk add --no-cache bash gcc musl-dev vips-dev make git && \
git config --global --add safe.directory /workspace && \
CGO_ENABLED=1 ENABLE_VIPS=true VERSION=${{ needs.determine-release-type.outputs.version }} \
make -C ocis release-linux-docker-${{ matrix.arch }}"
- id: tags
run: |
VERSION="${{ needs.determine-release-type.outputs.version }}"
REPO="${{ matrix.repo }}"
ARCH="${{ matrix.arch }}"
printf "tags<<EOF\n%s\nEOF\n" \
"${REPO}:${VERSION}-linux-${ARCH}" >> $GITHUB_OUTPUT
- id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: ocis
file: ocis/docker/Dockerfile.linux.${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
load: true
push: false
provenance: false
build-args: |
REVISION=${{ github.sha }}
VERSION=${{ needs.determine-release-type.outputs.version }}
tags: ${{ steps.tags.outputs.tags }}
- id: trivy
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
continue-on-error: true
with:
image-ref: ${{ steps.tags.outputs.tags }}
format: table
exit-code: 1
severity: HIGH,CRITICAL
ignore-unfixed: true
skip-files: /usr/bin/gomplate,/usr/bin/wait-for
hide-progress: true
env:
TRIVY_IGNOREFILE: .trivyignore
- name: Block on vulnerabilities
if: steps.trivy.outcome == 'failure'
run: |
echo "::error title=Security scan blocked release::Image ${{ steps.tags.outputs.tags }} has HIGH or CRITICAL vulnerabilities (see Trivy report above). Fix all findings before releasing."
exit 1
- name: push
if: steps.trivy.outcome == 'success'
run: docker push ${{ steps.tags.outputs.tags }}
docker-scan:
name: docker-scan (${{ matrix.arch }}, ${{ matrix.repo }})
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [determine-release-type, docker-build]
strategy:
matrix:
arch: [amd64]
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
id: trivy
continue-on-error: true
with:
image-ref: ${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-${{ matrix.arch }}
format: table
exit-code: 1
severity: HIGH,CRITICAL
ignore-unfixed: true
skip-files: /usr/bin/gomplate,/usr/bin/wait-for
hide-progress: true
env:
TRIVY_IGNOREFILE: .trivyignore
- name: Block on vulnerabilities
if: steps.trivy.outcome == 'failure'
run: |
echo "::error title=Security scan blocked release::Image ${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-${{ matrix.arch }} has HIGH or CRITICAL vulnerabilities (see Trivy report above). Fix all findings before releasing."
exit 1
docker-manifest:
if: false
name: docker-manifest (${{ matrix.repo }})
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [determine-release-type, docker-build, docker-scan]
strategy:
matrix:
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- if: ${{ contains(matrix.repo, 'rolling') }}
run: |
docker buildx imagetools create \
-t "${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}" \
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-amd64" \
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-arm64"
- if: ${{ !contains(matrix.repo, 'rolling') }}
run: |
docker buildx imagetools create \
-t "${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}" \
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-amd64" \
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-arm64"
docker-readme:
if: false
name: docker-readme (${{ matrix.repo }})
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [determine-release-type, docker-manifest]
strategy:
matrix:
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ matrix.repo }}
readme-filepath: ocis/README.md
build-binaries:
name: build-binaries (${{ matrix.os }})
runs-on: ubuntu-latest
@@ -291,7 +120,7 @@ jobs:
os: [linux, darwin]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: generated-code
path: .
@@ -304,7 +133,7 @@ jobs:
if [[ "${{ matrix.os }}" == "linux" ]]; then
cp assets/End-User-License-Agreement-for-ownCloud-Infinite-Scale.pdf ocis/dist/release/
fi
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: binaries-${{ matrix.os }}
path: ocis/dist/release/*
@@ -329,11 +158,11 @@ jobs:
needs: [determine-release-type, generate-code]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: generated-code
path: .
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
@@ -347,7 +176,7 @@ jobs:
- run: make ci-node-check-licenses && make ci-node-save-licenses
- run: make ci-go-check-licenses && make ci-go-save-licenses
- run: tar -czf third-party-licenses.tar.gz -C third-party-licenses .
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: third-party-licenses
path: third-party-licenses.tar.gz
@@ -371,7 +200,7 @@ jobs:
if [[ $(wc -l < ocis/dist/CHANGELOG.md) -lt 5 ]]; then
echo "Development release — no release notes yet. See [unreleased changes](https://github.com/owncloud/ocis/tree/master/changelog/unreleased/)." > ocis/dist/CHANGELOG.md
fi
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: changelog
path: ocis/dist/CHANGELOG.md
@@ -382,19 +211,19 @@ jobs:
timeout-minutes: 30
needs: [determine-release-type, build-binaries, license-check, generate-changelog, security-scan-trivy]
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: binaries-linux
path: release-assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: binaries-darwin
path: release-assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: third-party-licenses
path: release-assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: changelog
path: .
@@ -419,15 +248,15 @@ jobs:
- create-github-release
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: binaries-linux
path: release-assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: binaries-darwin
path: release-assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: third-party-licenses
path: release-assets
+1 -1
View File
@@ -77,7 +77,7 @@ jobs:
version: 10.33.3
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.15.0
cache: pnpm
@@ -0,0 +1,13 @@
Bugfix: Fix AuthApp and basic auth requests with custom PROXY_USER_OIDC_CLAIM
We fixed AuthApp (app password) and HTTP basic auth requests returning an
internal server error whenever PROXY_USER_OIDC_CLAIM was set to anything
other than its default value. Both authenticators put the already
authenticated user directly into the request context instead of faking
incomplete claims for the account resolver to re-resolve. We also made sure
a user who only ever authenticates this way still gets a default role
assigned, and that these requests keep getting rejected on deployments with
multiple instances enabled, since neither carries tenant-membership
information.
https://github.com/owncloud/ocis/pull/13107
@@ -0,0 +1,20 @@
Bugfix: Record the acting user in the audit log's User field
The audit log's `User` field is documented as the UID of the user performing
the action, but the file and folder converters filled it from the event's
`Owner`, which reva does not set, so the field was empty on every upload,
download, move, delete, restore and version restore. Where an event did carry
an owner, `User` named the owner rather than the person acting, for example a
share recipient uploading into a shared folder. Space, user and group events
hard-coded the field to an empty string although every one of those events
carries the actor.
`User` is now taken from the event's `Executant` for all of these events. The
`Owner` field of file events is unchanged. The failed public-link access event
still has no actor and keeps an empty `User`.
While adding tests for the user and group events, the group member added and
removed messages turned out to pass the user and group ids in the wrong order,
naming the group as the user and the user as the group; that is fixed too.
https://github.com/owncloud/ocis/issues/4789
@@ -0,0 +1,11 @@
Bugfix: Show a clear error for deleted public links and files in app views
Opening a file via a public link in an app such as the preview, after the link
or the file had been deleted, showed the message "Unknown error". The server
answers with an empty 404, which the WebDAV client turns into a generic message,
and app views that failed while loading the folder passed only that message on.
These views now show "The resource could not be located, it may not exist
anymore.", as the other loading paths already did.
https://github.com/owncloud/ocis/issues/13138
https://github.com/owncloud/ocis/pull/13156
@@ -0,0 +1,9 @@
Bugfix: Show image preview for files with spaces in the name on public links
The preview in the details panel was not shown for files opened via a public
link when the file name contained spaces. The preview URL was used unquoted in a
CSS `url()`, so the browser dropped it and never requested the thumbnail. The
URL is now quoted.
https://github.com/owncloud/ocis/issues/13137
https://github.com/owncloud/ocis/pull/13150
@@ -0,0 +1,10 @@
Bugfix: Disable rubber-band overscroll of the page in file apps
Scrolling to the top or bottom of the content in a file app such as
OnlyOffice, Collabora or the text editor could make the whole page bounce
along with it, including the top bar and the app frame, briefly revealing the
blank page background behind them. The vertical elastic overscroll of the page
is now disabled while a file is open in one of these apps, so the surrounding
layout stays in place.
https://github.com/owncloud/ocis/pull/13140
@@ -0,0 +1,11 @@
Bugfix: Files no longer stay in processing after upload or copy
After uploading or copying files, some of them sometimes stayed greyed out as
"processing" until the page was reloaded. This happened when processing
finished while the file list was still being loaded: the update from the
server was ignored and the list then showed the file as still processing.
Files whose processing has finished are now refreshed automatically when they
show up in the file list as processing.
https://github.com/owncloud/ocis/pull/13134
@@ -0,0 +1,13 @@
Bugfix: Remove the unmarshalable request body field from graph log messages
We've removed the `body` field from the log messages of the graph service's HTTP
handlers. The field was set from `http.Request.Body`, an `io.ReadCloser`, which
can never be serialized into a useful log value.
The tracing middleware replaces the request body with a wrapper that carries an
exported function field, so serializing it failed outright and the log line was
emitted with `"body": "marshaling error: json: unsupported type: func(int64)"`
instead of the payload. Without the tracing middleware the field serialized to an
empty object. In both cases the intended payload was never logged.
https://github.com/owncloud/ocis/pull/12915
@@ -0,0 +1,15 @@
Bugfix: Keep bind config in sync when resetting a service user password
Resetting an IDM service user password with `ocis idm resetpassword
--user-type service` only changed the entry in the IDM directory. Services such
as auth-basic, users and groups still bound to LDAP as the `reva` service user
using the old `bind_password` from their configuration, so after a restart
those binds failed and regular admin login started returning 401 Unauthorized.
The command now rewrites the matching `bind_password` and
`service_user_passwords` keys in `ocis.yaml` when it is present, and always
prints the environment variables that must carry the new password for env-var
and distributed deployments it cannot rewrite.
https://github.com/owncloud/ocis/pull/13176
https://github.com/owncloud/ocis/issues/12569
@@ -0,0 +1,25 @@
Bugfix: Fix the LDAP master-ID filter when the base filter is empty
The function `EnhanceFilterWithMasterID` in `ocis-pkg/ldap/filter.go` adds a
master-ID clause to an LDAP filter with OR. An empty filter means "no
restriction". Before this fix, the function replaced an empty filter with a
master-ID-only filter. This action restricted an unrestricted search to
master-ID users only.
The bug broke the search for a user on another instance in multi-instance
deployments. This search uses the Graph API endpoint `/graph/v1.0/users`.
Multi-instance deployments use this search to find a user to share a resource
with.
Now the function keeps an empty filter unchanged. The function still adds a
master-ID clause to a filter that is not empty.
The `graph`, `auth-basic`, `users`, and `groups` services also use this
function to compute their default LDAP user filter when
`OCIS_MULTI_INSTANCE_MASTER_ID` is set. An empty user filter now means these
services resolve or authenticate every user in the shared LDAP directory,
not only master-ID users. Each of these services now rejects startup when
`OCIS_MULTI_INSTANCE_MASTER_ID` is set and its own user filter is empty.
Set an explicit `OCIS_LDAP_USER_FILTER` for every multi-instance deployment.
https://github.com/owncloud/ocis/pull/13100
@@ -0,0 +1,10 @@
Bugfix: Mark all notifications as read
Clicking "Mark all read" in the notifications menu only cleared the list
visually. The request sent to the server was malformed, so the notifications
were not deleted and reappeared after a page reload. This affected the regular
view as well as the Safe.
The request is now sent correctly and the notifications are removed for good.
https://github.com/owncloud/ocis/pull/13157
@@ -0,0 +1,9 @@
Bugfix: Remove federated connections
Removing a federated connection in the connections panel sent a malformed
request to the server, so the connection was not actually removed and could
reappear after a page reload.
The request is now sent correctly and the connection is removed for good.
https://github.com/owncloud/ocis/pull/13160
@@ -0,0 +1,8 @@
Bugfix: Stop logging "no user in context" for data gateway requests
The proxy's create-home middleware logged an error for every request that
carried a reva token but no user. reva's internal downloads through the data
gateway (`/data`) are such requests, so every file download added an
error-level line. These requests are now passed on with a debug-level log.
https://github.com/owncloud/ocis/issues/13101
@@ -0,0 +1,10 @@
Bugfix: Show an error instead of "no deleted files" for inaccessible trash
Members of a space who are not allowed to list its trash, for example members
with the "Can edit" role, were told that the space has no deleted files, even
though files had been deleted. The trash view now tells the user that the
deleted files could not be loaded and that they might lack the permission to
view them. A trash that is really empty still shows the "no deleted files"
message.
https://github.com/owncloud/ocis/pull/13105
@@ -0,0 +1,10 @@
Bugfix: Clean up the trash view in the Safe
The trash offered a "Copy permanent link" action for deleted items, which
cannot be linked to. The action is no longer shown for deleted items.
The personal space in the trash was labelled "Personal" in the Safe, while the
rest of the interface calls it "Safe-Personal". The trash now uses the same
name.
https://github.com/owncloud/ocis/pull/13136
@@ -0,0 +1,8 @@
Bugfix: Show correct message when Safe access is denied for lacking permission
A user without permission to use the Safe who opened the Safe URL directly was
shown "Not logged in" with a "Log in again" button, even though they were
still logged in. The page now shows "Access denied" with a "Continue" button
that returns to the app for this case.
https://github.com/owncloud/ocis/pull/13111
@@ -0,0 +1,8 @@
Bugfix: Vault share search could show ineligible users
Searching for a share recipient by a cross-instance reference (e.g.
`user@school`) could return a user without vault access, letting them be
selected in the Safe share picker before failing with an error afterward.
Vault eligibility is now always enforced for this kind of search too.
https://github.com/owncloud/ocis/pull/13154
@@ -0,0 +1,13 @@
Bugfix: Fix file and folder downloads in vault mode
Downloading a file in the vault failed with a 403 error. A download uses a
signed link without a login token. Thus the proxy uses the stored MFA status of
the user. The proxy did not store this status. Now the proxy stores it after it
knows the user. A download is accepted if the user had a request with MFA within
the MFA session duration.
Downloading a folder or several files in the vault failed with a 404 error. In
vault mode, the web UI requested the signing key from a wrong address. Now the
web UI uses the correct address.
https://github.com/owncloud/ocis/pull/13097
@@ -0,0 +1,14 @@
Bugfix: Retry WOPI rename and upload while the file is processing
Renaming a file or uploading its contents through the collaboration service
failed with a 500 when the file was still being processed, for example right
after it had been created by a PutRelativeFile request. The storage answers
with a "too early" status in that case, which was only handled when deleting
files.
The collaboration service now retries the rename and upload requests with an
increasing waiting time until the file is ready. The delete request uses the
same retry logic, which is now limited to 10 retries instead of waiting
indefinitely.
https://github.com/owncloud/ocis/pull/13141
@@ -0,0 +1,13 @@
Change: Remove the MFA session extension popup in vault mode
In vault mode, the web UI showed a popup shortly before the multi-factor
authentication session was about to expire, offering to extend or dismiss it.
Extending only reset a timer in the browser and did not renew anything on the
server, so the popup has been removed.
The frontend service no longer exposes the MFA session duration in its
capabilities, and its `session_duration` setting has been removed. The
`OCIS_MFA_SESSION_DURATION` environment variable is still used by the proxy
service.
https://github.com/owncloud/ocis/pull/13085
@@ -0,0 +1,12 @@
Enhancement: Record tag changes in the audit log
Adding or removing tags on a file or folder left no trace in the audit log.
The graph service already publishes `TagsAdded` and `TagsRemoved` events for
every change, but only the search service listened to them.
The audit service now records both: `file_tags_add` and `file_tags_remove`
entries carry the acting user, the file id and path, the space owner and the
tags concerned. The graph service also sets the timestamp on the two events,
which it left empty before.
https://github.com/owncloud/ocis/issues/13054
@@ -0,0 +1,11 @@
Enhancement: Default 30-day expiration for vault shares
When a user or group share of a vault file or folder is created without an
expiration date, the server now preconfigures a default expiration (30 days
by default, configurable via `GRAPH_DEFAULT_VAULT_SHARE_EXPIRATION_DAYS`) to
encourage data minimization. The sharer can override or shorten this value.
Non-vault shares and space memberships are exempt and stay unbounded, as
space memberships represent a permanent organizational role.
https://github.com/owncloud/ocis/pull/12988
@@ -0,0 +1,13 @@
Enhancement: Add a --timeout flag to the search index command
`ocis search index` called the search service with a fixed 10 minute request
timeout. The service walks the whole space inside that request, so once the
timeout expired the walk was cancelled with "error walking the tree: context
canceled" and everything after that point stayed unindexed. A space whose
walk takes longer than ten minutes, for example because the content extractor
is slow on a few files, could never be fully indexed from the command line.
The timeout is now a flag. `--timeout` takes a duration (default `10m`, so the
behaviour is unchanged out of the box); `0` waits indefinitely.
https://github.com/owncloud/ocis/issues/13052
@@ -0,0 +1,14 @@
Bugfix: The global variable OCIS_CACHE_DATABASE was replaced
Some services accepted only the global variable OCIS_CACHE_DATABASE for their
cache database name. The default values for each service is unique that is
why this has not been noticed until now.
We added a local variable for each service. The GATEWAY service now accepts
GATEWAY_PROVIDER_CACHE_DATABASE. The PROXY service now accepts
PROXY_OIDC_USERINFO_CACHE_DATABASE. The SETTINGS service now accepts
SETTINGS_CACHE_DATABASE. The STORAGE-SYSTEM service now accepts
STORAGE_SYSTEM_CACHE_DATABASE. The do not use the global variable OCIS_CACHE_DATABASE
to avoid the cache collisions.
https://github.com/owncloud/ocis/pull/13158
+14 -13
View File
@@ -5,7 +5,7 @@ go 1.26.8
require (
dario.cat/mergo v1.0.2
github.com/CiscoM31/godata v1.0.11
github.com/KimMachineGun/automemlimit v0.7.5
github.com/KimMachineGun/automemlimit v1.0.0
github.com/Masterminds/semver v1.5.0
github.com/MicahParks/keyfunc/v2 v2.1.0
github.com/Nerzal/gocloak/v13 v13.9.0
@@ -23,9 +23,9 @@ require (
github.com/gabriel-vasile/mimetype v1.4.15
github.com/ggwhite/go-masker v1.1.0
github.com/go-chi/chi/v5 v5.3.2
github.com/go-chi/httprate v0.16.0
github.com/go-chi/httprate v0.16.1
github.com/go-chi/render v1.0.3
github.com/go-ldap/ldap/v3 v3.4.14
github.com/go-ldap/ldap/v3 v3.4.15
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3
github.com/go-micro/plugins/v4/client/grpc v1.2.1
github.com/go-micro/plugins/v4/logger/zerolog v1.2.0
@@ -58,7 +58,7 @@ 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.15.0
github.com/nats-io/nats-server/v2 v2.15.1
github.com/nats-io/nats.go v1.54.0
github.com/olekukonko/tablewriter v1.1.5
github.com/onsi/ginkgo v1.16.5
@@ -67,10 +67,10 @@ require (
github.com/open-policy-agent/opa v1.21.1
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-20261007080847-2cb387523ac7
github.com/owncloud/reva/v2 v2.0.0-20261012083840-8b649a4c3899
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.12
github.com/prometheus/client_golang v1.24.1
github.com/prometheus/client_golang v1.25.0
github.com/r3labs/sse/v2 v2.10.0
github.com/rogpeppe/go-internal v1.16.0
github.com/rs/cors v1.11.1
@@ -82,7 +82,7 @@ require (
github.com/stretchr/testify v1.12.1
github.com/test-go/testify v1.1.4
github.com/thejerf/suture/v4 v4.0.6
github.com/tidwall/gjson v1.19.1
github.com/tidwall/gjson v1.20.0
github.com/tus/tusd/v2 v2.10.1
github.com/unrolled/secure v1.17.0
github.com/urfave/cli/v2 v2.27.7
@@ -90,7 +90,7 @@ require (
go-micro.dev/v4 v4.11.0
go.etcd.io/bbolt v1.5.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.72.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0
go.opentelemetry.io/contrib/zpages v0.72.0
go.opentelemetry.io/otel v1.47.0
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
@@ -100,15 +100,16 @@ require (
golang.org/x/crypto v0.57.0
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba
golang.org/x/image v0.46.0
golang.org/x/net v0.59.0
golang.org/x/net v0.60.0
golang.org/x/oauth2 v0.37.0
golang.org/x/sync v0.23.0
golang.org/x/sync v0.24.0
golang.org/x/term v0.46.0
golang.org/x/text v0.42.0
google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc
google.golang.org/grpc v1.86.0-dev
google.golang.org/protobuf v1.36.12
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 v3.5.2
stash.kopano.io/kgol/rndm v1.1.2
)
@@ -238,7 +239,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.20.0 // indirect
github.com/klauspost/compress v1.20.1 // 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
@@ -292,8 +293,8 @@ require (
github.com/pquerna/cachecontrol v0.2.0 // indirect
github.com/prometheus/alertmanager v0.34.1 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.70.1 // indirect
github.com/prometheus/procfs v0.21.1 // indirect
github.com/prometheus/common v0.72.0 // indirect
github.com/prometheus/procfs v0.22.0 // indirect
github.com/prometheus/statsd_exporter v0.22.8 // indirect
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
github.com/rs/xid v1.6.0 // indirect
+26 -26
View File
@@ -51,8 +51,8 @@ github.com/CiscoM31/godata v1.0.11 h1:w7y8twuW02LdH6mak3/GJ5i0GrCv2IoZUJVqa/g5Ye
github.com/CiscoM31/godata v1.0.11/go.mod h1:ZMiT6JuD3Rm83HEtiTx4JEChsd25YCrxchKGag/sdTc=
github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c h1:ocsNvQ2tNHme4v/lTs17HROamc7mFzZfzWcg4m+UXN0=
github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40=
github.com/KimMachineGun/automemlimit v0.7.5 h1:RkbaC0MwhjL1ZuBKunGDjE/ggwAX43DwZrJqVwyveTk=
github.com/KimMachineGun/automemlimit v0.7.5/go.mod h1:QZxpHaGOQoYvFhv/r4u3U0JTC2ZcOwbSr11UZF46UBM=
github.com/KimMachineGun/automemlimit v1.0.0 h1:+MqlvDE/pkJNjk1rU+O14QsH8k10nJAD0frB0lsxyvw=
github.com/KimMachineGun/automemlimit v1.0.0/go.mod h1:n+BSXxQWDFS1DKh67Rqo0lgTsowsg6x65ak5uyngML0=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
@@ -288,8 +288,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.8 h1:H9AZkK22UOmfX8J84ubyaZxKJZ3FMHVwn8swoM
github.com/go-asn1-ber/asn1-ber v1.5.8/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-chi/chi/v5 v5.3.2 h1:5YQkICvTCSZ25hoRsyJazN0scjzKGiu4VAUc7H1o1nY=
github.com/go-chi/chi/v5 v5.3.2/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
github.com/go-chi/httprate v0.16.0 h1:8V5DH9j6pSK6UQoBsTpvMyFxycqaKEIToyPKzHJjUa8=
github.com/go-chi/httprate v0.16.0/go.mod h1:A8lo+qRhk+s9LiuP5saS7XCGDXRXMcrueq0NfIuCa/I=
github.com/go-chi/httprate v0.16.1 h1:q2M8FmDsI4oEr1oRX43N+VeA0Ujd1tb/EasrSzXy87o=
github.com/go-chi/httprate v0.16.1/go.mod h1:A8lo+qRhk+s9LiuP5saS7XCGDXRXMcrueq0NfIuCa/I=
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
@@ -315,8 +315,8 @@ github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
github.com/go-ldap/ldap/v3 v3.4.14 h1:D6PYdEgsaVzsXyr6w/yDC06Ria4uUhWm+Rb+er8lfAs=
github.com/go-ldap/ldap/v3 v3.4.14/go.mod h1:S4eJUMUNjDkE0ZJtIZdybwyb03sGGLW6gxXT1Hs8VKA=
github.com/go-ldap/ldap/v3 v3.4.15 h1:eRB4f4Ecn1POL1mO86+uUDlecmyWsdiJwh60bAUS4UY=
github.com/go-ldap/ldap/v3 v3.4.15/go.mod h1:jeD0c98EdZQCKKKKe4kTWs5aCf6y+j8KuYsYLznZSQk=
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3 h1:sfz1YppV05y4sYaW7kXZtrocU/+vimnIWt4cxAYh7+o=
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3/go.mod h1:ZXFhGda43Z2TVbfGZefXyMJzsDHhCh0go3bZUcwTx7o=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
@@ -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.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
github.com/klauspost/compress v1.20.1/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=
@@ -696,8 +696,8 @@ 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.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-server/v2 v2.15.1 h1:fK3AeYFIji1Smng60jB0hVoAPZezA/UzsaI3BqXFNEI=
github.com/nats-io/nats-server/v2 v2.15.1/go.mod h1:yeuYRtKVKIFtmMz2/YPk+6hvmNBnk+WwTUzErBdH6IE=
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=
@@ -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-20261007080847-2cb387523ac7 h1:wIL6E2Lu4hVcU44qa1rjo+dp90++/aQeUe4tAjifRAg=
github.com/owncloud/reva/v2 v2.0.0-20261007080847-2cb387523ac7/go.mod h1:cgqg+UTe4ekjMbJj8hgoXSTxQ9fQramKcOUdvsFUrzc=
github.com/owncloud/reva/v2 v2.0.0-20261012083840-8b649a4c3899 h1:IMu076AtnFEdabpBbowcGDYOeFLtm9ycNY1Z43YPYZU=
github.com/owncloud/reva/v2 v2.0.0-20261012083840-8b649a4c3899/go.mod h1:cgqg+UTe4ekjMbJj8hgoXSTxQ9fQramKcOUdvsFUrzc=
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=
@@ -777,8 +777,8 @@ github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqr
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -793,8 +793,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
github.com/prometheus/common v0.72.0 h1:tAYsE+sPJxIncDAobm4H5aQjmox9ZxEIIqPbiffa8G4=
github.com/prometheus/common v0.72.0/go.mod h1:77NWqAQ2tXT7BIK40qjJdw5Acrsrg1TlHAnsQi3i6mk=
github.com/prometheus/procfs v0.0.0-20170703101242-e645f4e5aaa8/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
@@ -802,8 +802,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics=
github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58=
github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI=
github.com/prometheus/statsd_exporter v0.22.8 h1:Qo2D9ZzaQG+id9i5NYNGmbf1aa/KxKbB9aKfMS+Yib0=
github.com/prometheus/statsd_exporter v0.22.8/go.mod h1:/DzwbTEaFTE0Ojz5PqcSk6+PFHOPWGxdXVr6yC8eFOM=
@@ -891,8 +891,8 @@ github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o
github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
github.com/thejerf/suture/v4 v4.0.6 h1:QsuCEsCqb03xF9tPAsWAj8QOAJBgQI1c0VqJNaingg8=
github.com/thejerf/suture/v4 v4.0.6/go.mod h1:gu9Y4dXNUWFrByqRt30Rm9/UZ0wzRSt9AJS6xu/ZGxU=
github.com/tidwall/gjson v1.19.1 h1:uKxUTe/+mtjSY3Sf1EIND83MyH+jWf1SixZ7DHpjbJU=
github.com/tidwall/gjson v1.19.1/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
github.com/tidwall/gjson v1.20.0 h1:+agJ3rEzKcCXKDKo0ml26UROcpcAlnZyjq+TjbY5Fto=
github.com/tidwall/gjson v1.20.0/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
@@ -968,8 +968,8 @@ go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.72.0 h1:Tq+E65HaNbZTeqcLw6QUhsV+/EIWdkfUH2CQzcrlE5M=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.72.0/go.mod h1:A+EVhDakAj1waJBPhmTszZaSr08ww8MRRKy1nB1rqck=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 h1:3g7B90UzBltIDKq1/5mrTGxTnOFDV0ICOhLoxiZ8jlg=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0/go.mod h1:Ef8SuTh59BT7+ofpDxN9z+yOlc4t2GjLmKDgYNJL/NU=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
go.opentelemetry.io/contrib/zpages v0.72.0 h1:aXBUaFvbF7xy77q6vXBvaw7dcZK0zUqJSF5UhtbbuZ4=
go.opentelemetry.io/contrib/zpages v0.72.0/go.mod h1:e/qIKK0RHtY2dvkJhp1jtjVvglq/IDzMI7gDN8mMMtY=
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
@@ -1102,8 +1102,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1127,8 +1127,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.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
golang.org/x/sync v0.24.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=
+6 -11
View File
@@ -7,14 +7,13 @@ import (
"github.com/go-ldap/ldap/v3"
)
// EnhanceFilterWithMasterID OR's the given LDAP filter with master-id match clauses.
// Returns filter unchanged when masterID is empty or both attributes are empty.
// EnhanceFilterWithMasterID adds master-ID match clauses to the given LDAP filter with OR.
// An empty filter means "no restriction". Do not OR an empty filter with a master-ID clause.
// This action would restrict an unrestricted search to the master ID only.
// The function returns the filter without a change when masterID is empty, when both
// attributes are empty, or when filter is empty.
func EnhanceFilterWithMasterID(filter, masterID, memberAttr, guestAttr string) string {
if masterID == "" {
return filter
}
if memberAttr == "" && guestAttr == "" {
if masterID == "" || (memberAttr == "" && guestAttr == "") || filter == "" {
return filter
}
@@ -35,9 +34,5 @@ func EnhanceFilterWithMasterID(filter, masterID, memberAttr, guestAttr string) s
masterIDFilter = fmt.Sprintf("(|%s)", strings.Join(masterIDParts, ""))
}
if filter == "" {
return masterIDFilter
}
return fmt.Sprintf("(|%s%s)", filter, masterIDFilter)
}
+2 -2
View File
@@ -54,12 +54,12 @@ func TestEnhanceFilterWithMasterID(t *testing.T) {
expectedFilter: "(|(ownCloudGuestOf=instance-1)(ownCloudGuestOf=0000-0000-000-0000))",
},
{
name: "empty existing filter",
name: "empty existing filter stays unrestricted",
filter: "",
masterID: "0000-0000-000-0000",
memberAttr: "ownCloudMemberOf",
guestAttr: "ownCloudGuestOf",
expectedFilter: "(|(ownCloudMemberOf=0000-0000-000-0000)(ownCloudGuestOf=0000-0000-000-0000))",
expectedFilter: "",
},
{
name: "LDAP injection protection",
+7
View File
@@ -46,6 +46,13 @@ func MissingLDAPBindPassword(service string) error {
service, defaults.BaseConfigPath())
}
func MissingLDAPUserFilterForMasterID(service string) error {
return fmt.Errorf("The ldap user_filter has not been set for %s, but OCIS_MULTI_INSTANCE_MASTER_ID is set. "+
"Set an explicit user_filter to scope this instance to its own users. "+
"Without a user_filter, every user in the shared LDAP directory can access this instance.",
service)
}
func MissingServiceUserPassword(service, serviceUser string) error {
return fmt.Errorf("The password of service user %s has not been set properly in your config for %s. "+
"Make sure your %s config contains the proper values "+
+5 -5
View File
@@ -54,8 +54,8 @@ type GRPCClientOptions struct {
// which read them independently of each other but apply the same rules, so both behave
// identically for every input. Keepalive is off unless the time is set to a duration that
// parses; a value without a unit suffix leaves the clients without pings.
GRPCClientKeepaliveTime time.Duration `yaml:"grpc_client_keepalive_time" env:"GRPC_CLIENT_KEEPALIVE_TIME" desc:"How long a grpc client connection with an ongoing request may stay silent before the server is pinged to check whether it is still answering. Set a duration like '20s' to enable detection of unresponsive peers. Leaving it unset, or at '0', sends no pings at all, which is grpc's own default. Values below '10s' are raised to '10s' by grpc. Make sure to include the unit suffix, a bare number is not a valid duration." introductionVersion:"8.3.0"`
GRPCClientKeepaliveTimeout time.Duration `yaml:"grpc_client_keepalive_timeout" env:"GRPC_CLIENT_KEEPALIVE_TIMEOUT" desc:"How long a grpc client waits for the answer to a keepalive ping before it considers the connection dead and fails all requests on it. Defaults to '10s'. Has no effect unless GRPC_CLIENT_KEEPALIVE_TIME is set. See GRPC_CLIENT_KEEPALIVE_TIME." introductionVersion:"8.3.0"`
GRPCClientKeepaliveTime time.Duration `yaml:"grpc_client_keepalive_time" env:"GRPC_CLIENT_KEEPALIVE_TIME" desc:"How long a grpc client connection with an ongoing request may stay silent before the server is pinged to check whether it is still answering. Set a duration like '20s' to enable detection of unresponsive peers. Leaving it unset, or at '0', sends no pings at all, which is grpc's own default. Values below '10s' are raised to '10s' by grpc. Make sure to include the unit suffix, a bare number is not a valid duration." introductionVersion:"9.0.0"`
GRPCClientKeepaliveTimeout time.Duration `yaml:"grpc_client_keepalive_timeout" env:"GRPC_CLIENT_KEEPALIVE_TIMEOUT" desc:"How long a grpc client waits for the answer to a keepalive ping before it considers the connection dead and fails all requests on it. Defaults to '10s'. Has no effect unless GRPC_CLIENT_KEEPALIVE_TIME is set. See GRPC_CLIENT_KEEPALIVE_TIME." introductionVersion:"9.0.0"`
}
type GRPCServiceTLS struct {
@@ -80,9 +80,9 @@ type Cache struct {
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
AuthUsername string `yaml:"auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"pre5.0"`
AuthPassword string `yaml:"auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"pre5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the NATS store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the NATS store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate used to validate the NATS store TLS certificate. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the NATS store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the NATS store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate used to validate the NATS store TLS certificate. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
// Commons holds configuration that are common to all extensions. Each extension can then decide whether
+3 -3
View File
@@ -55,9 +55,9 @@ type Store struct {
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;ACTIVITYLOG_STORE_TTL" desc:"Time to live for events in the store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;ACTIVITYLOG_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;ACTIVITYLOG_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;ACTIVITYLOG_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;ACTIVITYLOG_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;ACTIVITYLOG_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;ACTIVITYLOG_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;ACTIVITYLOG_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;ACTIVITYLOG_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
// ServiceAccount is the configuration for the used service account
+2
View File
@@ -2,6 +2,8 @@
The audit service logs all events of the system as an audit log. Per default, it will be logged to standard out, but can also be configured to a file output. Supported log formats are json or a minimal human-readable format.
Besides shares, links, files, spaces, users and groups, tag changes are recorded: adding tags to a file or folder is logged as `file_tags_add` and removing them as `file_tags_remove`, each with the acting user, the file id and the tags as requested. The request is recorded as made: a tag that was already present (or, for a removal, absent) is still listed, so repeated requests remain visible.
With audit logs, you are able to prove compliance with corporate guidelines as well as to enable reporting and auditing of operations. The audit service takes note of actions conducted by users and administrators.
Example minimal format:
+4
View File
@@ -83,6 +83,10 @@ func StartAuditLogger(ctx context.Context, ch <-chan events.Event, log log.Logge
auditEvent = types.ItemRestored(ev)
case events.FileVersionRestored:
auditEvent = types.FileVersionRestored(ev)
case events.TagsAdded:
auditEvent = types.TagsAdded(ev)
case events.TagsRemoved:
auditEvent = types.TagsRemoved(ev)
case events.SpaceCreated:
auditEvent = types.SpaceCreated(ev)
case events.SpaceRenamed:
+108 -22
View File
@@ -325,7 +325,7 @@ var testCases = []struct {
Event: events.FileUploaded{
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
@@ -335,7 +335,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' created file 'pro-1$sto-123!iid-123/item'", "file_create")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
},
}, {
Alias: "File read",
@@ -343,7 +343,7 @@ var testCases = []struct {
Event: events.FileDownloaded{
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
@@ -353,7 +353,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' read file 'pro-1$sto-123!iid-123/item'", "file_read")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
},
}, {
Alias: "File trashed",
@@ -361,7 +361,7 @@ var testCases = []struct {
Event: events.ItemTrashed{
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
@@ -371,7 +371,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' trashed file 'pro-1$sto-123!iid-123/item'", "file_delete")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
},
}, {
Alias: "File renamed",
@@ -380,7 +380,7 @@ var testCases = []struct {
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
OldReference: reference("pro-1", "sto-123", "iid-123", "./anotheritem"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
@@ -390,7 +390,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' moved file 'pro-1$sto-123!iid-123/item' from './anotheritem' to './item'", "file_rename")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
// AuditEventFileRenamed fields
require.Equal(t, "./anotheritem", ev.OldPath)
@@ -401,7 +401,7 @@ var testCases = []struct {
Event: events.ItemPurged{
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
@@ -411,7 +411,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' removed file 'pro-1$sto-123!iid-123/item' from trashbin", "file_trash_delete")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
},
}, {
Alias: "File restored",
@@ -419,7 +419,7 @@ var testCases = []struct {
Event: events.ItemRestored{
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
OldReference: reference("pro-1", "sto-123", "sto-123!iid-123/item", "./oldpath"),
Key: "",
},
@@ -431,7 +431,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'pro-1$sto-123!iid-123/item' from trashbin to './item'", "file_trash_restore")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
// AuditEventFileRestored fields
require.Equal(t, "./oldpath", ev.OldPath)
@@ -442,7 +442,7 @@ var testCases = []struct {
Event: events.FileVersionRestored{
Executant: userID("uid-123"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
Owner: userID("uid-owner"),
Key: "v1",
},
},
@@ -453,7 +453,7 @@ var testCases = []struct {
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'pro-1$sto-123!iid-123/item' in version 'v1'", "file_version_restore")
// AuditEventSharing fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
// AuditEventFileRestored fields
require.Equal(t, "v1", ev.Key)
@@ -464,7 +464,7 @@ var testCases = []struct {
Event: events.SpaceCreated{
Executant: userID("uid-123"),
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
Owner: userID("uid-123"),
Owner: userID("uid-owner"),
Root: resourceID("pro-1", "sto-123", "iid-123"),
Name: "test-space",
Type: "project",
@@ -477,11 +477,11 @@ var testCases = []struct {
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "", "2286-11-20T17:46:40Z", "user 'uid-123' created a space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_created")
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "2286-11-20T17:46:40Z", "user 'uid-123' created a space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_created")
// AuditEventSpaces fields
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
// AuditEventFileRestored fields
require.Equal(t, "uid-123", ev.Owner)
require.Equal(t, "uid-owner", ev.Owner)
require.Equal(t, "pro-1$sto-123!iid-123", ev.RootItem)
require.Equal(t, "test-space", ev.Name)
require.Equal(t, "project", ev.Type)
@@ -492,7 +492,7 @@ var testCases = []struct {
Event: events.SpaceRenamed{
Executant: userID("uid-123"),
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
Owner: userID("uid-123"),
Owner: userID("uid-owner"),
Name: "new-name",
},
},
@@ -501,7 +501,7 @@ var testCases = []struct {
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' renamed space 'space-123' to 'new-name' (storage: 'storage-1')", "space_renamed")
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' renamed space 'space-123' to 'new-name' (storage: 'storage-1')", "space_renamed")
// AuditEventSpaces fields
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
// AuditEventSpaceRenamed fields
@@ -520,7 +520,7 @@ var testCases = []struct {
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' disabled the space 'space-123' (storage: 'storage-1')", "space_disabled")
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "0001-01-01T00:00:00Z", "user 'uid-123' disabled the space 'space-123' (storage: 'storage-1')", "space_disabled")
// AuditEventSpaces fields
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
},
@@ -537,7 +537,7 @@ var testCases = []struct {
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' (re-) enabled the space 'space-123' (storage: 'storage-1')", "space_enabled")
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' (re-) enabled the space 'space-123' (storage: 'storage-1')", "space_enabled")
// AuditEventSpaces fields
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
},
@@ -555,7 +555,7 @@ var testCases = []struct {
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' deleted the space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_deleted")
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "0001-01-01T00:00:00Z", "user 'uid-123' deleted the space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_deleted")
// AuditEventSpaces fields
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
},
@@ -587,6 +587,92 @@ var testCases = []struct {
require.Equal(t, "http://ocis.test/invite", ev.InviteLink)
},
},
{
Alias: "User created",
SystemEvent: events.Event{
Event: events.UserCreated{
Executant: userID("uid-admin"),
UserID: "uid-new",
Timestamp: timestamp(10e8),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
ev := types.AuditEventUserCreated{}
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields: User is the actor, not the affected user
checkBaseAuditEvent(t, ev.AuditEvent, "uid-admin", "2001-09-09T01:46:40Z", "user 'uid-admin' created the user 'uid-new'", "user_created")
// AuditEventUserCreated fields
require.Equal(t, "uid-new", ev.UserID)
},
},
{
Alias: "Group member added",
SystemEvent: events.Event{
Event: events.GroupMemberAdded{
Executant: userID("uid-admin"),
GroupID: "gid-123",
UserID: "uid-member",
Timestamp: timestamp(10e8),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
ev := types.AuditEventGroupMemberAdded{}
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields: User is the actor, not the member
checkBaseAuditEvent(t, ev.AuditEvent, "uid-admin", "2001-09-09T01:46:40Z", "user 'uid-admin' added user 'uid-member' was added to group 'gid-123'", "group_member_added")
// AuditEventGroupMemberAdded fields
require.Equal(t, "gid-123", ev.GroupID)
require.Equal(t, "uid-member", ev.UserID)
},
},
{
Alias: "Tags added",
SystemEvent: events.Event{
Event: events.TagsAdded{
Executant: userID("uid-123"),
SpaceOwner: userID("uid-owner"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Tags: "holiday,family",
Timestamp: timestamp(10e8),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
ev := types.AuditEventTagsAdded{}
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields: User is the actor, Owner the space owner
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "2001-09-09T01:46:40Z", "user 'uid-123' added tags 'holiday,family' to file 'pro-1$sto-123!iid-123/item'", "file_tags_add")
// AuditEventFiles fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
// AuditEventTagsAdded fields
require.Equal(t, "holiday,family", ev.Tags)
},
},
{
Alias: "Tags removed",
SystemEvent: events.Event{
Event: events.TagsRemoved{
Executant: userID("uid-123"),
SpaceOwner: userID("uid-owner"),
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
Tags: "holiday",
Timestamp: timestamp(10e8),
},
},
CheckAuditEvent: func(t *testing.T, b []byte) {
ev := types.AuditEventTagsRemoved{}
require.NoError(t, json.Unmarshal(b, &ev))
// AuditEvent fields: User is the actor, Owner the space owner
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "2001-09-09T01:46:40Z", "user 'uid-123' removed tags 'holiday' from file 'pro-1$sto-123!iid-123/item'", "file_tags_remove")
// AuditEventFiles fields
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
// AuditEventTagsRemoved fields
require.Equal(t, "holiday", ev.Tags)
},
},
}
func TestAuditLogging(t *testing.T) {
+49 -25
View File
@@ -247,7 +247,7 @@ func FilesAuditEvent(base AuditEvent, itemid, owner, path string) AuditEventFile
// ContainerCreated converts a ContainerCreated event to an AuditEventContainerCreated
func ContainerCreated(ev events.ContainerCreated) AuditEventContainerCreated {
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageContainerCreated(ev.Executant.GetOpaqueId(), iid), ActionContainerCreated)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageContainerCreated(ev.Executant.GetOpaqueId(), iid), ActionContainerCreated)
return AuditEventContainerCreated{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
}
@@ -256,7 +256,7 @@ func ContainerCreated(ev events.ContainerCreated) AuditEventContainerCreated {
// FileUploaded converts a FileUploaded event to an AuditEventFileCreated
func FileUploaded(ev events.FileUploaded) AuditEventFileCreated {
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileCreated(ev.Executant.GetOpaqueId(), iid), ActionFileCreated)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileCreated(ev.Executant.GetOpaqueId(), iid), ActionFileCreated)
return AuditEventFileCreated{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
}
@@ -265,7 +265,7 @@ func FileUploaded(ev events.FileUploaded) AuditEventFileCreated {
// FileDownloaded converts a FileDownloaded event to an AuditEventFileRead
func FileDownloaded(ev events.FileDownloaded) AuditEventFileRead {
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileRead(ev.Executant.GetOpaqueId(), iid), ActionFileRead)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileRead(ev.Executant.GetOpaqueId(), iid), ActionFileRead)
return AuditEventFileRead{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
}
@@ -280,7 +280,7 @@ func ItemMoved(ev events.ItemMoved) AuditEventFileRenamed {
oldpath = ev.OldReference.GetPath()
}
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileRenamed(ev.Executant.GetOpaqueId(), iid, oldpath, path), ActionFileRenamed)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileRenamed(ev.Executant.GetOpaqueId(), iid, oldpath, path), ActionFileRenamed)
return AuditEventFileRenamed{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
OldPath: oldpath,
@@ -290,7 +290,7 @@ func ItemMoved(ev events.ItemMoved) AuditEventFileRenamed {
// ItemTrashed converts a ItemTrashed event to an AuditEventFileDeleted
func ItemTrashed(ev events.ItemTrashed) AuditEventFileDeleted {
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileTrashed(ev.Executant.GetOpaqueId(), iid), ActionFileTrashed)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileTrashed(ev.Executant.GetOpaqueId(), iid), ActionFileTrashed)
return AuditEventFileDeleted{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
}
@@ -299,7 +299,7 @@ func ItemTrashed(ev events.ItemTrashed) AuditEventFileDeleted {
// ItemPurged converts a ItemPurged event to an AuditEventFilePurged
func ItemPurged(ev events.ItemPurged) AuditEventFilePurged {
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFilePurged(ev.Executant.GetOpaqueId(), iid), ActionFilePurged)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFilePurged(ev.Executant.GetOpaqueId(), iid), ActionFilePurged)
return AuditEventFilePurged{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
}
@@ -314,7 +314,7 @@ func ItemRestored(ev events.ItemRestored) AuditEventFileRestored {
oldpath = ev.OldReference.GetPath()
}
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileRestored(ev.Executant.GetOpaqueId(), iid, path), ActionFileRestored)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileRestored(ev.Executant.GetOpaqueId(), iid, path), ActionFileRestored)
return AuditEventFileRestored{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
OldPath: oldpath,
@@ -324,13 +324,37 @@ func ItemRestored(ev events.ItemRestored) AuditEventFileRestored {
// FileVersionRestored converts a FileVersionRestored event to an AuditEventFileVersionRestored
func FileVersionRestored(ev events.FileVersionRestored) AuditEventFileVersionRestored {
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileVersionRestored(ev.Executant.GetOpaqueId(), iid, ev.Key), ActionFileVersionRestored)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileVersionRestored(ev.Executant.GetOpaqueId(), iid, ev.Key), ActionFileVersionRestored)
return AuditEventFileVersionRestored{
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
Key: ev.Key,
}
}
// TagsAdded converts a TagsAdded event to an AuditEventTagsAdded.
// Unlike the other file events, User is the executant (who changed the tags), not the
// space owner: tags are usually changed by someone other than the owner, and the
// owner is still recorded in the Owner field.
func TagsAdded(ev events.TagsAdded) AuditEventTagsAdded {
iid, path, owner := extractFileDetails(ev.Ref, ev.SpaceOwner)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageTagsAdded(ev.Executant.GetOpaqueId(), ev.Tags, iid), ActionTagsAdded)
return AuditEventTagsAdded{
AuditEventFiles: FilesAuditEvent(base, iid, owner, path),
Tags: ev.Tags,
}
}
// TagsRemoved converts a TagsRemoved event to an AuditEventTagsRemoved.
// User is the executant, as in TagsAdded.
func TagsRemoved(ev events.TagsRemoved) AuditEventTagsRemoved {
iid, path, owner := extractFileDetails(ev.Ref, ev.SpaceOwner)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageTagsRemoved(ev.Executant.GetOpaqueId(), ev.Tags, iid), ActionTagsRemoved)
return AuditEventTagsRemoved{
AuditEventFiles: FilesAuditEvent(base, iid, owner, path),
Tags: ev.Tags,
}
}
// SpacesAuditEvent creates an AuditEventSpaces from the given values
func SpacesAuditEvent(base AuditEvent, spaceID string) AuditEventSpaces {
return AuditEventSpaces{
@@ -343,7 +367,7 @@ func SpacesAuditEvent(base AuditEvent, spaceID string) AuditEventSpaces {
func SpaceCreated(ev events.SpaceCreated) AuditEventSpaceCreated {
sid := ev.ID.GetOpaqueId()
iid, _, owner := extractFileDetails(&provider.Reference{ResourceId: ev.Root}, ev.Owner)
base := BasicAuditEvent("", formatTime(ev.MTime), MessageSpaceCreated(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceCreated)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.MTime), MessageSpaceCreated(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceCreated)
return AuditEventSpaceCreated{
AuditEventSpaces: SpacesAuditEvent(base, sid),
Owner: owner,
@@ -356,7 +380,7 @@ func SpaceCreated(ev events.SpaceCreated) AuditEventSpaceCreated {
// SpaceRenamed converts a SpaceRenamed event to an AuditEventSpaceRenamed
func SpaceRenamed(ev events.SpaceRenamed) AuditEventSpaceRenamed {
sid := ev.ID.GetOpaqueId()
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageSpaceRenamed(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceRenamed)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageSpaceRenamed(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceRenamed)
return AuditEventSpaceRenamed{
AuditEventSpaces: SpacesAuditEvent(base, sid),
NewName: ev.Name,
@@ -366,7 +390,7 @@ func SpaceRenamed(ev events.SpaceRenamed) AuditEventSpaceRenamed {
// SpaceDisabled converts a SpaceDisabled event to an AuditEventSpaceDisabled
func SpaceDisabled(ev events.SpaceDisabled) AuditEventSpaceDisabled {
sid := ev.ID.GetOpaqueId()
base := BasicAuditEvent("", formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDisabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceDisabled)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDisabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceDisabled)
return AuditEventSpaceDisabled{
AuditEventSpaces: SpacesAuditEvent(base, sid),
}
@@ -375,7 +399,7 @@ func SpaceDisabled(ev events.SpaceDisabled) AuditEventSpaceDisabled {
// SpaceEnabled converts a SpaceEnabled event to an AuditEventSpaceEnabled
func SpaceEnabled(ev events.SpaceEnabled) AuditEventSpaceEnabled {
sid := ev.ID.GetOpaqueId()
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageSpaceEnabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceEnabled)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageSpaceEnabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceEnabled)
return AuditEventSpaceEnabled{
AuditEventSpaces: SpacesAuditEvent(base, sid),
}
@@ -384,7 +408,7 @@ func SpaceEnabled(ev events.SpaceEnabled) AuditEventSpaceEnabled {
// SpaceDeleted converts a SpaceDeleted event to an AuditEventSpaceDeleted
func SpaceDeleted(ev events.SpaceDeleted) AuditEventSpaceDeleted {
sid := ev.ID.GetOpaqueId()
base := BasicAuditEvent("", formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDeleted(ev.Executant.GetOpaqueId(), sid, ev.SpaceName), ActionSpaceDeleted)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDeleted(ev.Executant.GetOpaqueId(), sid, ev.SpaceName), ActionSpaceDeleted)
return AuditEventSpaceDeleted{
AuditEventSpaces: SpacesAuditEvent(base, sid),
}
@@ -403,7 +427,7 @@ func SpaceShared(ev events.SpaceShared) AuditEventSpaceShared {
sse.GranteeGroupID = ev.GranteeGroupID.OpaqueId
grantee = "group:" + ev.GranteeGroupID.OpaqueId
}
base := BasicAuditEvent("", "", MessageSpaceShared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceShared)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), "", MessageSpaceShared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceShared)
sse.AuditEventSpaces = SpacesAuditEvent(base, sid)
return sse
@@ -422,7 +446,7 @@ func SpaceUnshared(ev events.SpaceUnshared) AuditEventSpaceUnshared {
sue.GranteeGroupID = ev.GranteeGroupID.OpaqueId
grantee = "group:" + ev.GranteeGroupID.OpaqueId
}
base := BasicAuditEvent("", formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceUnshared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceUnshared)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceUnshared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceUnshared)
sue.AuditEventSpaces = SpacesAuditEvent(base, sid)
return sue
@@ -437,7 +461,7 @@ func SpaceUpdated(ev events.SpaceUpdated) AuditEventSpaceUpdated {
Opaque: opaqueMap,
}
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageSpaceUpdated(ev.Executant.GetOpaqueId(), sid, ev.Space.Name, ev.Space.Quota.QuotaMaxBytes, opaqueMap), ActionSpaceUpdated)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageSpaceUpdated(ev.Executant.GetOpaqueId(), sid, ev.Space.Name, ev.Space.Quota.QuotaMaxBytes, opaqueMap), ActionSpaceUpdated)
sue.AuditEventSpaces = SpacesAuditEvent(base, sid)
return sue
@@ -445,7 +469,7 @@ func SpaceUpdated(ev events.SpaceUpdated) AuditEventSpaceUpdated {
// UserCreated converts a UserCreated event to an AuditEventUserCreated
func UserCreated(ev events.UserCreated) AuditEventUserCreated {
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageUserCreated(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserCreated)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageUserCreated(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserCreated)
return AuditEventUserCreated{
AuditEvent: base,
UserID: ev.UserID,
@@ -454,7 +478,7 @@ func UserCreated(ev events.UserCreated) AuditEventUserCreated {
// UserDeleted converts a UserDeleted event to an AuditEventUserDeleted
func UserDeleted(ev events.UserDeleted) AuditEventUserDeleted {
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageUserDeleted(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserDeleted)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageUserDeleted(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserDeleted)
return AuditEventUserDeleted{
AuditEvent: base,
UserID: ev.UserID,
@@ -464,7 +488,7 @@ func UserDeleted(ev events.UserDeleted) AuditEventUserDeleted {
// UserFeatureChanged converts a UserFeatureChanged event to an AuditEventUserFeatureChanged
func UserFeatureChanged(ev events.UserFeatureChanged) AuditEventUserFeatureChanged {
msg := MessageUserFeatureChanged(ev.Executant.GetOpaqueId(), ev.UserID, ev.Features)
base := BasicAuditEvent("", formatTime(ev.Timestamp), msg, ActionUserFeatureChanged)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), msg, ActionUserFeatureChanged)
return AuditEventUserFeatureChanged{
AuditEvent: base,
UserID: ev.UserID,
@@ -474,7 +498,7 @@ func UserFeatureChanged(ev events.UserFeatureChanged) AuditEventUserFeatureChang
// GroupCreated converts a GroupCreated event to an AuditEventGroupCreated
func GroupCreated(ev events.GroupCreated) AuditEventGroupCreated {
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageGroupCreated(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupCreated)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageGroupCreated(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupCreated)
return AuditEventGroupCreated{
AuditEvent: base,
GroupID: ev.GroupID,
@@ -483,7 +507,7 @@ func GroupCreated(ev events.GroupCreated) AuditEventGroupCreated {
// GroupDeleted converts a GroupDeleted event to an AuditEventGroupDeleted
func GroupDeleted(ev events.GroupDeleted) AuditEventGroupDeleted {
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageGroupDeleted(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupDeleted)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageGroupDeleted(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupDeleted)
return AuditEventGroupDeleted{
AuditEvent: base,
GroupID: ev.GroupID,
@@ -492,8 +516,8 @@ func GroupDeleted(ev events.GroupDeleted) AuditEventGroupDeleted {
// GroupMemberAdded converts a GroupMemberAdded event to an AuditEventGroupMemberAdded
func GroupMemberAdded(ev events.GroupMemberAdded) AuditEventGroupMemberAdded {
msg := MessageGroupMemberAdded(ev.Executant.GetOpaqueId(), ev.GroupID, ev.UserID)
base := BasicAuditEvent("", formatTime(ev.Timestamp), msg, ActionGroupMemberAdded)
msg := MessageGroupMemberAdded(ev.Executant.GetOpaqueId(), ev.UserID, ev.GroupID)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), msg, ActionGroupMemberAdded)
return AuditEventGroupMemberAdded{
AuditEvent: base,
GroupID: ev.GroupID,
@@ -503,8 +527,8 @@ func GroupMemberAdded(ev events.GroupMemberAdded) AuditEventGroupMemberAdded {
// GroupMemberRemoved converts a GroupMemberRemoved event to an AuditEventGroupMemberRemove
func GroupMemberRemoved(ev events.GroupMemberRemoved) AuditEventGroupMemberRemoved {
msg := MessageGroupMemberRemoved(ev.Executant.GetOpaqueId(), ev.GroupID, ev.UserID)
base := BasicAuditEvent("", formatTime(ev.Timestamp), msg, ActionGroupMemberRemoved)
msg := MessageGroupMemberRemoved(ev.Executant.GetOpaqueId(), ev.UserID, ev.GroupID)
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), msg, ActionGroupMemberRemoved)
return AuditEventGroupMemberRemoved{
AuditEvent: base,
GroupID: ev.GroupID,
+2
View File
@@ -24,6 +24,8 @@ func RegisteredEvents() []events.Unmarshaller {
events.ItemPurged{},
events.ItemRestored{},
events.FileVersionRestored{},
events.TagsAdded{},
events.TagsRemoved{},
events.SpaceCreated{},
events.SpaceRenamed{},
events.SpaceEnabled{},
+13 -1
View File
@@ -32,6 +32,8 @@ const (
ActionFilePurged = "file_trash_delete"
ActionFileRestored = "file_trash_restore"
ActionFileVersionRestored = "file_version_restore"
ActionTagsAdded = "file_tags_add"
ActionTagsRemoved = "file_tags_remove"
// Spaces
ActionSpaceCreated = "space_created"
@@ -124,7 +126,17 @@ func MessageFileRead(executant, item string) string {
return fmt.Sprintf("user '%s' read file '%s'", executant, item)
}
// MessageFileTrashed returns the human-readable string that describes the action
// MessageTagsAdded returns a human readable string that describes the action
func MessageTagsAdded(executant, tags, item string) string {
return fmt.Sprintf("user '%s' added tags '%s' to file '%s'", executant, tags, item)
}
// MessageTagsRemoved returns a human readable string that describes the action
func MessageTagsRemoved(executant, tags, item string) string {
return fmt.Sprintf("user '%s' removed tags '%s' from file '%s'", executant, tags, item)
}
// MessageFileTrashed returns a human readable string that describes the action
func MessageFileTrashed(executant, item string) string {
return fmt.Sprintf("user '%s' trashed file '%s'", executant, item)
}
+14
View File
@@ -149,6 +149,20 @@ type AuditEventFileRestored struct {
OldPath string
}
// AuditEventTagsAdded is the event logged when tags are added to a file or folder
type AuditEventTagsAdded struct {
AuditEventFiles
Tags string // the tags the request asked to add, as carried by the event (ev.Tags); some may already have been present
}
// AuditEventTagsRemoved is the event logged when tags are removed from a file or folder
type AuditEventTagsRemoved struct {
AuditEventFiles
Tags string // the tags the request asked to remove, as carried by the event (ev.Tags); some may not have been present
}
// AuditEventFileVersionRestored is the event logged when a file version is restored
type AuditEventFileVersionRestored struct {
AuditEventFiles
+1 -1
View File
@@ -82,7 +82,7 @@ type LDAPProvider struct {
IDP string `yaml:"idp" env:"OCIS_URL;OCIS_OIDC_ISSUER;AUTH_BASIC_IDP_URL" desc:"The identity provider value to set in the userids of the CS3 user objects for users returned by this user provider." introductionVersion:"pre5.0"`
DisableUserMechanism string `yaml:"disable_user_mechanism" env:"OCIS_LDAP_DISABLE_USER_MECHANISM;AUTH_BASIC_DISABLE_USER_MECHANISM" desc:"An option to control the behavior for disabling users. Valid options are 'none', 'attribute' and 'group'. If set to 'group', disabling a user via API will add the user to the configured group for disabled users, if set to 'attribute' this will be done in the ldap user entry, if set to 'none' the disable request is not processed." introductionVersion:"pre5.0"`
LdapDisabledUsersGroupDN string `yaml:"ldap_disabled_users_group_dn" env:"OCIS_LDAP_DISABLED_USERS_GROUP_DN;AUTH_BASIC_DISABLED_USERS_GROUP_DN" desc:"The distinguished name of the group to which added users will be classified as disabled when 'disable_user_mechanism' is set to 'group'." introductionVersion:"pre5.0"`
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance." introductionVersion:"7.0"`
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance. Also set 'user_filter'. Without an explicit 'user_filter', this instance allows login for every user in the shared LDAP directory." introductionVersion:"7.0"`
UserMemberAttribute string `yaml:"user_member_attribute" env:"OCIS_LDAP_USER_MEMBER_ATTRIBUTE" desc:"LDAP attribute that marks a user as a member of an instance." introductionVersion:"7.0"`
UserGuestAttribute string `yaml:"user_guest_attribute" env:"OCIS_LDAP_USER_GUEST_ATTRIBUTE" desc:"LDAP attribute that marks a user as a guest of an instance." introductionVersion:"7.0"`
UserSchema LDAPUserSchema `yaml:"user_schema"`
@@ -42,5 +42,9 @@ func Validate(cfg *config.Config) error {
return shared.MissingLDAPBindPassword(cfg.Service.Name)
}
if cfg.AuthProvider == "ldap" && cfg.AuthProviders.LDAP.MasterID != "" && cfg.AuthProviders.LDAP.UserFilter == "" {
return shared.MissingLDAPUserFilterForMasterID(cfg.Service.Name)
}
return nil
}
@@ -0,0 +1,63 @@
package parser
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/owncloud/ocis/v2/services/auth-basic/pkg/config"
)
func TestValidateMasterIDRequiresUserFilter(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "auth-basic"},
TokenManager: &config.TokenManager{JWTSecret: "secret"},
AuthProvider: "ldap",
AuthProviders: config.AuthProviders{
LDAP: config.LDAPProvider{
BindPassword: "secret",
MasterID: "master-1",
UserFilter: "",
},
},
}
err := Validate(cfg)
assert.Error(t, err)
}
func TestValidateMasterIDWithUserFilterPasses(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "auth-basic"},
TokenManager: &config.TokenManager{JWTSecret: "secret"},
AuthProvider: "ldap",
AuthProviders: config.AuthProviders{
LDAP: config.LDAPProvider{
BindPassword: "secret",
MasterID: "master-1",
UserFilter: "(ownCloudMemberOf=instance-1)",
},
},
}
err := Validate(cfg)
assert.NoError(t, err)
}
func TestValidateNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "auth-basic"},
TokenManager: &config.TokenManager{JWTSecret: "secret"},
AuthProvider: "ldap",
AuthProviders: config.AuthProviders{
LDAP: config.LDAPProvider{
BindPassword: "secret",
MasterID: "",
UserFilter: "",
},
},
}
err := Validate(cfg)
assert.NoError(t, err)
}
+3 -3
View File
@@ -11,7 +11,7 @@ type Store struct {
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;COLLABORATION_STORE_TTL" desc:"Time to live for events in the store. Defaults to '30m' (30 minutes). See the Environment Variable Types description for more details." introductionVersion:"7.0.0"`
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;COLLABORATION_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.0.0"`
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;COLLABORATION_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.0.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;COLLABORATION_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;COLLABORATION_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;COLLABORATION_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;COLLABORATION_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;COLLABORATION_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;COLLABORATION_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
@@ -274,12 +274,15 @@ func (c *ContentConnector) PutFile(ctx context.Context, stream io.Reader, stream
},
}
gwc, err = c.gws.Next()
if err != nil {
return nil, err
}
// Initiate the upload request
resp, err := gwc.InitiateFileUpload(ctx, req)
// Initiate the upload request. The target file might still be processing,
// so we retry if we get a "TOO_EARLY" code
resp, err := retryWhileTooEarly(ctx, logger, "PutFile", func() (*gatewayv1beta1.InitiateFileUploadResponse, error) {
gwc, err := c.gws.Next()
if err != nil {
return nil, err
}
return gwc.InitiateFileUpload(ctx, req)
})
if err := requestFailed(logger, resp.GetStatus(), false, err, "PutFile: InitiateFileUpload failed"); err != nil {
return nil, err
}
@@ -410,6 +410,34 @@ var _ = Describe("ContentConnector", func() {
Expect(response).To(BeNil())
})
It("InitiateFileUpload retries while the file is processing", func() {
reader := strings.NewReader("Content to upload is here!")
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
gatewayClient.On("Stat", mock.Anything, mock.Anything).Times(1).Return(&providerv1beta1.StatResponse{
Status: status.NewOK(ctx),
Info: &providerv1beta1.ResourceInfo{
Lock: &providerv1beta1.Lock{
LockId: "goodAndValidLock",
Type: providerv1beta1.LockType_LOCK_TYPE_WRITE,
},
Size: uint64(123456789),
},
}, nil)
gatewayClient.On("InitiateFileUpload", mock.Anything, mock.Anything).Return(&gateway.InitiateFileUploadResponse{
Status: status.NewTooEarly(ctx, "resource is processing"),
}, nil).Twice()
gatewayClient.On("InitiateFileUpload", mock.Anything, mock.Anything).Return(&gateway.InitiateFileUploadResponse{
Status: status.NewOK(ctx),
}, nil).Once()
// no upload protocols are returned, so the upload fails after InitiateFileUpload succeeds
_, err := cc.PutFile(ctx, reader, reader.Size(), "goodAndValidLock")
Expect(err).To(Equal(connector.NewConnectorError(500, "url is missing")))
gatewayClient.AssertNumberOfCalls(GinkgoT(), "InitiateFileUpload", 3)
})
It("upload request failed", func() {
reader := strings.NewReader("Content to upload is here!")
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
@@ -939,42 +939,22 @@ func (f *FileConnector) DeleteFile(ctx context.Context, lockID string) (*Connect
Str("RequestedLockID", lockID).
Logger()
var deleteRes *providerv1beta1.DeleteResponse
deleteReq := &providerv1beta1.DeleteRequest{
Ref: wopiContext.FileReference,
LockId: lockID,
}
// we'll retry the request after a while if we get a "TOO_EARLY" code
for retries := 0; deleteRes == nil || deleteRes.GetStatus().GetCode() == rpcv1beta1.Code_CODE_TOO_EARLY; retries++ {
// the file might still be processing, so we retry if we get a "TOO_EARLY" code
deleteRes, err := retryWhileTooEarly(ctx, logger, "DeleteFile", func() (*providerv1beta1.DeleteResponse, error) {
gwc, err := f.gws.Next()
if err != nil {
return nil, err
}
deleteRes, err = gwc.Delete(ctx, deleteReq)
if err != nil {
logger.Error().Err(err).Msg("DeleteFile: stat failed")
return nil, err
}
if deleteRes.GetStatus().GetCode() == rpcv1beta1.Code_CODE_TOO_EARLY {
// starting from 20ms, double the waiting time for each retry
// capping at 5 secs
var waitingTime time.Duration
waitingTime = (20 * time.Millisecond) << retries
if waitingTime.Seconds() > 5 {
waitingTime = 5 * time.Second
}
logger.Warn().
Str("StatusCode", deleteRes.GetStatus().GetCode().String()).
Str("StatusMsg", deleteRes.GetStatus().GetMessage()).
Dur("WaitingTime", waitingTime).
Int("Retries", retries).
Msg("DeleteFile: file isn't ready yet. Retrying")
time.Sleep(waitingTime)
}
return gwc.Delete(ctx, deleteReq)
})
if err != nil {
logger.Error().Err(err).Msg("DeleteFile: delete failed")
return nil, err
}
if deleteRes.GetStatus().GetCode() != rpcv1beta1.Code_CODE_OK {
@@ -1092,15 +1072,18 @@ func (f *FileConnector) RenameFile(ctx context.Context, lockID, target string) (
// add the new file reference to the log context
newLogger := logger.With().Str("NewFileReference", targetFileReference.String()).Logger()
gwc, err = f.gws.Next()
if err != nil {
return nil, err
}
// try to put the file. It mustn't return a 400 or 409
moveRes, err := gwc.Move(ctx, &providerv1beta1.MoveRequest{
Source: wopiContext.FileReference,
Destination: targetFileReference,
LockId: lockID,
// try to move the file. It mustn't return a 400 or 409
// the file might still be processing, so we retry if we get a "TOO_EARLY" code
moveRes, err := retryWhileTooEarly(ctx, newLogger, "RenameFile", func() (*providerv1beta1.MoveResponse, error) {
gwc, err := f.gws.Next()
if err != nil {
return nil, err
}
return gwc.Move(ctx, &providerv1beta1.MoveRequest{
Source: wopiContext.FileReference,
Destination: targetFileReference,
LockId: lockID,
})
})
if err != nil {
newLogger.Error().Err(err).Msg("RenameFile: move failed")
@@ -1456,6 +1456,36 @@ var _ = Describe("FileConnector", func() {
Expect(response.Headers).To(BeNil())
})
It("Delete retries while the file is processing", func() {
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
gatewayClient.On("Delete", mock.Anything, mock.Anything).Return(&providerv1beta1.DeleteResponse{
Status: status.NewTooEarly(ctx, "file is processing"),
}, nil).Twice()
gatewayClient.On("Delete", mock.Anything, mock.Anything).Return(&providerv1beta1.DeleteResponse{
Status: status.NewOK(ctx),
}, nil).Once()
response, err := fc.DeleteFile(ctx, "newlock")
Expect(err).ToNot(HaveOccurred())
Expect(response.Status).To(Equal(200))
gatewayClient.AssertNumberOfCalls(GinkgoT(), "Delete", 3)
})
It("Delete stops retrying when the context is cancelled", func() {
cancelCtx, cancel := context.WithCancel(context.Background())
ctx := middleware.WopiContextToCtx(cancelCtx, wopiCtx)
gatewayClient.On("Delete", mock.Anything, mock.Anything).Return(&providerv1beta1.DeleteResponse{
Status: status.NewTooEarly(ctx, "file is processing"),
}, nil).Run(func(mock.Arguments) { cancel() }).Once()
response, err := fc.DeleteFile(ctx, "newlock")
Expect(err).To(MatchError(context.Canceled))
Expect(response).To(BeNil())
gatewayClient.AssertNumberOfCalls(GinkgoT(), "Delete", 1)
})
It("Delete success", func() {
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
@@ -1623,6 +1653,32 @@ var _ = Describe("FileConnector", func() {
Expect(rBody["Name"]).To(MatchRegexp(`^[a-zA-Z0-9_-]+ newFile$`))
})
It("Rename retries while the file is processing", func() {
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
gatewayClient.On("Stat", mock.Anything, mock.Anything).Times(1).Return(&providerv1beta1.StatResponse{
Status: status.NewOK(ctx),
Info: &providerv1beta1.ResourceInfo{
Lock: &providerv1beta1.Lock{
LockId: "zzz999",
Type: providerv1beta1.LockType_LOCK_TYPE_WRITE,
},
},
}, nil)
gatewayClient.On("Move", mock.Anything, mock.Anything).Return(&providerv1beta1.MoveResponse{
Status: status.NewTooEarly(ctx, "resource is processing"),
}, nil).Twice()
gatewayClient.On("Move", mock.Anything, mock.Anything).Return(&providerv1beta1.MoveResponse{
Status: status.NewOK(ctx),
}, nil).Once()
response, err := fc.RenameFile(ctx, "zzz999", "newFile.doc")
Expect(err).ToNot(HaveOccurred())
Expect(response.Status).To(Equal(200))
gatewayClient.AssertNumberOfCalls(GinkgoT(), "Move", 3)
})
It("Success", func() {
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
@@ -0,0 +1,56 @@
package connector
import (
"context"
"time"
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
"github.com/rs/zerolog"
)
const (
// tooEarlyInitialWait is the waiting time before the first retry
tooEarlyInitialWait = 20 * time.Millisecond
// tooEarlyMaxWait caps the waiting time between retries
tooEarlyMaxWait = 5 * time.Second
// tooEarlyMaxRetries limits the retries, so the request can't hang forever
tooEarlyMaxRetries = 10
)
// statusResponse is implemented by every CS3 response carrying a status
type statusResponse interface {
GetStatus() *rpcv1beta1.Status
}
// retryWhileTooEarly calls the request until the response status isn't
// "TOO_EARLY", which is returned while the target resource is still being
// processed (e.g. right after an upload). The waiting time starts at 20ms and
// doubles on each retry, capped at 5 seconds.
//
// The last response is returned if the resource is still processing after all
// the retries, so the caller must handle the "TOO_EARLY" code too. Errors abort
// the retries immediately, and so does a cancelled context, in which case the
// context error is returned.
func retryWhileTooEarly[T statusResponse](ctx context.Context, logger zerolog.Logger, msg string, request func() (T, error)) (T, error) {
for retries := 0; ; retries++ {
res, err := request()
if err != nil || res.GetStatus().GetCode() != rpcv1beta1.Code_CODE_TOO_EARLY || retries >= tooEarlyMaxRetries {
return res, err
}
waitingTime := min(tooEarlyInitialWait<<retries, tooEarlyMaxWait)
logger.Warn().
Str("StatusCode", res.GetStatus().GetCode().String()).
Str("StatusMsg", res.GetStatus().GetMessage()).
Dur("WaitingTime", waitingTime).
Int("Retries", retries).
Msg(msg + ": file isn't ready yet. Retrying")
select {
case <-ctx.Done():
return res, ctx.Err()
case <-time.After(waitingTime):
// nothing to do, the waiting time elapsed so we just retry the request
}
}
}
+3 -3
View File
@@ -45,9 +45,9 @@ type Store struct {
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;EVENTHISTORY_STORE_TTL" desc:"Time to live for events in the store. Defaults to '336h' (2 weeks). See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;EVENTHISTORY_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;EVENTHISTORY_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;EVENTHISTORY_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;EVENTHISTORY_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;EVENTHISTORY_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;EVENTHISTORY_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;EVENTHISTORY_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;EVENTHISTORY_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
// Events combines the configuration options for the event bus.
+7 -6
View File
@@ -71,6 +71,8 @@ type Config struct {
EnableVaultMode bool `yaml:"enable_vault_mode" env:"OCIS_ENABLE_VAULT_MODE;FRONTEND_ENABLE_VAULT_MODE" desc:"Enable vault mode. When enabled, the capabilities endpoint will report vault as enabled and the capabilities?vault=true endpoint will return capabilities with public sharing and federation disabled." introductionVersion:"8.1.0"`
DefaultVaultShareExpirationDays int `yaml:"default_vault_share_expiration_days" env:"OCIS_DEFAULT_VAULT_SHARE_EXPIRATION_DAYS;FRONTEND_DEFAULT_VAULT_SHARE_EXPIRATION_DAYS" desc:"The default expiration, in days, applied to a vault user or group share created without an explicit expiration date. Reported via the vault capability so clients can reflect the admin-configured value. Must match the graph service's GRAPH_DEFAULT_VAULT_SHARE_EXPIRATION_DAYS." introductionVersion:"9.0.0"`
Context context.Context `yaml:"-"`
}
@@ -148,9 +150,9 @@ type OCS struct {
StatCacheDisablePersistence bool `yaml:"stat_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disable persistence of the cache. Only applies when using the 'nats-js-kv' store type. Defaults to false." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DISABLE_PERSISTENCE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
StatCacheAuthUsername string `yaml:"stat_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_USERNAME in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
StatCacheAuthPassword string `yaml:"stat_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_PASSWORD in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
StatCacheEnableTLS bool `yaml:"stat_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the stat cache store. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
StatCacheTLSInsecure bool `yaml:"stat_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the stat cache store connection. Only applies when using the 'nats-js-kv' store type. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
StatCacheTLSRootCACertificate string `yaml:"stat_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the stat cache store TLS connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
StatCacheEnableTLS bool `yaml:"stat_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the stat cache store. Only applies when using the 'nats-js-kv' store type." introductionVersion:"9.0.0"`
StatCacheTLSInsecure bool `yaml:"stat_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the stat cache store connection. Only applies when using the 'nats-js-kv' store type. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
StatCacheTLSRootCACertificate string `yaml:"stat_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the stat cache store TLS connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"9.0.0"`
CacheWarmupDriver string `yaml:"cache_warmup_driver,omitempty"` // not supported by the oCIS product, therefore not part of docs
CacheWarmupDrivers CacheWarmupDrivers `yaml:"cache_warmup_drivers,omitempty"` // not supported by the oCIS product, therefore not part of docs
@@ -213,7 +215,6 @@ type Validation struct {
// MFAConfig configures multi factor multifactor authentication
type MFAConfig struct {
Enabled bool `yaml:"enabled" env:"OCIS_MFA_ENABLED" desc:"Set to true to enable multi factor authentication. See the documentation for more details." introductionVersion:"7.3.0"`
AuthLevelNames []string `yaml:"auth_level_names" env:"OCIS_MFA_AUTH_LEVEL_NAMES" desc:"This authentication level name indicates that multi-factor authentication was performed. The name must match the ACR claim in the access token received. Note: If multiple names are required, use a comma-separated list. The front-end service will use the first name in the list when requesting multi-factor authentication (MFA)." introductionVersion:"7.3.0"`
SessionDuration int `yaml:"session_duration" env:"OCIS_MFA_SESSION_DURATION" desc:"The duration in seconds that a multi-factor authentication session is valid. After this time the user will be prompted to re-authenticate. Defaults to 3600 (1 hour)." introductionVersion:"8.1.0"`
Enabled bool `yaml:"enabled" env:"OCIS_MFA_ENABLED" desc:"Set to true to enable multi factor authentication. See the documentation for more details." introductionVersion:"7.3.0"`
AuthLevelNames []string `yaml:"auth_level_names" env:"OCIS_MFA_AUTH_LEVEL_NAMES" desc:"This authentication level name indicates that multi-factor authentication was performed. The name must match the ACR claim in the access token received. Note: If multiple names are required, use a comma-separated list. The front-end service will use the first name in the list when requesting multi-factor authentication (MFA)." introductionVersion:"7.3.0"`
}
@@ -144,9 +144,9 @@ func DefaultConfig() *config.Config {
MaxTagLength: 100,
},
MultiFactorAuthentication: config.MFAConfig{
AuthLevelNames: []string{"advanced"},
SessionDuration: 3600,
AuthLevelNames: []string{"advanced"},
},
DefaultVaultShareExpirationDays: 30,
}
}
+4 -4
View File
@@ -361,13 +361,13 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
},
"auth": map[string]interface{}{
"mfa": map[string]interface{}{
"enabled": cfg.MultiFactorAuthentication.Enabled,
"levelnames": cfg.MultiFactorAuthentication.AuthLevelNames,
"session_duration": cfg.MultiFactorAuthentication.SessionDuration,
"enabled": cfg.MultiFactorAuthentication.Enabled,
"levelnames": cfg.MultiFactorAuthentication.AuthLevelNames,
},
},
"vault": map[string]interface{}{
"enabled": cfg.EnableVaultMode,
"enabled": cfg.EnableVaultMode,
"default_share_expiration_days": cfg.DefaultVaultShareExpirationDays,
},
},
"version": map[string]interface{}{
+10 -10
View File
@@ -88,14 +88,14 @@ type StorageRegistry struct {
// Cache holds cache config
type Cache struct {
ProviderCacheStore string `yaml:"provider_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_PROVIDER_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0"`
ProviderCacheNodes []string `yaml:"provider_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_PROVIDER_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
ProviderCacheDatabase string `yaml:"provider_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0"`
ProviderCacheTTL time.Duration `yaml:"provider_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_PROVIDER_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
ProviderCacheDisablePersistence bool `yaml:"provider_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;GATEWAY_PROVIDER_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the provider cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
ProviderCacheAuthUsername string `yaml:"provider_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME;GATEWAY_PROVIDER_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
ProviderCacheAuthPassword string `yaml:"provider_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD;GATEWAY_PROVIDER_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
ProviderCacheEnableTLS bool `yaml:"provider_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GATEWAY_PROVIDER_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
ProviderCacheTLSInsecure bool `yaml:"provider_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GATEWAY_PROVIDER_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
ProviderCacheTLSRootCACertificate string `yaml:"provider_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GATEWAY_PROVIDER_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
ProviderCacheStore string `yaml:"provider_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_PROVIDER_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0"`
ProviderCacheNodes []string `yaml:"provider_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_PROVIDER_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
ProviderCacheDatabase string `yaml:"provider_cache_database" env:"OCIS_CACHE_DATABASE;GATEWAY_PROVIDER_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"9.0" deprecationInfo:"The global variable OCIS_CACHE_DATABASE is deprecated and will be removed in a future release. Please use local variable GATEWAY_PROVIDER_CACHE_DATABASE instead."`
ProviderCacheTTL time.Duration `yaml:"provider_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_PROVIDER_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
ProviderCacheDisablePersistence bool `yaml:"provider_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;GATEWAY_PROVIDER_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the provider cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
ProviderCacheAuthUsername string `yaml:"provider_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME;GATEWAY_PROVIDER_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
ProviderCacheAuthPassword string `yaml:"provider_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD;GATEWAY_PROVIDER_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
ProviderCacheEnableTLS bool `yaml:"provider_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GATEWAY_PROVIDER_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
ProviderCacheTLSInsecure bool `yaml:"provider_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GATEWAY_PROVIDER_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
ProviderCacheTLSRootCACertificate string `yaml:"provider_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GATEWAY_PROVIDER_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
+3 -3
View File
@@ -12,7 +12,7 @@ type Cache struct {
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;GRAPH_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;GRAPH_CACHE_AUTH_USERNAME" desc:"The username to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;GRAPH_CACHE_AUTH_PASSWORD" desc:"The password to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GRAPH_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GRAPH_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GRAPH_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GRAPH_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GRAPH_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GRAPH_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
+5 -3
View File
@@ -45,6 +45,8 @@ type Config struct {
EnableVaultMode bool `yaml:"enable_vault_mode" env:"OCIS_ENABLE_VAULT_MODE;GRAPH_ENABLE_VAULT_MODE" desc:"Enable vault mode in addition to the regular graph service. This only applies when the additional storage-users-vault service is running, which is a special configured storage-users service." introductionVersion:"8.1.0"`
DefaultVaultShareExpirationDays int `yaml:"default_vault_share_expiration_days" env:"OCIS_DEFAULT_VAULT_SHARE_EXPIRATION_DAYS;GRAPH_DEFAULT_VAULT_SHARE_EXPIRATION_DAYS" desc:"The default expiration, in days, applied to a vault user or group share created without an explicit expiration date. Space memberships are exempt." introductionVersion:"9.0.0"`
EnableUserSharing bool `yaml:"enable_user_sharing" env:"OCIS_ENABLE_USER_SHARING" desc:"Enables direct sharing with users and groups. When disabled, creating new user, group or federated shares via the drive item invite endpoints is rejected. Public link sharing and space membership are not affected." introductionVersion:"8.2.0"`
Context context.Context `yaml:"-"`
@@ -123,7 +125,7 @@ type LDAP struct {
InstanceMapperIDAttribute string `yaml:"instance_mapper_id_attribute" env:"OCIS_LDAP_INSTANCE_MAPPER_ID_ATTRIBUTE" desc:"LDAP Attribute of the instance ID. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
CrossInstanceReferenceTemplate string `yaml:"cross_instance_reference_template" env:"OCIS_LDAP_CROSS_INSTANCE_REFERENCE_TEMPLATE" desc:"Template for the users unique reference across oCIS instances. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
InstanceURLTemplate string `yaml:"instance_url_template" env:"OCIS_LDAP_INSTANCE_URL_TEMPLATE" desc:"Template for the instance URL. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.3.0"`
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"9.0.0"`
}
// LDAPEducationConfig represents the LDAP configuration for education related resources
@@ -192,13 +194,13 @@ type ServiceAccount struct {
type Validation struct {
MaxTagLength int `yaml:"max_tag_length" env:"OCIS_MAX_TAG_LENGTH" desc:"Define the maximum tag length. Defaults to 100 if not set. Set to 0 to not limit the tag length. Changes only impact the validation of new tags." introductionVersion:"7.2.0"`
MaxImageFileSize string `yaml:"max_image_file_size" env:"GRAPH_MAX_IMAGE_FILE_SIZE" desc:"The maximum file size of an image which can be set as a space image. Must be less than or equal to 'THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE' of the thumbnails service, otherwise images between the two values are accepted but cannot be rendered. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB, TB, TiB, PB, PiB, EB, EiB], example: 2GB. Set to 0 to not limit the file size." introductionVersion:"8.3.0"`
MaxImageFileSize string `yaml:"max_image_file_size" env:"GRAPH_MAX_IMAGE_FILE_SIZE" desc:"The maximum file size of an image which can be set as a space image. Must be less than or equal to 'THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE' of the thumbnails service, otherwise images between the two values are accepted but cannot be rendered. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB, TB, TiB, PB, PiB, EB, EiB], example: 2GB. Set to 0 to not limit the file size." introductionVersion:"9.0.0"`
}
// MultiInstanceConfig holds configuration for multi-instance-ocis
type MultiInstanceConfig struct {
Enabled bool `yaml:"enabled" env:"OCIS_MULTI_INSTANCE_ENABLED" desc:"Enable multiple instances of Infinite Scale." introductionVersion:"8.0.0"`
InstanceID string `yaml:"instanceid" env:"OCIS_MULTI_INSTANCE_INSTANCEID" desc:"The unique ID of this instance." introductionVersion:"8.0.0"`
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master ID that grants access to all instances. Users with this ID in their memberOf or guestOf claims can access any instance. Leave empty to disable." introductionVersion:"8.1.0"`
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master ID that grants access to all instances. Users with this ID in their memberOf or guestOf claims can access any instance. Leave empty to disable. Also set 'OCIS_LDAP_USER_FILTER'. Without an explicit user filter, this instance resolves every user in the shared LDAP directory." introductionVersion:"8.1.0"`
QueryRegexp string `yaml:"query_regexp" env:"OCIS_MULTI_INSTANCE_QUERY_TEMPLATE" desc:"The regular expression extracting username and instancename from a user provided search." introductionVersion:"8.0.0"`
}
@@ -134,9 +134,10 @@ func DefaultConfig() *config.Config {
Cluster: "ocis-cluster",
EnableTLS: false,
},
MaxConcurrency: 20,
ReceivedSharesStatTimeout: 10 * time.Second,
EnableUserSharing: true,
MaxConcurrency: 20,
ReceivedSharesStatTimeout: 10 * time.Second,
EnableUserSharing: true,
DefaultVaultShareExpirationDays: 30,
UnifiedRoles: config.UnifiedRoles{
AvailableRoles: nil, // will be populated with defaults in EnsureDefaults
},
@@ -98,6 +98,10 @@ func validateLDAPSettings(cfg *config.Config) error {
return shared.MissingLDAPBindPassword(cfg.Service.Name)
}
if cfg.MultiInstance.MasterID != "" && cfg.Identity.LDAP.UserFilter == "" {
return shared.MissingLDAPUserFilterForMasterID(cfg.Service.Name)
}
// ensure that "GroupBaseDN" is below "GroupBaseDN"
if cfg.Identity.LDAP.WriteEnabled && cfg.Identity.LDAP.GroupCreateBaseDN != cfg.Identity.LDAP.GroupBaseDN {
baseDN, err := ldap.ParseDN(cfg.Identity.LDAP.GroupBaseDN)
@@ -0,0 +1,63 @@
package parser
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
)
func TestValidateLDAPSettingsMasterIDRequiresUserFilter(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "graph"},
Identity: config.Identity{
LDAP: config.LDAP{
BindPassword: "secret",
UserFilter: "",
},
},
MultiInstance: config.MultiInstanceConfig{
MasterID: "master-1",
},
}
err := validateLDAPSettings(cfg)
assert.Error(t, err)
}
func TestValidateLDAPSettingsMasterIDWithUserFilterPasses(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "graph"},
Identity: config.Identity{
LDAP: config.LDAP{
BindPassword: "secret",
UserFilter: "(ownCloudMemberOf=instance-1)",
},
},
MultiInstance: config.MultiInstanceConfig{
MasterID: "master-1",
},
}
err := validateLDAPSettings(cfg)
assert.NoError(t, err)
}
func TestValidateLDAPSettingsNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "graph"},
Identity: config.Identity{
LDAP: config.LDAP{
BindPassword: "secret",
UserFilter: "",
},
},
MultiInstance: config.MultiInstanceConfig{
MasterID: "",
},
}
err := validateLDAPSettings(cfg)
assert.NoError(t, err)
}
@@ -7,6 +7,7 @@ import (
"net/url"
"slices"
"strings"
"time"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
grouppb "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
@@ -177,6 +178,18 @@ func (s DriveItemPermissionsService) Invite(ctx context.Context, resourceId *sto
var shareid string
var expiration *types.Timestamp
var cTime *types.Timestamp
// use the client-supplied expiration, else default vault shares to DefaultVaultShareExpirationDays;
// space memberships and non-vault shares are exempt
resourceID := statResponse.GetInfo().GetId()
var shareExpiration *types.Timestamp
switch {
case invite.ExpirationDateTime != nil:
shareExpiration = utils.TimeToTS(*invite.ExpirationDateTime)
case !IsSpaceRoot(resourceID) && IsVaultResource(resourceID):
shareExpiration = utils.TimeToTS(time.Now().UTC().AddDate(0, 0, s.config.DefaultVaultShareExpirationDays))
}
switch driveRecipient.GetLibreGraphRecipientType() {
case "group":
group, err := s.identityCache.GetGroup(ctx, objectID)
@@ -192,8 +205,8 @@ func (s DriveItemPermissionsService) Invite(ctx context.Context, resourceId *sto
},
}
createShareRequest := createShareRequestToGroup(group, statResponse.GetInfo(), cs3ResourcePermissions)
if invite.ExpirationDateTime != nil {
createShareRequest.GetGrant().Expiration = utils.TimeToTS(*invite.ExpirationDateTime)
if shareExpiration != nil {
createShareRequest.GetGrant().Expiration = shareExpiration
}
createShareResponse, err := gatewayClient.CreateShare(ctx, createShareRequest)
if err := errorcode.FromCS3Status(createShareResponse.GetStatus(), err); err != nil {
@@ -246,8 +259,8 @@ func (s DriveItemPermissionsService) Invite(ctx context.Context, resourceId *sto
}
createShareRequest := createShareRequestToFederatedUser(user, statResponse.GetInfo().GetId(), providerInfoResp.ProviderInfo, cs3ResourcePermissions)
if invite.ExpirationDateTime != nil {
createShareRequest.Expiration = utils.TimeToTS(*invite.ExpirationDateTime)
if shareExpiration != nil {
createShareRequest.Expiration = shareExpiration
}
createShareResponse, err := gatewayClient.CreateOCMShare(ctx, createShareRequest)
if err := errorcode.FromCS3Status(createShareResponse.GetStatus(), err); err != nil {
@@ -259,8 +272,8 @@ func (s DriveItemPermissionsService) Invite(ctx context.Context, resourceId *sto
expiration = createShareResponse.GetShare().GetExpiration()
} else {
createShareRequest := createShareRequestToUser(user, statResponse.GetInfo(), cs3ResourcePermissions)
if invite.ExpirationDateTime != nil {
createShareRequest.GetGrant().Expiration = utils.TimeToTS(*invite.ExpirationDateTime)
if shareExpiration != nil {
createShareRequest.GetGrant().Expiration = shareExpiration
}
createShareResponse, err := gatewayClient.CreateShare(ctx, createShareRequest)
if err := errorcode.FromCS3Status(createShareResponse.GetStatus(), err); err != nil {
@@ -173,7 +173,7 @@ func (api DriveItemPermissionsApi) CreateLink(w http.ResponseWriter, r *http.Req
var createLink libregraph.DriveItemCreateLink
if err = StrictJSONUnmarshal(r.Body, &createLink); err != nil {
logger.Error().Err(err).Interface("body", r.Body).Msg("could not create link: invalid body schema definition")
logger.Error().Err(err).Msg("could not create link: invalid body schema definition")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
return
}
@@ -202,7 +202,7 @@ func (api DriveItemPermissionsApi) CreateSpaceRootLink(w http.ResponseWriter, r
var createLink libregraph.DriveItemCreateLink
if err = StrictJSONUnmarshal(r.Body, &createLink); err != nil {
logger.Error().Err(err).Interface("body", r.Body).Msg("could not create link: invalid body schema definition")
logger.Error().Err(err).Msg("could not create link: invalid body schema definition")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
return
}
@@ -174,6 +174,121 @@ var _ = Describe("DriveItemPermissionsService", func() {
Expect(permission.GrantedToV2.Group.GetId()).To(Equal("2"))
})
It("applies a default 30-day expiration to a vault user share created without one", func() {
statResponse.Info.Id = &provider.ResourceId{
StorageId: utils.VaultStorageProviderID,
SpaceId: driveItemId.SpaceId,
OpaqueId: driveItemId.OpaqueId,
}
var capturedReq *collaboration.CreateShareRequest
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
capturedReq = args.Get(1).(*collaboration.CreateShareRequest)
}).Return(createShareResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
{ObjectId: libregraph.PtrString("1"), LibreGraphRecipientType: libregraph.PtrString("user")},
}
driveItemInvite.ExpirationDateTime = nil
createShareResponse.Share = &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: "123"},
}
expectedDefault := time.Now().UTC().AddDate(0, 0, 30)
_, err := driveItemPermissionsService.Invite(context.Background(), driveItemId, driveItemInvite)
Expect(err).ToNot(HaveOccurred())
Expect(capturedReq.GetGrant().GetExpiration()).ToNot(BeNil())
Expect(utils.TSToTime(capturedReq.GetGrant().GetExpiration())).To(BeTemporally("~", expectedDefault, time.Minute))
})
It("applies a default 30-day expiration to a vault group share created without one", func() {
statResponse.Info.Id = &provider.ResourceId{
StorageId: utils.VaultStorageProviderID,
SpaceId: driveItemId.SpaceId,
OpaqueId: driveItemId.OpaqueId,
}
var capturedReq *collaboration.CreateShareRequest
gatewayClient.On("GetGroup", mock.Anything, mock.Anything).Return(getGroupResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
capturedReq = args.Get(1).(*collaboration.CreateShareRequest)
}).Return(createShareResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
{ObjectId: libregraph.PtrString("2"), LibreGraphRecipientType: libregraph.PtrString("group")},
}
driveItemInvite.ExpirationDateTime = nil
createShareResponse.Share = &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: "123"},
}
expectedDefault := time.Now().UTC().AddDate(0, 0, 30)
_, err := driveItemPermissionsService.Invite(context.Background(), driveItemId, driveItemInvite)
Expect(err).ToNot(HaveOccurred())
Expect(capturedReq.GetGrant().GetExpiration()).ToNot(BeNil())
Expect(utils.TSToTime(capturedReq.GetGrant().GetExpiration())).To(BeTemporally("~", expectedDefault, time.Minute))
})
It("does not apply a default expiration to a non-vault user share created without one", func() {
var capturedReq *collaboration.CreateShareRequest
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
capturedReq = args.Get(1).(*collaboration.CreateShareRequest)
}).Return(createShareResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
{ObjectId: libregraph.PtrString("1"), LibreGraphRecipientType: libregraph.PtrString("user")},
}
driveItemInvite.ExpirationDateTime = nil
createShareResponse.Share = &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: "123"},
}
_, err := driveItemPermissionsService.Invite(context.Background(), driveItemId, driveItemInvite)
Expect(err).ToNot(HaveOccurred())
Expect(capturedReq.GetGrant().GetExpiration()).To(BeNil())
})
It("does not apply a default expiration to a non-vault group share created without one", func() {
var capturedReq *collaboration.CreateShareRequest
gatewayClient.On("GetGroup", mock.Anything, mock.Anything).Return(getGroupResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
capturedReq = args.Get(1).(*collaboration.CreateShareRequest)
}).Return(createShareResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
{ObjectId: libregraph.PtrString("2"), LibreGraphRecipientType: libregraph.PtrString("group")},
}
driveItemInvite.ExpirationDateTime = nil
createShareResponse.Share = &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: "123"},
}
_, err := driveItemPermissionsService.Invite(context.Background(), driveItemId, driveItemInvite)
Expect(err).ToNot(HaveOccurred())
Expect(capturedReq.GetGrant().GetExpiration()).To(BeNil())
})
It("keeps a client-provided expiration instead of the default", func() {
var capturedReq *collaboration.CreateShareRequest
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
capturedReq = args.Get(1).(*collaboration.CreateShareRequest)
}).Return(createShareResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
{ObjectId: libregraph.PtrString("1"), LibreGraphRecipientType: libregraph.PtrString("user")},
}
explicit := time.Now().Add(time.Hour)
driveItemInvite.ExpirationDateTime = libregraph.PtrTime(explicit)
createShareResponse.Share = &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: "123"},
}
_, err := driveItemPermissionsService.Invite(context.Background(), driveItemId, driveItemInvite)
Expect(err).ToNot(HaveOccurred())
Expect(utils.TSToTime(capturedReq.GetGrant().GetExpiration())).To(BeTemporally("~", explicit, time.Second))
})
It("succeeds with file roles (happy path)", func() {
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).Return(createShareResponse, nil)
@@ -349,6 +464,37 @@ var _ = Describe("DriveItemPermissionsService", func() {
Expect(permission.GrantedToV2.User.GetDisplayName()).To(Equal(getUserResponse.User.DisplayName))
Expect(permission.GrantedToV2.User.GetId()).To(Equal("1"))
})
It("does not apply a default expiration to a space membership created without one", func() {
root := &provider.ResourceId{
StorageId: utils.VaultStorageProviderID,
SpaceId: "2",
OpaqueId: "2", // space root: OpaqueId == SpaceId
}
listSpacesResponse.StorageSpaces[0].SpaceType = "project"
listSpacesResponse.StorageSpaces[0].Root = root
statResponse.Info.Id = root
statResponse.Info.Space = &provider.StorageSpace{Root: root}
var capturedReq *collaboration.CreateShareRequest
gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(listSpacesResponse, nil)
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(statResponse, nil)
gatewayClient.On("CreateShare", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
capturedReq = args.Get(1).(*collaboration.CreateShareRequest)
}).Return(createShareResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
{ObjectId: libregraph.PtrString("1"), LibreGraphRecipientType: libregraph.PtrString("user")},
}
driveItemInvite.ExpirationDateTime = nil
createShareResponse.Share = &collaboration.Share{
Id: &collaboration.ShareId{OpaqueId: "123"},
}
_, err := driveItemPermissionsService.SpaceRootInvite(context.Background(), driveId, driveItemInvite)
Expect(err).ToNot(HaveOccurred())
Expect(capturedReq.GetGrant().GetExpiration()).To(BeNil())
})
It("rejects to add a user to a personal space", func() {
gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(listSpacesResponse, nil)
driveItemInvite.Recipients = []libregraph.DriveRecipient{
@@ -149,7 +149,7 @@ func (g Graph) CreateAppRoleAssignment(w http.ResponseWriter, r *http.Request) {
// DeleteAppRoleAssignment implements the Service interface.
func (g Graph) DeleteAppRoleAssignment(w http.ResponseWriter, r *http.Request) {
logger := g.logger.SubloggerWithRequestID(r.Context())
logger.Info().Interface("body", r.Body).Msg("calling delete appRoleAssignment")
logger.Info().Msg("calling delete appRoleAssignment")
userID := chi.URLParam(r, "userID")
+2 -2
View File
@@ -444,7 +444,7 @@ func (g Graph) createDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
drive := libregraph.Drive{}
if err := StrictJSONUnmarshal(r.Body, &drive); err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create drive: invalid body schema definition")
logger.Debug().Err(err).Msg("could not create drive: invalid body schema definition")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
return
}
@@ -582,7 +582,7 @@ func (g Graph) updateDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
drive := libregraph.DriveUpdate{}
if err = StrictJSONUnmarshal(r.Body, &drive); err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update drive, invalid request body")
logger.Debug().Err(err).Msg("could not update drive, invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: error: %v", err.Error()))
return
}
@@ -54,7 +54,7 @@ func (g Graph) PostEducationClass(w http.ResponseWriter, r *http.Request) {
class := libregraph.NewEducationClassWithDefaults()
err := StrictJSONUnmarshal(r.Body, class)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create education class: invalid request body")
logger.Debug().Err(err).Msg("could not create education class: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -110,7 +110,7 @@ func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) {
changes := libregraph.NewEducationClassWithDefaults()
err = StrictJSONUnmarshal(r.Body, changes)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not change class: invalid request body")
logger.Debug().Err(err).Msg("could not change class: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -315,10 +315,7 @@ func (g Graph) PostEducationClassMember(w http.ResponseWriter, r *http.Request)
memberRef := libregraph.NewMemberReference()
err = StrictJSONUnmarshal(r.Body, memberRef)
if err != nil {
logger.Debug().
Err(err).
Interface("body", r.Body).
Msg("could not add class member: invalid request body")
logger.Debug().Err(err).Msg("could not add class member: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -461,10 +458,7 @@ func (g Graph) PostEducationClassTeacher(w http.ResponseWriter, r *http.Request)
memberRef := libregraph.NewMemberReference()
err = StrictJSONUnmarshal(r.Body, memberRef)
if err != nil {
logger.Debug().
Err(err).
Interface("body", r.Body).
Msg("could not add class teacher: invalid request body")
logger.Debug().Err(err).Msg("could not add class teacher: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -54,7 +54,7 @@ func (g Graph) PostEducationSchool(w http.ResponseWriter, r *http.Request) {
school := libregraph.NewEducationSchool()
err := StrictJSONUnmarshal(r.Body, school)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create school: invalid request body")
logger.Debug().Err(err).Msg("could not create school: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -131,7 +131,7 @@ func (g Graph) PatchEducationSchool(w http.ResponseWriter, r *http.Request) {
school := libregraph.NewEducationSchool()
err = StrictJSONUnmarshal(r.Body, school)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update school: invalid request body")
logger.Debug().Err(err).Msg("could not update school: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -330,10 +330,7 @@ func (g Graph) PostEducationSchoolUser(w http.ResponseWriter, r *http.Request) {
memberRef := libregraph.NewMemberReference()
err = StrictJSONUnmarshal(r.Body, memberRef)
if err != nil {
logger.Debug().
Err(err).
Interface("body", r.Body).
Msg("could not add school user: invalid request body")
logger.Debug().Err(err).Msg("could not add school user: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -485,10 +482,7 @@ func (g Graph) PostEducationSchoolClass(w http.ResponseWriter, r *http.Request)
memberRef := libregraph.NewMemberReference()
err = StrictJSONUnmarshal(r.Body, memberRef)
if err != nil {
logger.Debug().
Err(err).
Interface("body", r.Body).
Msg("could not add school class: invalid request body")
logger.Debug().Err(err).Msg("could not add school class: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -52,11 +52,11 @@ func (g Graph) GetEducationUsers(w http.ResponseWriter, r *http.Request) {
// PostEducationUser implements the Service interface.
func (g Graph) PostEducationUser(w http.ResponseWriter, r *http.Request) {
logger := g.logger.SubloggerWithRequestID(r.Context())
logger.Info().Interface("body", r.Body).Msg("calling create education user")
logger.Info().Msg("calling create education user")
u := libregraph.NewEducationUser()
err := StrictJSONUnmarshal(r.Body, u)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create education user: invalid request body")
logger.Debug().Err(err).Msg("could not create education user: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %v", err.Error()))
return
}
@@ -321,7 +321,7 @@ func (g Graph) PatchEducationUser(w http.ResponseWriter, r *http.Request) {
changes := libregraph.NewEducationUser()
err = StrictJSONUnmarshal(r.Body, changes)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update education user: invalid request body")
logger.Debug().Err(err).Msg("could not update education user: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("invalid request body: %s", err.Error()))
return
+4 -7
View File
@@ -99,7 +99,7 @@ func (g Graph) PostGroup(w http.ResponseWriter, r *http.Request) {
grp := libregraph.NewGroup()
err := StrictJSONUnmarshal(r.Body, grp)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create group: invalid request body")
logger.Debug().Err(err).Msg("could not create group: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
@@ -164,13 +164,13 @@ func (g Graph) PatchGroup(w http.ResponseWriter, r *http.Request) {
changes := libregraph.NewGroup()
err = StrictJSONUnmarshal(r.Body, changes)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not change group: invalid request body")
logger.Debug().Err(err).Msg("could not change group: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
if reflect.ValueOf(*changes).IsZero() {
logger.Debug().Interface("body", r.Body).Msg("ignoring empyt request body")
logger.Debug().Msg("ignoring empyt request body")
render.Status(r, http.StatusNoContent)
render.NoContent(w, r)
return
@@ -370,10 +370,7 @@ func (g Graph) PostGroupMember(w http.ResponseWriter, r *http.Request) {
memberRef := libregraph.NewMemberReference()
err = StrictJSONUnmarshal(r.Body, memberRef)
if err != nil {
logger.Debug().
Err(err).
Interface("body", r.Body).
Msg("could not add group member: invalid request body")
logger.Debug().Err(err).Msg("could not add group member: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
return
}
+7 -2
View File
@@ -16,6 +16,7 @@ import (
"github.com/owncloud/reva/v2/pkg/events"
"github.com/owncloud/reva/v2/pkg/storagespace"
"github.com/owncloud/reva/v2/pkg/tags"
"github.com/owncloud/reva/v2/pkg/utils"
"go-micro.dev/v4/metadata"
)
@@ -56,7 +57,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
)
if err := StrictJSONUnmarshal(r.Body, &assignment); err != nil {
g.logger.Debug().Err(err).Interface("body", r.Body).Msg("could not decode tag assignment request")
g.logger.Debug().Err(err).Msg("could not decode tag assignment request")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
return
}
@@ -141,6 +142,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
if g.eventsPublisher != nil {
ev := events.TagsAdded{
// The tags as requested, including any that were already present.
Tags: strings.Join(assignment.Tags, ","),
Ref: &provider.Reference{
ResourceId: &rid,
@@ -148,6 +150,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
},
SpaceOwner: sres.Info.Owner,
Executant: revaCtx.ContextMustGetUser(r.Context()).Id,
Timestamp: utils.TSNow(),
}
if err := events.Publish(r.Context(), g.eventsPublisher, ev); err != nil {
g.logger.Error().Err(err).Msg("Failed to publish TagsAdded event")
@@ -163,7 +166,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
)
if err := StrictJSONUnmarshal(r.Body, &unassignment); err != nil {
g.logger.Debug().Err(err).Interface("body", r.Body).Msg("could not decode tag assignment request")
g.logger.Debug().Err(err).Msg("could not decode tag assignment request")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
return
}
@@ -239,6 +242,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
// Always publish the event so the search index gets updated,
// even if the tag was already absent from file metadata.
ev := events.TagsRemoved{
// The tags as requested, including any that were not present.
Tags: strings.Join(unassignment.Tags, ","),
Ref: &provider.Reference{
ResourceId: &rid,
@@ -246,6 +250,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
},
SpaceOwner: sres.Info.Owner,
Executant: revaCtx.ContextMustGetUser(ctx).Id,
Timestamp: utils.TSNow(),
}
if g.publishTagsRemoved(ctx, client, ev, tagsChanged, currentTags) != nil {
w.WriteHeader(http.StatusInternalServerError)
+5 -5
View File
@@ -386,11 +386,11 @@ func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {
username, instancename := g.parseExternalSearch(odataReq)
switch {
case odataReq.Query.Filter != nil:
users, err = g.applyUserFilter(r.Context(), odataReq, nil)
case username != "" && instancename != "" && g.contextUserHasExternalSharePermission(r.Context()):
users = make([]*libregraph.User, 1)
users[0], err = g.identityBackend.GetPreciseUser(r.Context(), username, instancename, odataReq)
case odataReq.Query.Filter != nil:
users, err = g.applyUserFilter(r.Context(), odataReq, nil)
default:
users, err = g.identityBackend.GetUsers(r.Context(), odataReq)
}
@@ -857,7 +857,7 @@ func (g Graph) PatchMe(w http.ResponseWriter, r *http.Request) {
changes := libregraph.NewUserUpdate()
err := StrictJSONUnmarshal(r.Body, changes)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update user: invalid request body")
logger.Debug().Err(err).Msg("could not update user: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("invalid request body: %s", err.Error()))
return
@@ -904,7 +904,7 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
changes := libregraph.NewUserUpdate()
err = StrictJSONUnmarshal(r.Body, changes)
if err != nil {
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update user: invalid request body")
logger.Debug().Err(err).Msg("could not update user: invalid request body")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("invalid request body: %s", err.Error()))
return
@@ -945,7 +945,7 @@ func (g Graph) patchUser(w http.ResponseWriter, r *http.Request, nameOrID string
}
if reflect.ValueOf(*changes).IsZero() {
logger.Debug().Interface("body", r.Body).Msg("ignoring empty request body")
logger.Debug().Msg("ignoring empty request body")
render.Status(r, http.StatusNoContent)
render.NoContent(w, r)
return
+198 -46
View File
@@ -610,6 +610,165 @@ var _ = Describe("Users", func() {
})
})
// vaultRole is a role bundle that grants vault mode, vaultLessRole is one that does not.
const (
vaultRole = "vault-granting-role-ID"
vaultLessRole = "ordinary-role-ID"
eligibleUser = "25cb7bc0-3168-4a0c-adbe-396f478ad494"
otherUser = "2713f1d5-6822-42bd-ad56-9f6c55a3a8fa"
)
// expectRoles makes the settings service report both roles, only one of which
// carries the vault mode permission.
expectRoles := func() {
roleService.On("ListRoles", mock.Anything, mock.Anything, mock.Anything).Return(&settings.ListBundlesResponse{
Bundles: []*settingsmsg.Bundle{
{
Id: vaultRole,
Type: settingsmsg.Bundle_TYPE_ROLE,
Settings: []*settingsmsg.Setting{
{
Name: permission.VaultMode,
Value: &settingsmsg.Setting_PermissionValue{PermissionValue: &settingsmsg.Permission{}},
},
},
},
{
Id: vaultLessRole,
Type: settingsmsg.Bundle_TYPE_ROLE,
Settings: []*settingsmsg.Setting{
{
Name: "Some.OtherPermission",
Value: &settingsmsg.Setting_PermissionValue{PermissionValue: &settingsmsg.Permission{}},
},
},
},
},
}, 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)
}
Describe("GetUsers with a cross-instance search string", func() {
BeforeEach(func() {
cfg.MultiInstance.Enabled = true
cfg.MultiInstance.QueryRegexp = `^([^@]+)@([^.]+)\.example\.test$`
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settings.GetPermissionByIDResponse{
Permission: &settingsmsg.Permission{
Operation: settingsmsg.Permission_OPERATION_UNKNOWN,
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
},
}, nil)
})
// None of these reach GetPreciseUser: a filter, a non-matching search, no search at
// all, or missing permission each independently keep it from firing.
DescribeTable("does not resolve via GetPreciseUser",
func(search string, filter string, permissionGranted bool, needsMFA bool) {
identityBackend.On("GetUsers", mock.Anything, mock.Anything).Return([]*libregraph.User{}, nil)
student := &libregraph.User{}
student.SetId("precise-student")
identityBackend.On("GetPreciseUser", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(student, nil)
if !permissionGranted {
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Unset()
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settings.GetPermissionByIDResponse{}, nil)
}
path := "/graph/v1.0/users"
if search != "" {
path += "?$search=" + url.QueryEscape(search)
}
if filter != "" {
sep := "?"
if search != "" {
sep = "&"
}
path += sep + "$filter=" + url.QueryEscape(filter)
}
r := httptest.NewRequest(http.MethodGet, path, nil)
if needsMFA {
r = r.WithContext(revactx.SetMFA(r.Context()))
}
svc.GetUsers(rr, r)
Expect(rr.Code).To(Equal(http.StatusOK))
identityBackend.AssertNotCalled(GinkgoT(), "GetPreciseUser", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
},
Entry("filter present, even though the search string also matches the cross-instance pattern",
`"student@other-instance.example.test"`, "vaultEligible eq true", true, false),
Entry("search string doesn't match the cross-instance pattern",
`"not-a-cross-instance-string"`, "", true, false),
Entry("no $search present at all",
"", "", true, true),
Entry("caller lacks external-share permission",
`"student@school4.example.test"`, "", false, false),
)
It("resolves a legitimate cross-instance share when no $filter is present", func() {
student := &libregraph.User{}
student.SetId("precise-student")
identityBackend.On("GetPreciseUser", mock.Anything, "student", "school2", mock.Anything).
Return(student, nil)
r := httptest.NewRequest(http.MethodGet,
"/graph/v1.0/users?$search="+url.QueryEscape(`"student@school2.example.test"`), nil)
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())
Expect(res.Value).To(HaveLen(1))
Expect(res.Value[0].GetId()).To(Equal("precise-student"))
identityBackend.AssertNotCalled(GinkgoT(), "GetUsers", mock.Anything, mock.Anything)
})
It("still runs the filter end-to-end — keeping the eligible user and dropping the ineligible one — when the search string also matches the cross-instance pattern", func() {
eligible := &libregraph.User{}
eligible.SetId(eligibleUser)
ineligible := &libregraph.User{}
ineligible.SetId(otherUser)
identityBackend.On("GetUsers", mock.Anything, mock.Anything).
Return([]*libregraph.User{eligible, ineligible}, nil)
expectRoles()
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?$search="+url.QueryEscape(`"student@school3.example.test"`)+
"&$filter="+url.QueryEscape("vaultEligible eq true"), nil)
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())
ids := make([]string, 0, len(res.Value))
for _, u := range res.Value {
ids = append(ids, u.GetId())
}
Expect(ids).To(ConsistOf(eligibleUser))
identityBackend.AssertNotCalled(GinkgoT(), "GetPreciseUser", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
})
})
DescribeTable("GetUsers handles unsupported or invalid filters",
func(filter string, status int) {
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settings.GetPermissionByIDResponse{
@@ -701,52 +860,7 @@ var _ = Describe("Users", func() {
)
Describe("the vaultEligible filter", func() {
// vaultRole is a role bundle that grants vault mode, vaultLessRole is one that does not.
const (
vaultRole = "vault-granting-role-ID"
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
// carries the vault mode permission.
expectRoles := func() {
roleService.On("ListRoles", mock.Anything, mock.Anything, mock.Anything).Return(&settings.ListBundlesResponse{
Bundles: []*settingsmsg.Bundle{
{
Id: vaultRole,
Type: settingsmsg.Bundle_TYPE_ROLE,
Settings: []*settingsmsg.Setting{
{
Name: permission.VaultMode,
Value: &settingsmsg.Setting_PermissionValue{PermissionValue: &settingsmsg.Permission{}},
},
},
},
{
Id: vaultLessRole,
Type: settingsmsg.Bundle_TYPE_ROLE,
Settings: []*settingsmsg.Setting{
{
Name: "Some.OtherPermission",
Value: &settingsmsg.Setting_PermissionValue{PermissionValue: &settingsmsg.Permission{}},
},
},
},
},
}, 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)
}
const thirdUser = "3a6e6e0e-3f8b-4e3e-9f8b-1a2b3c4d5e6f"
// requestVaultEligibleUsers builds a GetUsers request for filter, executes it against
// svc, and unmarshals a successful response body into a userList. It fails the test
@@ -1720,6 +1834,44 @@ var _ = Describe("Users", func() {
Expect(res.Value[0].GetId()).To(Equal("federated"))
Expect(res.Value[0].GetUserType()).To(Equal("Federated"))
})
It("runs the Federated filter, not GetPreciseUser, when the search string also matches the cross-instance pattern", func() {
cfg.MultiInstance.Enabled = true
cfg.MultiInstance.QueryRegexp = `^([^@]+)@([^.]+)\.example\.test$`
svc, _ = service.NewService(
service.Config(cfg),
service.WithGatewaySelector(gatewaySelector),
service.EventsPublisher(&eventsPublisher),
service.WithIdentityBackend(identityBackend),
service.WithRoleService(roleService),
service.WithValueService(valueService),
service.PermissionService(permissionService),
)
gatewayClient.On("FindAcceptedUsers", mock.Anything, mock.Anything).Return(&invitepb.FindAcceptedUsersResponse{
Status: status.NewOK(ctx),
AcceptedUsers: []*userv1beta1.User{},
}, nil)
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settings.GetPermissionByIDResponse{
Permission: &settingsmsg.Permission{
Operation: settingsmsg.Permission_OPERATION_UNKNOWN,
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
},
}, nil)
r := httptest.NewRequest(http.MethodGet,
"/graph/v1.0/users?$search="+url.QueryEscape(`"student@school2.example.test"`)+
"&$filter="+url.QueryEscape("userType eq 'Federated'"), nil)
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())
Expect(res.Value).To(BeEmpty())
identityBackend.AssertNotCalled(GinkgoT(), "GetPreciseUser", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
})
It("does not list federated users when filtering for 'Member' users", func() {
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settings.GetPermissionByIDResponse{}, nil)
+1 -1
View File
@@ -79,7 +79,7 @@ type LDAPDriver struct {
UserObjectClass string `yaml:"user_object_class" env:"OCIS_LDAP_USER_OBJECTCLASS;GROUPS_LDAP_USER_OBJECTCLASS" desc:"The object class to use for users in the default user search filter ('inetOrgPerson')." introductionVersion:"pre5.0"`
GroupObjectClass string `yaml:"group_object_class" env:"OCIS_LDAP_GROUP_OBJECTCLASS;GROUPS_LDAP_GROUP_OBJECTCLASS" desc:"The object class to use for groups in the default group search filter ('groupOfNames')." introductionVersion:"pre5.0"`
IDP string `yaml:"idp" env:"OCIS_URL;OCIS_OIDC_ISSUER;GROUPS_IDP_URL" desc:"The identity provider value to set in the group IDs of the CS3 group objects for groups returned by this group provider." introductionVersion:"pre5.0"`
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance." introductionVersion:"7.0"`
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance. Also set 'user_filter'. Without an explicit 'user_filter', this instance resolves every user in the shared LDAP directory." introductionVersion:"7.0"`
UserMemberAttribute string `yaml:"user_member_attribute" env:"OCIS_LDAP_USER_MEMBER_ATTRIBUTE" desc:"LDAP attribute that marks a user as a member of an instance." introductionVersion:"7.0"`
UserGuestAttribute string `yaml:"user_guest_attribute" env:"OCIS_LDAP_USER_GUEST_ATTRIBUTE" desc:"LDAP attribute that marks a user as a guest of an instance." introductionVersion:"7.0"`
UserSchema LDAPUserSchema `yaml:"user_schema"`
@@ -42,5 +42,9 @@ func Validate(cfg *config.Config) error {
return shared.MissingLDAPBindPassword(cfg.Service.Name)
}
if cfg.Driver == "ldap" && cfg.Drivers.LDAP.MasterID != "" && cfg.Drivers.LDAP.UserFilter == "" {
return shared.MissingLDAPUserFilterForMasterID(cfg.Service.Name)
}
return nil
}
@@ -0,0 +1,63 @@
package parser
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/owncloud/ocis/v2/services/groups/pkg/config"
)
func TestValidateMasterIDRequiresUserFilter(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "groups"},
TokenManager: &config.TokenManager{JWTSecret: "secret"},
Driver: "ldap",
Drivers: config.Drivers{
LDAP: config.LDAPDriver{
BindPassword: "secret",
MasterID: "master-1",
UserFilter: "",
},
},
}
err := Validate(cfg)
assert.Error(t, err)
}
func TestValidateMasterIDWithUserFilterPasses(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "groups"},
TokenManager: &config.TokenManager{JWTSecret: "secret"},
Driver: "ldap",
Drivers: config.Drivers{
LDAP: config.LDAPDriver{
BindPassword: "secret",
MasterID: "master-1",
UserFilter: "(ownCloudMemberOf=instance-1)",
},
},
}
err := Validate(cfg)
assert.NoError(t, err)
}
func TestValidateNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
cfg := &config.Config{
Service: config.Service{Name: "groups"},
TokenManager: &config.TokenManager{JWTSecret: "secret"},
Driver: "ldap",
Drivers: config.Drivers{
LDAP: config.LDAPDriver{
BindPassword: "secret",
MasterID: "",
UserFilter: "",
},
},
}
err := Validate(cfg)
assert.NoError(t, err)
}
+99
View File
@@ -0,0 +1,99 @@
package command
import (
"fmt"
"strings"
"gopkg.in/yaml.v3"
)
// configFilePerm is the permission mask used when rewriting ocis.yaml, matching
// the mask `ocis init` uses to create it.
const configFilePerm = 0o600
// serviceUserConfigKeys maps an IDM service user (the ou=sysusers entries plus
// the bootstrap password keys) to the ocis.yaml key paths that must hold the
// same secret so services can still bind to LDAP after a password reset.
//
// reva, libregraph and idp share OCIS_LDAP_BIND_PASSWORD across several
// services but bind as distinct DNs, so their bind_password lives under
// different service sections. The idm.service_user_passwords.* keys are what
// `ocis init` writes and what re-bootstrapping a fresh database would read.
var serviceUserConfigKeys = map[string][][]string{
"reva": {
{"auth_basic", "auth_providers", "ldap", "bind_password"},
{"users", "drivers", "ldap", "bind_password"},
{"groups", "drivers", "ldap", "bind_password"},
{"idm", "service_user_passwords", "reva_password"},
},
"libregraph": {
{"graph", "identity", "ldap", "bind_password"},
{"idm", "service_user_passwords", "idm_password"},
},
"idp": {
{"idp", "ldap", "bind_password"},
{"idm", "service_user_passwords", "idp_password"},
},
}
// syncServiceUserPasswordInConfig rewrites the bind_password / service user
// password keys associated with the given service user to newPassword,
// preserving the rest of the document (including comments and unrelated keys).
// It returns the updated document, the dotted paths that were actually changed,
// and any error. Paths that are not present in the document are skipped.
func syncServiceUserPasswordInConfig(data []byte, userName, newPassword string) ([]byte, []string, error) {
paths, ok := serviceUserConfigKeys[userName]
if !ok {
// Not a known service user with bind config to sync.
return data, nil, nil
}
var root yaml.Node
if err := yaml.Unmarshal(data, &root); err != nil {
return nil, nil, fmt.Errorf("failed to parse config: %w", err)
}
if len(root.Content) == 0 {
return data, nil, nil
}
doc := root.Content[0]
updated := make([]string, 0, len(paths))
for _, path := range paths {
if node := lookupYAMLNode(doc, path); node != nil {
node.SetString(newPassword)
updated = append(updated, strings.Join(path, "."))
}
}
if len(updated) == 0 {
return data, nil, nil
}
out, err := yaml.Marshal(&root)
if err != nil {
return nil, nil, fmt.Errorf("failed to serialize config: %w", err)
}
return out, updated, nil
}
// lookupYAMLNode walks a mapping node along path and returns the scalar value
// node at the end, or nil if any segment is missing.
func lookupYAMLNode(node *yaml.Node, path []string) *yaml.Node {
for _, key := range path {
if node.Kind != yaml.MappingNode {
return nil
}
var next *yaml.Node
for i := 0; i+1 < len(node.Content); i += 2 {
if node.Content[i].Value == key {
next = node.Content[i+1]
break
}
}
if next == nil {
return nil
}
node = next
}
return node
}
+138
View File
@@ -0,0 +1,138 @@
package command
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)
// sampleOcisConfig mirrors the relevant subset of an `ocis init` generated
// ocis.yaml, carrying the bind_password keys the reva/libregraph/idp service
// users are wired into.
const sampleOcisConfig = `token_manager:
jwt_secret: keepme
idm:
service_user_passwords:
admin_password: adminpw
idm_password: OLDIDM
reva_password: OLDREVA
idp_password: OLDIDP
idp:
ldap:
bind_password: OLDIDP
auth_basic:
auth_providers:
ldap:
bind_password: OLDREVA
users:
drivers:
ldap:
bind_password: OLDREVA
groups:
drivers:
ldap:
bind_password: OLDREVA
graph:
identity:
ldap:
bind_password: OLDIDM
`
func getYAMLPath(t *testing.T, data []byte, path ...string) string {
t.Helper()
var root yaml.Node
require.NoError(t, yaml.Unmarshal(data, &root))
node := root.Content[0]
for _, key := range path {
var next *yaml.Node
for i := 0; i+1 < len(node.Content); i += 2 {
if node.Content[i].Value == key {
next = node.Content[i+1]
break
}
}
require.NotNilf(t, next, "path %v: key %q not found", path, key)
node = next
}
return node.Value
}
func TestSyncServiceUserPasswordReva(t *testing.T) {
out, updated, err := syncServiceUserPasswordInConfig([]byte(sampleOcisConfig), "reva", "NEWPW")
require.NoError(t, err)
// reva binds via auth_basic, users and groups, and is bootstrapped via
// idm.service_user_passwords.reva_password — all must move to NEWPW.
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "auth_basic", "auth_providers", "ldap", "bind_password"))
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "users", "drivers", "ldap", "bind_password"))
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "groups", "drivers", "ldap", "bind_password"))
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "idm", "service_user_passwords", "reva_password"))
// Unrelated service users must stay untouched.
assert.Equal(t, "OLDIDM", getYAMLPath(t, out, "graph", "identity", "ldap", "bind_password"))
assert.Equal(t, "OLDIDP", getYAMLPath(t, out, "idp", "ldap", "bind_password"))
assert.Equal(t, "OLDIDM", getYAMLPath(t, out, "idm", "service_user_passwords", "idm_password"))
// Unrelated keys and comments-free structure must survive the round-trip.
assert.Equal(t, "keepme", getYAMLPath(t, out, "token_manager", "jwt_secret"))
assert.ElementsMatch(t, []string{
"auth_basic.auth_providers.ldap.bind_password",
"users.drivers.ldap.bind_password",
"groups.drivers.ldap.bind_password",
"idm.service_user_passwords.reva_password",
}, updated)
}
func TestSyncServiceUserPasswordLibregraph(t *testing.T) {
out, updated, err := syncServiceUserPasswordInConfig([]byte(sampleOcisConfig), "libregraph", "NEWPW")
require.NoError(t, err)
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "graph", "identity", "ldap", "bind_password"))
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "idm", "service_user_passwords", "idm_password"))
// reva keys stay put
assert.Equal(t, "OLDREVA", getYAMLPath(t, out, "users", "drivers", "ldap", "bind_password"))
assert.ElementsMatch(t, []string{
"graph.identity.ldap.bind_password",
"idm.service_user_passwords.idm_password",
}, updated)
}
func TestSyncServiceUserPasswordIdp(t *testing.T) {
out, updated, err := syncServiceUserPasswordInConfig([]byte(sampleOcisConfig), "idp", "NEWPW")
require.NoError(t, err)
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "idp", "ldap", "bind_password"))
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "idm", "service_user_passwords", "idp_password"))
assert.ElementsMatch(t, []string{
"idp.ldap.bind_password",
"idm.service_user_passwords.idp_password",
}, updated)
}
func TestSyncServiceUserPasswordUnknownUser(t *testing.T) {
// An arbitrary (non service) user has no bind config to sync; the config
// must be returned unchanged with no reported updates.
out, updated, err := syncServiceUserPasswordInConfig([]byte(sampleOcisConfig), "einstein", "NEWPW")
require.NoError(t, err)
assert.Empty(t, updated)
assert.Equal(t, strings.TrimSpace(sampleOcisConfig), strings.TrimSpace(string(out)))
}
func TestSyncServiceUserPasswordMissingKeys(t *testing.T) {
// A slim config that omits some bind_password keys: only the present ones
// are updated and reported, absent ones are silently skipped.
const slim = `idm:
service_user_passwords:
reva_password: OLDREVA
`
out, updated, err := syncServiceUserPasswordInConfig([]byte(slim), "reva", "NEWPW")
require.NoError(t, err)
assert.Equal(t, "NEWPW", getYAMLPath(t, out, "idm", "service_user_passwords", "reva_password"))
assert.ElementsMatch(t, []string{"idm.service_user_passwords.reva_password"}, updated)
}
+69 -4
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"path"
"syscall"
"time"
@@ -12,6 +13,7 @@ import (
"github.com/libregraph/idm/pkg/ldbbolt"
"github.com/libregraph/idm/server"
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
ocisdefaults "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/idm/pkg/config"
"github.com/owncloud/ocis/v2/services/idm/pkg/config/parser"
@@ -21,6 +23,12 @@ import (
"golang.org/x/term"
)
// User account types accepted by the --user-type flag.
const (
userTypeUser = "user"
userTypeService = "service"
)
// ResetPassword is the entrypoint for the resetpassword command
func ResetPassword(cfg *config.Config) *cli.Command {
return &cli.Command{
@@ -37,7 +45,7 @@ func ResetPassword(cfg *config.Config) *cli.Command {
&cli.StringFlag{
Name: "user-type",
Usage: "Type of user account: 'user' (ou=users) or 'service' (ou=sysusers)",
Value: "user",
Value: userTypeUser,
},
},
Before: func(_ *cli.Context) error {
@@ -50,8 +58,8 @@ func ResetPassword(cfg *config.Config) *cli.Command {
defer cancel()
userType := c.String("user-type")
if userType != "user" && userType != "service" {
return fmt.Errorf("invalid --user-type %q: must be 'user' or 'service'", userType)
if userType != userTypeUser && userType != userTypeService {
return fmt.Errorf("invalid --user-type %q: must be %q or %q", userType, userTypeUser, userTypeService)
}
return resetPassword(ctx, logger, cfg, c.String("user-name"), userType)
@@ -69,7 +77,7 @@ func resetPassword(_ context.Context, logger log.Logger, cfg *config.Config, use
}
ou := "users"
if userType == "service" {
if userType == userTypeService {
ou = "sysusers"
}
userDN := fmt.Sprintf("uid=%s,ou=%s,%s", userName, ou, servercfg.LDAPBaseDN)
@@ -105,9 +113,66 @@ func resetPassword(_ context.Context, logger log.Logger, cfg *config.Config, use
fmt.Fprintf(os.Stderr, "Failed to update user password: %v\n", err)
}
fmt.Printf("Password for user '%s' updated.\n", userDN)
if userType == userTypeService {
syncServiceUserBindConfig(userName, newPw)
}
return nil
}
// syncServiceUserBindConfig keeps ocis.yaml in sync after a service user's
// password was changed in the IDM database. Services bind to LDAP as the
// service users (e.g. uid=reva,ou=sysusers) using the bind_password from their
// config; if only the directory entry is changed those binds start failing on
// the next restart, which manifests as admin login returning 401. It rewrites
// the matching keys in ocis.yaml when present and always prints the env vars
// the operator must ensure carry the new value (covering env-var and
// distributed deployments this tool cannot rewrite).
func syncServiceUserBindConfig(userName, newPassword string) {
if _, known := serviceUserConfigKeys[userName]; !known {
return
}
configFile := path.Join(ocisdefaults.BaseConfigPath(), "ocis.yaml")
if data, err := os.ReadFile(configFile); err == nil {
out, updated, err := syncServiceUserPasswordInConfig(data, userName, newPassword)
switch {
case err != nil:
fmt.Fprintf(os.Stderr, "Warning: could not update bind passwords in %q: %v\n", configFile, err)
case len(updated) > 0:
if err := os.WriteFile(configFile, out, configFilePerm); err != nil {
fmt.Fprintf(os.Stderr, "Warning: could not write updated config %q: %v\n", configFile, err)
} else {
fmt.Printf("Updated bind passwords in %q:\n", configFile)
for _, key := range updated {
fmt.Printf(" - %s\n", key)
}
}
}
} else if !errors.Is(err, os.ErrNotExist) {
fmt.Fprintf(os.Stderr, "Warning: could not read config %q: %v\n", configFile, err)
}
fmt.Printf("\nIMPORTANT: the '%s' service user is used by oCIS services to bind to LDAP.\n", userName)
fmt.Printf("Make sure the following environment variable(s) are set to the new password\n")
fmt.Printf("wherever they are configured (env, secrets, per-service yaml), then restart oCIS:\n")
fmt.Printf(" - OCIS_LDAP_BIND_PASSWORD (shared) or the per-service variables below\n")
for _, env := range serviceUserBindEnvVars[userName] {
fmt.Printf(" - %s\n", env)
}
}
// serviceUserBindEnvVars lists the per-service bind_password environment
// variables that carry the given service user's password, for the operator
// guidance message. OCIS_LDAP_BIND_PASSWORD is a single shared variable used by
// all of these services, so it is noted separately by the caller rather than
// per user.
var serviceUserBindEnvVars = map[string][]string{
"reva": {"AUTH_BASIC_LDAP_BIND_PASSWORD", "USERS_LDAP_BIND_PASSWORD", "GROUPS_LDAP_BIND_PASSWORD", "IDM_REVASVC_PASSWORD"},
"libregraph": {"GRAPH_LDAP_BIND_PASSWORD", "IDM_SVC_PASSWORD"},
"idp": {"IDP_LDAP_BIND_PASSWORD", "IDM_IDPSVC_PASSWORD"},
}
func getPassword() (string, error) {
fmt.Print("Enter new password: ")
bytePassword, err := term.ReadPassword(syscall.Stdin)
+1 -1
View File
@@ -32,5 +32,5 @@ type Keycloak struct {
ClientRealm string `yaml:"client_realm" env:"OCIS_KEYCLOAK_CLIENT_REALM;INVITATIONS_KEYCLOAK_CLIENT_REALM" desc:"The realm the client is defined in." introductionVersion:"pre5.0"`
UserRealm string `yaml:"user_realm" env:"OCIS_KEYCLOAK_USER_REALM;INVITATIONS_KEYCLOAK_USER_REALM" desc:"The realm users are defined." introductionVersion:"pre5.0"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify" env:"OCIS_KEYCLOAK_INSECURE_SKIP_VERIFY;INVITATIONS_KEYCLOAK_INSECURE_SKIP_VERIFY" desc:"Disable TLS certificate validation for Keycloak connections. Do not set this in production environments." introductionVersion:"pre5.0"`
ExecuteActions []string `yaml:"execute_actions" env:"INVITATIONS_KEYCLOAK_EXECUTE_ACTIONS" desc:"A comma-separated list of Keycloak required actions sent to invited guests via the execute-actions email. Values are passed to Keycloak as-is. Defaults to 'UPDATE_PASSWORD,VERIFY_EMAIL'. See the Environment Variable Types description for more details." introductionVersion:"8.3.0"`
ExecuteActions []string `yaml:"execute_actions" env:"INVITATIONS_KEYCLOAK_EXECUTE_ACTIONS" desc:"A comma-separated list of Keycloak required actions sent to invited guests via the execute-actions email. Values are passed to Keycloak as-is. Defaults to 'UPDATE_PASSWORD,VERIFY_EMAIL'. See the Environment Variable Types description for more details." introductionVersion:"9.0.0"`
}
+3 -3
View File
@@ -79,7 +79,7 @@ type Store struct {
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;NOTIFICATIONS_STORE_TTL" desc:"Time to live for notifications in the store. Defaults to '336h' (2 weeks). See the Environment Variable Types description for more details." introductionVersion:"7.1.0"`
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;NOTIFICATIONS_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.1.0"`
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;NOTIFICATIONS_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.1.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;NOTIFICATIONS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;NOTIFICATIONS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;NOTIFICATIONS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;NOTIFICATIONS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;NOTIFICATIONS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;NOTIFICATIONS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
@@ -33,6 +33,7 @@ import (
"github.com/owncloud/ocis/v2/services/notifications/pkg/channels"
"github.com/owncloud/reva/v2/pkg/events"
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
"github.com/owncloud/reva/v2/pkg/storagespace"
"github.com/owncloud/reva/v2/pkg/utils"
cs3mocks "github.com/owncloud/reva/v2/tests/cs3mocks/mocks"
"github.com/stretchr/testify/mock"
@@ -80,6 +81,11 @@ var _ = Describe("Notifications", func() {
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(&user.GetUserResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, User: sharer}, nil).Once()
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(&user.GetUserResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, User: sharee}, nil).Once()
gatewayClient.On("Authenticate", mock.Anything, mock.Anything).Return(&gateway.AuthenticateResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, User: sharer}, nil)
// Registered before the catch-all below: testify/mock matches expectations in
// registration order, so the more specific vault matcher must come first.
gatewayClient.On("Stat", mock.Anything, mock.MatchedBy(func(r *provider.StatRequest) bool {
return r.GetRef().GetResourceId().GetStorageId() == utils.VaultStorageProviderID
})).Return(&provider.StatResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, Info: &provider.ResourceInfo{Name: "report.pdf", Space: &provider.StorageSpace{Name: "vault space"}}}, nil)
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(&provider.StatResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, Info: &provider.ResourceInfo{Name: "secrets of the board", Space: &provider.StorageSpace{Name: "secret space"}}}, nil)
vs = &settingssvc.MockValueService{}
vs.GetValueByUniqueIdentifiersFunc = func(ctx context.Context, req *settingssvc.GetValueByUniqueIdentifiersRequest, opts ...client.CallOption) (*settingssvc.GetValueResponse, error) {
@@ -270,6 +276,95 @@ https://owncloud.com
},
}),
)
vaultResourceID := &provider.ResourceId{
StorageId: utils.VaultStorageProviderID,
SpaceId: "spaceid",
OpaqueId: "itemid",
}
vaultSpaceID := &provider.StorageSpaceId{
OpaqueId: storagespace.FormatResourceID(&provider.ResourceId{
StorageId: utils.VaultStorageProviderID,
SpaceId: "vaultspaceid",
OpaqueId: "vaultspaceid",
}),
}
DescribeTable("Vault resources are redacted in notifications",
func(ev events.Event, mustNotContain string) {
received := make(chan *channels.Message, 1)
ch := make(chan events.Event)
evts := NewEventsNotifier(trace.NewNoopTracerProvider(), ch, capturingChannel{out: received}, log.NewLogger(), gatewaySelector, vs, "",
"", "", "", "", "", "",
store.Create(), nil, nil)
go evts.Run()
ch <- ev
var msg *channels.Message
select {
case msg = <-received:
case <-time.Tick(3 * time.Second):
Fail("timeout waiting for notification")
}
Expect(msg.Subject).NotTo(ContainSubstring(mustNotContain))
Expect(msg.TextBody).NotTo(ContainSubstring(mustNotContain))
},
Entry("Share Created", events.Event{
Event: events.ShareCreated{
Sharer: sharer.GetId(),
GranteeUserID: sharee.GetId(),
CTime: utils.TimeToTS(time.Date(2023, 4, 17, 16, 42, 0, 0, time.UTC)),
ItemID: vaultResourceID,
},
}, "report.pdf"),
Entry("Share Expired", events.Event{
Event: events.ShareExpired{
ShareOwner: sharer.GetId(),
GranteeUserID: sharee.GetId(),
ExpiredAt: time.Date(2023, 4, 17, 16, 42, 0, 0, time.UTC),
ItemID: vaultResourceID,
},
}, "report.pdf"),
Entry("Share Removed", events.Event{
Event: events.ShareRemoved{
Executant: sharer.GetId(),
GranteeUserID: sharee.GetId(),
ItemID: vaultResourceID,
},
}, "report.pdf"),
Entry("Added to Space", events.Event{
Event: events.SpaceShared{
Executant: sharer.GetId(),
Creator: sharer.GetId(),
GranteeUserID: sharee.GetId(),
ID: vaultSpaceID,
},
}, "vault space"),
Entry("Removed from Space", events.Event{
Event: events.SpaceUnshared{
Executant: sharer.GetId(),
GranteeUserID: sharee.GetId(),
ID: vaultSpaceID,
},
}, "vault space"),
Entry("Space Expired", events.Event{
Event: events.SpaceMembershipExpired{
SpaceOwner: sharer.GetId(),
GranteeUserID: sharee.GetId(),
SpaceID: vaultSpaceID,
SpaceName: "vault space",
ExpiredAt: time.Date(2023, 4, 17, 16, 42, 0, 0, time.UTC),
},
}, "vault space"),
)
})
var _ = Describe("Notifications X-Site Scripting", func() {
@@ -1278,6 +1373,17 @@ type testChannel struct {
done chan struct{}
}
// capturingChannel hands the sent message to the caller instead of asserting on it itself,
// for tests that need to inspect the message rather than match it exactly.
type capturingChannel struct {
out chan *channels.Message
}
func (c capturingChannel) SendMessage(_ context.Context, m *channels.Message) error {
c.out <- m
return nil
}
func (tc testChannel) SendMessage(_ context.Context, m *channels.Message) error {
defer GinkgoRecover()
+12 -3
View File
@@ -12,6 +12,15 @@ import (
"google.golang.org/protobuf/types/known/fieldmaskpb"
)
// vaultRedactedName replaces a file/space name with a generic placeholder when it belongs to
// the vault storage provider, so personal data never leaves the vault in a notification email.
func vaultRedactedName(storageID, name string) string {
if storageID == utils.VaultStorageProviderID {
return "a shared item"
}
return name
}
func (s eventsNotifier) handleShareCreated(baseCtx context.Context, e events.ShareCreated, eventId string) {
logger := s.logger.With().
Str("event", "ShareCreated").
@@ -69,7 +78,7 @@ func (s eventsNotifier) prepareShareCreated(baseCtx context.Context, logger zero
Msg("could not stat resource")
return owner, shareFolder, shareLink, ctx, err
}
shareFolder = resourceInfo.Name
shareFolder = vaultRedactedName(e.ItemID.GetStorageId(), resourceInfo.Name)
shareLink, err = urlJoinPath(s.ocisURL, "files/shares/with-me")
if err != nil {
@@ -157,7 +166,7 @@ func (s eventsNotifier) prepareShareExpired(baseCtx context.Context, logger zero
Msg("could not stat resource")
return shareFolder, ctx, err
}
shareFolder = resourceInfo.GetName()
shareFolder = vaultRedactedName(e.ItemID.GetStorageId(), resourceInfo.GetName())
return shareFolder, ctx, err
}
@@ -219,7 +228,7 @@ func (s eventsNotifier) prepareShareRemoved(baseCtx context.Context, logger zero
Msg("could not stat resource")
return executant, shareFolder, ctx, err
}
shareFolder = resourceInfo.Name
shareFolder = vaultRedactedName(e.ItemID.GetStorageId(), resourceInfo.Name)
executant, err = utils.GetUserWithContext(ctx, e.Executant, gatewayClient)
if err != nil {
+10 -3
View File
@@ -84,7 +84,7 @@ func (s eventsNotifier) prepareSpaceShared(baseCtx context.Context, logger zerol
Msg("could not get space info")
return executant, spaceName, shareLink, ctx, err
}
spaceName = resourceInfo.GetSpace().GetName()
spaceName = vaultRedactedName(resourceID.GetStorageId(), resourceInfo.GetSpace().GetName())
shareLink, err = urlJoinPath(s.ocisURL, "f", e.ID.OpaqueId)
if err != nil {
@@ -169,7 +169,7 @@ func (s eventsNotifier) prepareSpaceUnshared(baseCtx context.Context, logger zer
Msg("could not get space info")
return executant, spaceName, shareLink, ctx, err
}
spaceName = resourceInfo.GetSpace().GetName()
spaceName = vaultRedactedName(resourceID.GetStorageId(), resourceInfo.GetSpace().GetName())
shareLink, err = urlJoinPath(s.ocisURL, "f", e.ID.OpaqueId)
if err != nil {
@@ -220,10 +220,17 @@ func (s eventsNotifier) handleSpaceMembershipExpired(baseCtx context.Context, e
return
}
spaceName := e.SpaceName
if resourceID, err := storagespace.ParseID(e.SpaceID.GetOpaqueId()); err == nil {
spaceName = vaultRedactedName(resourceID.GetStorageId(), spaceName)
} else {
logger.Error().Err(err).Msg("could not parse resourceid from SpaceID, skipping vault redaction check")
}
emails, err := s.render(ctx, email.MembershipExpired,
"SpaceGrantee",
map[string]string{
"SpaceName": e.SpaceName,
"SpaceName": spaceName,
"ExpiredAt": e.ExpiredAt.Format("2006-01-02 15:04:05"),
}, recipientsInstant, owner.GetDisplayName())
if err != nil {
+1 -1
View File
@@ -39,7 +39,7 @@ type Config struct {
AllowPropfindDepthInfinity bool `yaml:"allow_propfind_depth_infinity" env:"OCDAV_ALLOW_PROPFIND_DEPTH_INFINITY" desc:"Allow the use of depth infinity in PROPFINDS. When enabled, a propfind will traverse through all subfolders. If many subfolders are expected, depth infinity can cause heavy server load and/or delayed response times." introductionVersion:"pre5.0"`
DisablePropfindPublicLinkResolution bool `yaml:"disable_propfind_public_link_resolution" env:"OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION" desc:"Disable the resolution of public link shares when answering PROPFIND requests. When disabled, the oc:share-type property will not be populated with public link share information, which can reduce load on services for large collections." introductionVersion:"8.3.0"`
DisablePropfindPublicLinkResolution bool `yaml:"disable_propfind_public_link_resolution" env:"OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION" desc:"Disable the resolution of public link shares when answering PROPFIND requests. When disabled, the oc:share-type property will not be populated with public link share information, which can reduce load on services for large collections." introductionVersion:"9.0.0"`
}
type Log struct {
+3 -3
View File
@@ -38,7 +38,7 @@ type SigningKeys struct {
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TTL" desc:"Default time to live for signing keys. See the Environment Variable Types description for more details." introductionVersion:"5.0"`
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
+3 -3
View File
@@ -64,7 +64,7 @@ type Store struct {
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;POSTPROCESSING_STORE_TTL" desc:"Time to live for events in the store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;POSTPROCESSING_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;POSTPROCESSING_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;POSTPROCESSING_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;POSTPROCESSING_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;POSTPROCESSING_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;POSTPROCESSING_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;POSTPROCESSING_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;POSTPROCESSING_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
+10 -5
View File
@@ -287,15 +287,19 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
if cfg.EnableBasicAuth {
logger.Warn().Msg("basic auth enabled, use only for testing or development")
authenticators = append(authenticators, middleware.BasicAuthenticator{
Logger: logger,
UserProvider: userProvider,
Logger: logger,
UserProvider: userProvider,
UserRoleAssigner: roleAssigner,
MultiInstanceEnabled: cfg.MultiInstance.Enabled,
})
}
if cfg.AuthMiddleware.AllowAppAuth {
authenticators = append(authenticators, middleware.AppAuthAuthenticator{
Logger: logger,
RevaGatewaySelector: gatewaySelector,
Logger: logger,
RevaGatewaySelector: gatewaySelector,
UserRoleAssigner: roleAssigner,
MultiInstanceEnabled: cfg.MultiInstance.Enabled,
})
}
@@ -353,7 +357,6 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
middleware.AllowAppAuth(cfg.AuthMiddleware.AllowAppAuth),
middleware.TraceProvider(traceProvider),
),
middleware.MultiFactor(cfg.MultiFactorAuthentication, middleware.Logger(logger), middleware.MFAStore(signingKeyStore)),
middleware.AccountResolver(
middleware.Logger(logger),
middleware.UserProvider(userProvider),
@@ -365,6 +368,8 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
middleware.EventsPublisher(publisher),
middleware.MultiInstance(cfg.MultiInstance.Enabled, cfg.MultiInstance.InstanceID, cfg.MultiInstance.MasterID, cfg.MultiInstance.MemberClaim, cfg.MultiInstance.GuestClaim, cfg.MultiInstance.GuestRole),
),
// needs the user resolved by the AccountResolver
middleware.MultiFactor(cfg.MultiFactorAuthentication, middleware.Logger(logger), middleware.MFAStore(signingKeyStore)),
middleware.SelectorCookie(
middleware.Logger(logger),
middleware.PolicySelectorConfig(*cfg.PolicySelector),
+7 -7
View File
@@ -141,15 +141,15 @@ type MFAConfig struct {
type Cache struct {
Store string `yaml:"store" env:"OCIS_CACHE_STORE;PROXY_OIDC_USERINFO_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0"`
Nodes []string `yaml:"addresses" env:"OCIS_CACHE_STORE_NODES;PROXY_OIDC_USERINFO_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0"`
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE;PROXY_OIDC_USERINFO_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"9.0" deprecationInfo:"The global variable OCIS_CACHE_DATABASE is deprecated and will be removed in a future release. Please use local variable PROXY_OIDC_USERINFO_CACHE_DATABASE instead."`
Table string `yaml:"table" env:"PROXY_OIDC_USERINFO_CACHE_TABLE" desc:"The database table the store should use." introductionVersion:"pre5.0"`
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;PROXY_OIDC_USERINFO_CACHE_TTL" desc:"Default time to live for user info in the user info cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;PROXY_OIDC_USERINFO_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"pre5.0"`
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;PROXY_OIDC_USERINFO_CACHE_AUTH_USERNAME" desc:"The username to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;PROXY_OIDC_USERINFO_CACHE_AUTH_PASSWORD" desc:"The password to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_OIDC_USERINFO_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_OIDC_USERINFO_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_OIDC_USERINFO_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_OIDC_USERINFO_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_OIDC_USERINFO_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_OIDC_USERINFO_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
// RoleAssignment contains the configuration for how to assign roles to users during login
@@ -205,9 +205,9 @@ type SigningKeys struct {
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_DISABLE_PERSISTENCE" desc:"Disables persistence of the store. Only applies when store type 'nats-js-kv' is configured. Defaults to true." introductionVersion:"5.0"`
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
}
// ClaimsSelectorConf is the config for the claims-selector
@@ -274,6 +274,14 @@ func DefaultPolicies() []config.Policy {
Endpoint: "/graph/",
Service: "com.owncloud.web.graph",
},
{
Endpoint: "/vault/graph/v1beta1/extensions/org.libregraph/activities",
Service: "com.owncloud.web.activitylog",
},
{
Endpoint: "/vault/graph/v1.0/invitations",
Service: "com.owncloud.web.invitations",
},
{
Endpoint: "/vault/graph/",
Service: "com.owncloud.web.graph",
@@ -105,6 +105,15 @@ func (m accountResolver) verifyUser(w http.ResponseWriter, req *http.Request, us
return
}
if errors.Is(err, backend.ErrAccountNotFound) {
// the identity backend excludes disabled accounts from by-claim
// lookups, so a disabled account also ends up here, not just a
// genuinely unknown username.
m.logger.Debug().Interface("user", user).Msg("Not found")
w.WriteHeader(http.StatusUnauthorized)
return
}
if err != nil {
m.logger.Error().Err(err).Msg("Could not get user by claim")
w.WriteHeader(http.StatusInternalServerError)
@@ -472,3 +472,35 @@ func TestResolveUserType(t *testing.T) {
})
}
}
// TestVerifyUserUnauthorizedOnUserNotFound covers the verifyUser fast path
// (user already in context, e.g. via AppAuthAuthenticator/BasicAuthenticator),
// as opposed to TestUnauthorizedOnUserNotFound which covers the claims-based
// resolveUserFromClaims path. A disabled account is looked up by username and
// comes back as ErrAccountNotFound (the identity backend excludes disabled
// accounts from by-claim lookups), which must map to 401, not 500.
func TestVerifyUserUnauthorizedOnUserNotFound(t *testing.T) {
user := &userv1beta1.User{
Id: &userv1beta1.UserId{Idp: "https://idx.example.com", OpaqueId: "123"},
Username: "alice",
}
ub := mocks.UserBackend{}
ub.On("GetUserByClaims", mock.Anything, "username", "alice").Return(nil, "", backend.ErrAccountNotFound)
ra := userRoleMocks.UserRoleAssigner{}
sut := AccountResolver(
Logger(log.NewLogger()),
UserProvider(&ub),
UserRoleAssigner(&ra),
)(mockHandler{})
req := httptest.NewRequest("GET", "http://example.com/foo", nil)
req = req.WithContext(revactx.ContextSetUser(context.Background(), user))
rw := httptest.NewRecorder()
sut.ServeHTTP(rw, req)
assert.Equal(t, http.StatusUnauthorized, rw.Code)
}
+26 -13
View File
@@ -6,15 +6,17 @@ import (
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
"github.com/owncloud/ocis/v2/services/proxy/pkg/userroles"
revactx "github.com/owncloud/reva/v2/pkg/ctx"
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
)
// AppAuthAuthenticator defines the app auth authenticator
type AppAuthAuthenticator struct {
Logger log.Logger
RevaGatewaySelector pool.Selectable[gateway.GatewayAPIClient]
Logger log.Logger
RevaGatewaySelector pool.Selectable[gateway.GatewayAPIClient]
UserRoleAssigner userroles.UserRoleAssigner
MultiInstanceEnabled bool
}
// Authenticate implements the authenticator interface to authenticate requests via app auth.
@@ -26,6 +28,15 @@ func (m AppAuthAuthenticator) Authenticate(r *http.Request) (*http.Request, erro
return nil, ErrAuthenticationFailed
}
if m.MultiInstanceEnabled {
// App passwords carry no OIDC claims, so there is no way to verify
// tenant membership (OCIS_MULTI_INSTANCE_MEMBER_CLAIM/GUEST_CLAIM)
// for them. Reject rather than let the request bypass the tenant
// check in services/proxy/pkg/middleware/account_resolver.go's
// resolveUserType.
return nil, ErrAuthenticationFailed
}
username, password, ok := r.BasicAuth()
if !ok {
return nil, ErrAuthenticationFailed
@@ -48,17 +59,19 @@ func (m AppAuthAuthenticator) Authenticate(r *http.Request) (*http.Request, erro
return nil, ErrAuthenticationFailed
}
r.Header.Set(revactx.TokenHeader, authenticateResponse.GetToken())
user := authenticateResponse.GetUser()
// fake oidc claims for the account resolver
claims := map[string]interface{}{
oidc.Iss: user.GetId().GetIdp(),
oidc.PreferredUsername: user.GetUsername(),
oidc.Email: user.GetMail(),
oidc.OwncloudUUID: user.GetId().GetOpaqueId(),
user, err := m.UserRoleAssigner.ApplyUserRole(r.Context(), authenticateResponse.GetUser())
if err != nil {
m.Logger.Error().Err(err).Msg("could not apply user role")
return nil, ErrAuthenticationFailed
}
r = r.WithContext(oidc.NewContext(r.Context(), claims))
// only mutate the request once we know we're returning success, so a
// failed authentication attempt can't leave a stale access token behind
// for a later authenticator in the chain to build on.
r.Header.Set(revactx.TokenHeader, authenticateResponse.GetToken())
// the user is already authenticated, put it into the context directly
// instead of faking oidc claims for the account resolver to re-resolve.
r = r.WithContext(revactx.ContextSetUser(r.Context(), user))
return r, nil
}
+91 -8
View File
@@ -1,27 +1,41 @@
package middleware
import (
"context"
"net/http"
"net/http/httptest"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
backendmocks "github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend/mocks"
"github.com/owncloud/ocis/v2/services/proxy/pkg/userroles/mocks"
"github.com/owncloud/reva/v2/pkg/auth/scope"
revactx "github.com/owncloud/reva/v2/pkg/ctx"
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
"github.com/owncloud/reva/v2/pkg/token/manager/jwt"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
)
var _ = Describe("Authenticating requests", Label("AppAuthAuthenticator"), func() {
var authenticator Authenticator
var roleAssigner *mocks.UserRoleAssigner
BeforeEach(func() {
pool.RemoveSelector("GatewaySelector" + "com.owncloud.api.gateway")
roleAssigner = &mocks.UserRoleAssigner{}
roleAssigner.EXPECT().ApplyUserRole(mock.Anything, mock.Anything).RunAndReturn(
func(ctx context.Context, user *userv1beta1.User) (*userv1beta1.User, error) { return user, nil },
).Maybe()
authenticator = AppAuthAuthenticator{
Logger: log.NewLogger(),
Logger: log.NewLogger(),
UserRoleAssigner: roleAssigner,
RevaGatewaySelector: pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
@@ -68,12 +82,81 @@ var _ = Describe("Authenticating requests", Label("AppAuthAuthenticator"), func(
Expect(req2).ToNot(BeNil())
Expect(req2.Header.Get("x-access-token")).To(Equal("reva-token"))
claims := oidc.FromContext(req2.Context())
Expect(claims).ToNot(BeNil())
Expect(claims[oidc.Iss]).To(Equal("testIDP"))
Expect(claims[oidc.PreferredUsername]).To(Equal("alice"))
Expect(claims[oidc.Email]).To(Equal("alice@example.prv"))
Expect(claims[oidc.OwncloudUUID]).To(Equal("abcd-1234"))
user, ok := revactx.ContextGetUser(req2.Context())
Expect(ok).To(Equal(true))
Expect(user.GetId().GetIdp()).To(Equal("testIDP"))
Expect(user.GetId().GetOpaqueId()).To(Equal("abcd-1234"))
Expect(user.GetUsername()).To(Equal("alice"))
Expect(user.GetMail()).To(Equal("alice@example.prv"))
})
})
When("multi-instance mode is enabled", func() {
It("rejects the request, since app passwords carry no tenant-membership claims", func() {
multiInstanceAuthenticator := AppAuthAuthenticator{
Logger: log.NewLogger(),
UserRoleAssigner: roleAssigner,
MultiInstanceEnabled: true,
RevaGatewaySelector: pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return mockGatewayClient{
AuthenticateFunc: func(authType, clientID, clientSecret string) *gateway.AuthenticateResponse {
return &gateway.AuthenticateResponse{Status: &rpcv1beta1.Status{Code: rpcv1beta1.Code_CODE_OK}}
},
}
},
),
}
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("test-user", "AppPassword")
req2, err := multiInstanceAuthenticator.Authenticate(req)
Expect(err).To(HaveOccurred())
Expect(req2).To(BeNil())
})
})
When("the account resolver is configured with a non-default PROXY_USER_OIDC_CLAIM", func() {
It("still resolves the already-authenticated user, bypassing claim-based lookup", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/graph/v1.0/me", http.NoBody)
req.SetBasicAuth("test-user", "AppPassword")
authenticatedReq, err := authenticator.Authenticate(req)
Expect(err).ToNot(HaveOccurred())
resolvedUser := &userv1beta1.User{
Id: &userv1beta1.UserId{Idp: "testIDP", OpaqueId: "abcd-1234"},
Username: "alice",
}
tokenManager, err := jwt.New(map[string]interface{}{"secret": "change-me", "expires": int64(60)})
Expect(err).ToNot(HaveOccurred())
s, err := scope.AddOwnerScope(nil)
Expect(err).ToNot(HaveOccurred())
token, err := tokenManager.MintToken(context.Background(), resolvedUser, s)
Expect(err).ToNot(HaveOccurred())
ub := backendmocks.UserBackend{}
// services/proxy/pkg/middleware/account_resolver.go's verifyUser always looks
// up the user by "username", regardless of the configured PROXY_USER_OIDC_CLAIM,
// because the user arrives already authenticated via the request context.
ub.On("GetUserByClaims", mock.Anything, "username", "alice", mock.Anything).Return(resolvedUser, token, nil)
resolver := AccountResolver(
Logger(log.NewLogger()),
UserProvider(&ub),
UserRoleAssigner(roleAssigner),
UserOIDCClaim("sub"),
UserCS3Claim("userid"),
)(mockHandler{})
rw := httptest.NewRecorder()
resolver.ServeHTTP(rw, authenticatedReq)
Expect(rw.Code).To(Equal(http.StatusOK))
})
})
@@ -20,6 +20,8 @@ import (
"github.com/owncloud/ocis/v2/services/proxy/pkg/router"
"github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend"
"github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend/mocks"
userRoleMocks "github.com/owncloud/ocis/v2/services/proxy/pkg/userroles/mocks"
revactx "github.com/owncloud/reva/v2/pkg/ctx"
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
"github.com/stretchr/testify/mock"
"go-micro.dev/v4/store"
@@ -81,10 +83,17 @@ var _ = Describe("Authenticating requests", Label("Authentication"), func() {
pool.RemoveSelector("GatewaySelector" + "com.owncloud.api.gateway")
logger := log.NewLogger()
roleAssigner := &userRoleMocks.UserRoleAssigner{}
roleAssigner.EXPECT().ApplyUserRole(mock.Anything, mock.Anything).RunAndReturn(
func(ctx context.Context, user *userv1beta1.User) (*userv1beta1.User, error) { return user, nil },
).Maybe()
authenticators = []Authenticator{
BasicAuthenticator{
Logger: logger,
UserProvider: &ub,
Logger: logger,
UserProvider: &ub,
UserRoleAssigner: roleAssigner,
},
&OIDCAuthenticator{
OIDCIss: "http://idp.example.com",
@@ -151,7 +160,7 @@ var _ = Describe("Authenticating requests", Label("Authentication"), func() {
testHandler.ServeHTTP(rr, req)
Expect(rr).To(HaveHTTPStatus(http.StatusOK))
})
It("ensures the context oidc data when user the Basic authentication is successful", func() {
It("ensures the authenticated user is in the context when the Basic authentication is successful", func() {
req := httptest.NewRequest("PROPFIND", "http://example.com/remote.php/dav/public-files/", http.NoBody)
req = req.WithContext(router.SetRoutingInfo(context.Background(), router.RoutingInfo{}))
req.SetBasicAuth("testuser", "testpassword")
@@ -160,12 +169,12 @@ var _ = Describe("Authenticating requests", Label("Authentication"), func() {
EnableBasicAuth(true),
)
testHandler := handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expect(oidc.FromContext(r.Context())).To(Equal(map[string]interface{}{
"email": "testuser@example.com",
"ownclouduuid": "OpaqueId",
"iss": "IdpId",
"preferred_username": "testuser",
}))
user, ok := revactx.ContextGetUser(r.Context())
Expect(ok).To(Equal(true))
Expect(user.GetId().GetIdp()).To(Equal("IdpId"))
Expect(user.GetId().GetOpaqueId()).To(Equal("OpaqueId"))
Expect(user.GetUsername()).To(Equal("testuser"))
Expect(user.GetMail()).To(Equal("testuser@example.com"))
}))
rr := httptest.NewRecorder()
testHandler.ServeHTTP(rr, req)
+26 -18
View File
@@ -4,16 +4,17 @@ import (
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
"github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend"
"github.com/owncloud/ocis/v2/services/proxy/pkg/userroles"
revactx "github.com/owncloud/reva/v2/pkg/ctx"
)
// BasicAuthenticator is the authenticator responsible for HTTP Basic authentication.
type BasicAuthenticator struct {
Logger log.Logger
UserProvider backend.UserBackend
UserCS3Claim string
UserOIDCClaim string
Logger log.Logger
UserProvider backend.UserBackend
UserRoleAssigner userroles.UserRoleAssigner
MultiInstanceEnabled bool
}
// Authenticate implements the authenticator interface to authenticate requests via basic auth.
@@ -25,6 +26,15 @@ func (m BasicAuthenticator) Authenticate(r *http.Request) (*http.Request, error)
return nil, ErrAuthenticationFailed
}
if m.MultiInstanceEnabled {
// Basic auth credentials carry no OIDC claims, so there is no way to
// verify tenant membership (OCIS_MULTI_INSTANCE_MEMBER_CLAIM/GUEST_CLAIM)
// for them. Reject rather than let the request bypass the tenant
// check in services/proxy/pkg/middleware/account_resolver.go's
// resolveUserType.
return nil, ErrAuthenticationFailed
}
login, password, ok := r.BasicAuth()
if !ok {
return nil, ErrAuthenticationFailed
@@ -40,23 +50,21 @@ func (m BasicAuthenticator) Authenticate(r *http.Request) (*http.Request, error)
return nil, ErrAuthenticationFailed
}
// fake oidc claims
claims := map[string]interface{}{
oidc.Iss: user.Id.Idp,
oidc.PreferredUsername: user.Username,
oidc.Email: user.Mail,
oidc.OwncloudUUID: user.Id.OpaqueId,
user, err = m.UserRoleAssigner.ApplyUserRole(r.Context(), user)
if err != nil {
m.Logger.Error().
Err(err).
Str("authenticator", "basic").
Str("path", r.URL.Path).
Msg("could not apply user role")
return nil, ErrAuthenticationFailed
}
if m.UserCS3Claim == "userid" {
// set the custom user claim only if users will be looked up by the userid on the CS3api
// OpaqueId contains the userid configured in STORAGE_LDAP_USER_SCHEMA_UID
claims[m.UserOIDCClaim] = user.Id.OpaqueId
}
m.Logger.Debug().
Str("authenticator", "basic").
Str("path", r.URL.Path).
Msg("successfully authenticated request")
return r.WithContext(oidc.NewContext(r.Context(), claims)), nil
// the user is already authenticated, put it into the context directly
// instead of faking oidc claims for the account resolver to re-resolve.
return r.WithContext(revactx.ContextSetUser(r.Context(), user)), nil
}
@@ -1,6 +1,7 @@
package middleware
import (
"context"
"net/http"
"net/http/httptest"
@@ -10,13 +11,17 @@ import (
. "github.com/onsi/gomega"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
"github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend"
"github.com/owncloud/ocis/v2/services/proxy/pkg/user/backend/mocks"
userRoleMocks "github.com/owncloud/ocis/v2/services/proxy/pkg/userroles/mocks"
"github.com/owncloud/reva/v2/pkg/auth/scope"
revactx "github.com/owncloud/reva/v2/pkg/ctx"
"github.com/owncloud/reva/v2/pkg/token/manager/jwt"
)
var _ = Describe("Authenticating requests", Label("BasicAuthenticator"), func() {
var authenticator Authenticator
var roleAssigner *userRoleMocks.UserRoleAssigner
ub := mocks.UserBackend{}
ub.On("Authenticate", mock.Anything, "testuser", "testpassword").Return(
&userv1beta1.User{
@@ -33,9 +38,15 @@ var _ = Describe("Authenticating requests", Label("BasicAuthenticator"), func()
ub.On("Authenticate", mock.Anything, mock.Anything, mock.Anything).Return(nil, "", backend.ErrAccountNotFound)
BeforeEach(func() {
roleAssigner = &userRoleMocks.UserRoleAssigner{}
roleAssigner.EXPECT().ApplyUserRole(mock.Anything, mock.Anything).RunAndReturn(
func(ctx context.Context, user *userv1beta1.User) (*userv1beta1.User, error) { return user, nil },
).Maybe()
authenticator = BasicAuthenticator{
Logger: log.NewLogger(),
UserProvider: &ub,
Logger: log.NewLogger(),
UserProvider: &ub,
UserRoleAssigner: roleAssigner,
}
})
@@ -49,19 +60,83 @@ var _ = Describe("Authenticating requests", Label("BasicAuthenticator"), func()
Expect(err).ToNot(HaveOccurred())
Expect(req2).ToNot(BeNil())
})
It("adds claims to the request context", func() {
It("puts the authenticated user into the request context", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("testuser", "testpassword")
req2, err := authenticator.Authenticate(req)
Expect(err).ToNot(HaveOccurred())
claims := oidc.FromContext(req2.Context())
Expect(claims).ToNot(BeNil())
Expect(claims[oidc.Iss]).To(Equal("IdpId"))
Expect(claims[oidc.PreferredUsername]).To(Equal("testuser"))
Expect(claims[oidc.Email]).To(Equal("testuser@example.com"))
Expect(claims[oidc.OwncloudUUID]).To(Equal("OpaqueId"))
user, ok := revactx.ContextGetUser(req2.Context())
Expect(ok).To(Equal(true))
Expect(user.GetId().GetIdp()).To(Equal("IdpId"))
Expect(user.GetId().GetOpaqueId()).To(Equal("OpaqueId"))
Expect(user.GetUsername()).To(Equal("testuser"))
Expect(user.GetMail()).To(Equal("testuser@example.com"))
})
})
When("multi-instance mode is enabled", func() {
It("rejects the request, since basic auth credentials carry no tenant-membership claims", func() {
multiInstanceAuthenticator := BasicAuthenticator{
Logger: log.NewLogger(),
UserProvider: &ub,
UserRoleAssigner: roleAssigner,
MultiInstanceEnabled: true,
}
req := httptest.NewRequest(http.MethodGet, "http://example.com/example/path", http.NoBody)
req.SetBasicAuth("testuser", "testpassword")
req2, err := multiInstanceAuthenticator.Authenticate(req)
Expect(err).To(HaveOccurred())
Expect(req2).To(BeNil())
})
})
When("the account resolver is configured with a non-default PROXY_USER_OIDC_CLAIM", func() {
It("still resolves the already-authenticated user, bypassing claim-based lookup", func() {
req := httptest.NewRequest(http.MethodGet, "http://example.com/graph/v1.0/me", http.NoBody)
req.SetBasicAuth("testuser", "testpassword")
authenticatedReq, err := authenticator.Authenticate(req)
Expect(err).ToNot(HaveOccurred())
resolvedUser := &userv1beta1.User{
Id: &userv1beta1.UserId{Idp: "IdpId", OpaqueId: "OpaqueId"},
Username: "testuser",
}
tokenManager, err := jwt.New(map[string]interface{}{"secret": "change-me", "expires": int64(60)})
Expect(err).ToNot(HaveOccurred())
s, err := scope.AddOwnerScope(nil)
Expect(err).ToNot(HaveOccurred())
token, err := tokenManager.MintToken(context.Background(), resolvedUser, s)
Expect(err).ToNot(HaveOccurred())
resolverBackend := mocks.UserBackend{}
// services/proxy/pkg/middleware/account_resolver.go's verifyUser always looks
// up the user by "username", regardless of the configured PROXY_USER_OIDC_CLAIM,
// because the user arrives already authenticated via the request context.
resolverBackend.On("GetUserByClaims", mock.Anything, "username", "testuser", mock.Anything).Return(resolvedUser, token, nil)
roleAssigner := &userRoleMocks.UserRoleAssigner{}
roleAssigner.EXPECT().ApplyUserRole(mock.Anything, mock.Anything).RunAndReturn(
func(ctx context.Context, user *userv1beta1.User) (*userv1beta1.User, error) { return user, nil },
).Maybe()
resolver := AccountResolver(
Logger(log.NewLogger()),
UserProvider(&resolverBackend),
UserRoleAssigner(roleAssigner),
UserOIDCClaim("sub"),
UserCS3Claim("userid"),
)(mockHandler{})
rw := httptest.NewRecorder()
resolver.ServeHTTP(rw, authenticatedReq)
Expect(rw.Code).To(Equal(http.StatusOK))
})
})
})
+5 -1
View File
@@ -58,7 +58,11 @@ func (m *createHome) ServeHTTP(w http.ResponseWriter, req *http.Request) {
createHomeReq := &provider.CreateHomeRequest{}
u, ok := revactx.ContextGetUser(ctx)
if !ok || u == nil {
m.logger.Error().Msg("no user in context")
// Requests on unprotected routes can carry a reva token without a resolved
// user, e.g. the internal download requests to the data gateway (/data), which
// reva's HTTP client sends with the caller's token. There is no home to create
// for them, so this is expected and not an error.
m.logger.Debug().Str("path", req.URL.Path).Msg("no user in context, not creating a home")
m.next.ServeHTTP(w, req)
return
}
@@ -0,0 +1,39 @@
package middleware
import (
"bytes"
"net/http"
"net/http/httptest"
"testing"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
)
// A request with a reva token but no user, like reva's internal download requests to
// the data gateway, is passed on unchanged and does not log an error.
func TestCreateHomeWithoutUserPassesThroughQuietly(t *testing.T) {
// Other tests in this package raise the global level; let error lines through.
defer zerolog.SetGlobalLevel(zerolog.GlobalLevel())
zerolog.SetGlobalLevel(zerolog.TraceLevel)
var buf bytes.Buffer
logger := log.Logger{Logger: zerolog.New(&buf).Level(zerolog.InfoLevel)}
nextCalled := false
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
nextCalled = true
w.WriteHeader(http.StatusOK)
})
sut := CreateHome(Logger(logger))(next)
req := httptest.NewRequest(http.MethodGet, "/data/some-transfer-token", nil)
req.Header.Set("x-access-token", "a-token")
rw := httptest.NewRecorder()
sut.ServeHTTP(rw, req)
assert.True(t, nextCalled)
assert.Equal(t, http.StatusOK, rw.Code)
assert.Empty(t, buf.String())
}
Loaded 100 of 410 files, more files were not shown because too many files have changed in this diff. Show more