Commit Graph
196 Commits
Author SHA1 Message Date
Jörn Friedrich Dreyer 9f1fbc4480 fix(ocs): never hand out signing keys to link visitors
A public link token carries the link owner as user. If a link visitor
ever reaches GetSigningKey they get the owner's signing key and can sign
urls for everything the owner can read, until the key expires. Today the
proxy public paths and the reva link scope keep visitors away from the
endpoint, this adds the check in the handler itself.

We now refuse guests and users with a public-share-role in the opaque,
before reading or creating the key.

ported from https://github.com/owncloud/ocis/pull/12332
related: https://github.com/opencloud-eu/omega/issues/879

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-11-23 15:33:15 +01:00
André Duffeck 2b77cb9a17 Bump reva to v3.0.1 2026-11-17 12:45:18 +01:00
Roman Perekhod 0cc21c5039 fix: move the home space create cache to the proxy
The gateway kept a cache of the users whose personal space had already
been created, but the proxy still sent a CreateHome request to the
gateway on every authenticated request, so each of them had to reach
the gateway before that cache could help.

Keep the set of users whose personal space exists in the proxy instead
and skip the gateway call for them. The set lives in memory only: after
a restart the first request of each user simply asks the gateway once
more, so persistence is not needed. A created and an already existing
personal space are both remembered, a failed attempt is not and gets
retried by the next request.

With the cache in the proxy the gateway no longer needs its own, so
remove the create home cache settings (GATEWAY_CREATE_HOME_CACHE_*) and
the create_personal_space_cache_config entry of the generated gateway
configuration, and update the gateway README accordingly.
2026-11-17 08:36:59 +01:00
Alex Ababii ae2116d2bc fix(proxy): fix codacy report in test 2026-11-06 12:29:04 +01:00
Alex Ababii 0a4bf452cd fix(proxy): handle tus upload with guest session through guest links autheticator 2026-11-06 12:29:04 +01:00
Alex Ababii 6441bfabbf fix(proxy): handle guest link signed with jwt 2026-11-06 12:29:04 +01:00
Alex Ababii 007c09d499 fix(proxy): upd guest link authenticator middleware 2026-11-06 12:29:04 +01:00
Alex Ababii 654d02f86d fix(proxy); restrict non guest related credentials in guest link authenticator middelware 2026-11-06 12:29:02 +01:00
micbar f558acdfdb fix: keep the health checks out of the access log 2026-11-05 23:00:19 +01:00
Ryo Kusnadi 31722c878e fix(proxy): answer 403 instead of 500 when the role claim is missing
With PROXY_ROLE_ASSIGNMENT_DRIVER=oidc, a token whose claims give no
OpenCloud role made the account resolver answer 500. Mark these claim
errors with userroles.ErrRoleClaim and answer 403 for them. Failures of
the settings or gateway service still answer 500.

Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
2026-11-04 15:29:30 +01:00
micbar 4e7ebd4f8c fix: only trust forwarding headers from trusted reverse proxies
chi's ClientIPFrom* header middlewares trust the header from anyone who can
  reach us. Pick the middleware per request instead: headers are only read
  when the peer is a trusted proxy, everyone else gets their network address.

  - PROXY_TRUSTED_PROXIES, defaults to loopback and private ranges
  - PROXY_CLIENT_IP_HEADER, defaults to X-Forwarded-For, e.g. CF-Connecting-IP
  - drop the strategy setting and xff_trusted_hops
  - pass the client address to the services in X-Forwarded-For instead of
    X-Client-Ip, reva reads it e.g. for OCM
  - same check in collaboration, traefik routes to it directly
  - OC_TRUSTED_PROXIES and OC_CLIENT_IP_HEADER set both services
  - the other services only drop RealIP, none of them reads the address

  Taken from #3864 and https://github.com/opencloud-eu/opencloud/pull/3464#issuecomment-6494799883

# Conflicts:
#	services/proxy/README.md
2026-10-30 15:15:22 +01:00
Alex Ababii cf0f06e060 select correct chi middleware to get real IP based on config values 2026-10-30 15:13:55 +01:00
Alex Ababii 2230f93bfb upd test 2026-10-30 15:13:55 +01:00
Alex Ababii 850f1714a1 upd deprecated chi RealIP middelware 2026-10-30 15:13:54 +01:00
André Duffeck 855a7286d1 Make archiver work with guest link auth 2026-10-19 10:53:01 +02:00
Jannik Stehle 68cad133a4 fix: allow guest link auth for app open and new endpoints 2026-10-16 09:54:27 +02:00
Jannik Stehle a608418678 fix: allow guests to list role definitions
Shared drive items only reference role ids, so web needs the role
definitions to resolve the guest's share permissions.
2026-10-15 11:57:13 +02:00
André Duffeck 5c7f49de07 Also send SSEs to share recipients 2026-10-09 15:24:24 +02:00
André Duffeck 88e45f8961 Stream auth failure bodies through encoders 2026-10-06 10:22:41 +02:00
Ralf Haferkamp fbb6ac602c proxy: add guestlink auth middleware 2026-10-06 09:47:00 +02:00
Ralf Haferkamp 98cdbd077d refactor(proxy): return typed authentication results from authenticators
Replace the boolean authenticator result with a typed AuthenticationResult
containing AuthenticationState (NotApplicable, Failed, Succeeded, Error)
to distinguish between non-applicability, rejected credentials, and
dependency failures.

All existing authentication behavior remains observably unchanged.
2026-10-06 09:47:00 +02:00
Pascal Bleser d768a9b0f9 feat(proxy): add the service to the proxy metrics
Improve the metrics for the proxy service.

 * extend the instrumenter middleware to add a label with the name of
   the service the request is being dispatched to

 * add a native Prometheus histogram that tracks the durations and also
   includes a label for the name of the service the request is being
   dispatched to, as well as a 'result' label ('success',
   'client-error', 'server-error') based on the HTTP status code of the
   response

 * add per-service gauge functions to count the number of in-flight
   requests

 * add a counter for routing failures, for when an inbound request
   cannot be mapped to a route

 * extend the route.RoutingInfo struct with a service attribute, and a
   Service() getter

 * remove the 'routing_failure_count' metric, as it is redundant
2026-09-18 09:52:33 +02:00
zerox80 86d71dcdc3 feat(proxy): configure and enforce OIDC access token audiences 2026-09-16 10:15:56 +02:00
Ralf Haferkamp a256da502b fix(proxy): suppress auth challenges for failed signed URLs
Do not set WWW-Authenticate headers when an active signed URL
authentication attempt fails. Signed URL clients cannot respond to Basic
or Bearer challenges, and advertising them may trigger unintended
authentication prompts.

Keep returning 401 Unauthorized while preserving the existing challenge
behavior for unsigned requests and disabled signed URL mechanisms.
2026-09-11 11:51:01 +02:00
Alex Ababii 8875d062b0 upd tests for auth requests middelware 2026-09-08 09:37:51 +02:00
Alex Ababii d1d20edbd2 log jwt expired on debug level instead of error 2026-09-08 09:37:51 +02:00
Dominik Schmidt 7f7a938c3f fix(proxy): restrict JWT signed urls to the allowed HTTP methods
The legacy OC-Signature path already rejects methods outside
PRE_SIGNED_URL_ALLOWED_HTTP_METHODS, the JWT path did not. A leaked
signed download url could be used for PUT, DELETE, MOVE or PROPFIND
as the signing user for the lifetime of the signature.
2026-09-07 13:00:09 +02:00
Jörn Friedrich Dreyer 0776a479da send all /data throught middleware
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-08-21 07:34:46 +02:00
Jörn Friedrich Dreyer a93ec92789 rewrite more /data urls
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-08-21 07:34:46 +02:00
Jörn Friedrich Dreyer a74661618e refactor datagateway into proxy middleware
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-08-21 07:34:46 +02:00
Jörn Friedrich Dreyer 6f5f993ada Merge pull request #3288 from fschade/feat-modernize-opa
perf(policies): reuse the compiled rego query across evaluations
2026-08-12 17:58:13 +02:00
Florian Schade 1e7cfaf92d refactor(policies): read the rego policies once at startup 2026-08-12 17:01:49 +02:00
Florian Schade cd7f8f91b6 fix: oidc middleware claim race 2026-08-11 11:39:50 +02:00
Elias Schneider 4734c57f2b fix(proxy): honor access token cache ttl 2026-07-14 17:49:40 +02:00
André Duffeck 1ea634e6e3 Do not try to create personal spaces for lightweight or service users
This fixes error logs like

RR error when calling Createhome error="gateway: grpc failed with code CODE_INVALID_ARGUMENT" line=github.com/opencloud-eu/opencloud/services/proxy/pkg/middleware/create_home.go:87 service=proxy

e.g. during internal requests to the data provider.
2026-06-19 11:05:44 +02:00
Florian Schade 159785a3b5 enhancement: make collaboration font management functionality public 2026-06-11 09:28:37 +02:00
Florian Schade 457284885b fix: remove unnecessary error log it the oidc access token verify method is set to none 2026-05-20 15:11:03 +02:00
Florian Schade 288e67cc39 chore: replace interface with any 2026-04-23 09:31:11 +02:00
Ralf Haferkamp d9f39773e7 proxy: add memory cache for tenant id mapping
This is to reduce the number of "proxy->gateway->users->ldap" roundtrips
for the tenant id mapping.

The cache currently has a non-configurable ttl of 10 min.

Related: #2310
2026-04-09 17:46:50 +02:00
Ralf Haferkamp a931e53c26 proxy: Allow mapping from an external tenant id to the internal id
When the tenant id coming in via the OIDC claims doesn't match the
tenant id on the provisioned user, a mapping can be configured and
resolved via the reva TenantAPI service (now started as part of the
"users" service).

Closes: #2310
2026-04-09 17:46:50 +02:00
Ralf Haferkamp 33f45fa965 feat(multi-tenancy): verify tenant via OIDC claim
When multi-tenancy is enable we now allow to specify an OIDC claim
against which the tenantid of the user resolved via CS3 apis is matched.

Partial: #2310
2026-04-02 16:10:53 +02:00
Michael Barz f0836c54fb feat: add userid to spans (#2536) 2026-03-30 10:32:24 +02:00
Florian Schade e8ecbd7af1 refactor: make the logout mode private 2026-02-25 14:02:09 +01:00
Florian Schade fd614eacf1 fix: use base64 record keys to prevent separator clashes with subjects or sessionIds that contain a dot 2026-02-25 14:02:09 +01:00
Florian Schade f72e3f1e32 chore: cleanup backchannel logout pr for review 2026-02-25 14:02:09 +01:00
Florian Schade f6553498f6 enhancement: finalize backchannel logout 2026-02-25 14:02:09 +01:00
6a0fd89475 refactor deletion
Co-authored-by: Jörn Dreyer <j.dreyer@opencloud.eu>
Co-authored-by: Michael Barz <m.barz@opencloud.eu>
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
2026-02-25 14:02:09 +01:00
Christian Richter cb38aaab16 create mapping in cache for subject => sessionid
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
2026-02-25 14:02:09 +01:00
Ralf Haferkamp 6dde2839df fix(oidc_auth): Fix userinfo cache expiration logic
When the userinfo claims store in the usercache is found to be expired,
do not return an error but ignore the cached entry and force a
re-verification of the access token (either via parsing the JWT again or
via a UserInfo lookup).
This is required for setups with non-JWT access tokes where the expiry
date set in the cached claims does not reflect the actual token expiry,
but just the CacheTTL.

Fixes: #1493
2026-02-19 13:17:17 +01:00
Christian Richter 97ee9b36a5 incorporate requested changes
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
2025-11-19 09:38:16 +01:00