Commit Graph
532 Commits
Author SHA1 Message Date
Jörn Friedrich Dreyer 4f2ab613a2 Merge pull request #3903 from opencloud-eu/feat/policies-request-length
feat(policies): pass request lengths to the proxy policies
2026-11-30 15:27:36 +01:00
Jörn Friedrich Dreyer a69677cecf feat(policies): leave unknown request lengths out of the policy input
content_length was 0 both for an empty body and for a body of unknown
length, e.g. a PUT with chunked transfer encoding. A policy could not
reject uploads that do not declare their size.

The lengths are now proto3 optional fields and the proxy sets
content_length whenever Go knows it, including 0 for an empty body.
An unknown length leaves the key out of the policy input. Rules that
compare a missing key do not apply, so existing limit rules keep
working, and a policy can reject an undeclared length explicitly with
`not "content_length" in object.keys(input.request)`.

We use field presence instead of -1, because a negative sentinel would
turn a request without lengths, e.g. in the postprocessing stage, into
an empty body.

related: https://github.com/opencloud-eu/opencloud/pull/3903#issuecomment-7273785513

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-11-30 12:31:02 +01:00
Dominik Schmidt 25f536563a feat(proxy): accept lists and globs for the CSP config file locations 2026-11-27 15:09:18 +01:00
micbar 0a36e91f0c fix: audit log follow-ups from the review
Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 17:26:25 +01:00
micbar 8d42270543 refactor(audit): build the audit emitter in one place 2026-11-26 16:52:55 +01:00
micbar 1edcc57d88 feat(proxy): audit logins, public link access and backchannel logouts
The proxy builds the audit request context: client address (PROXY_CLIENT_IP_HEADER behind trusted proxies), user agent, auth method, session and OIDC client. A value a client sent in X-Audit-Context is dropped.

A login is recorded once per OIDC session and client, not per access token. Public link access is recorded with the client address, failed attempts every time.
2026-11-26 16:52:55 +01:00
Pascal Bleser 153c046778 fix(proxy): redirect to HTTPS on the host of OC_URL
The proxy redirected requests forwarded as plain HTTP to https:// plus
the Host header of the request. The client controls that header, so the
redirect could send users to any other site (open redirect).

The redirect now uses the host of OC_URL, the URL where OpenCloud is
reachable for users, and keeps the path and query of the request as the
client escaped them. If OC_URL can't be parsed or has no host, requests
are passed on without a redirect, and the proxy logs why at startup.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 09:34:44 +01:00
Sara Ahmadi b9a39ea2d5 fix(proxy): add includeSubDomains to the Strict-Transport-Security header
Assisted-by: Claude Code:claude-opus-5-5
2026-11-24 16:55:55 +01:00
Sara Ahmadi 4e0b8f483b Merge pull request #4092 from asaah262/test/856-basic-challenge-app-auth
test(proxy): cover the authentication challenges for basic auth and app tokens
2026-11-24 11:46:12 +01:00
Sara Ahmadi 1aa9a5a80d test(proxy): build the test metrics from the default config
Assisted-by: Claude Code:claude-opus-5-5
2026-11-24 11:31:53 +01:00
Sara Ahmadi 82d6b0d1b1 fix(proxy): set Secure, HttpOnly and SameSite=Strict on the policy selector cookie
Assisted-by: Claude Code:claude-opus-5-5
2026-11-23 18:54:46 +01:00
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
Sara Ahmadi 814a2a763f test(proxy): cover the authentication challenges for basic auth and app tokens
Assisted-by: Claude Code:claude-opus-5-5
2026-11-23 14:53:40 +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
2435420f69 [full-ci] chore: bump reva to 2.52.2 (#3955)
* chore: bump reva to 2.52.2

* Merge pull request #42 from opencloud-eu/fix-web-theme-merge

fix(web): merge copies of the theme sources so themeDefaults is never mutated

* Merge pull request #43 from opencloud-eu/fix-search-trailing-not

fix(search): handle missing operands in the bleve compiler

* Merge pull request #44 from opencloud-eu/fix-search-highlight-escaping

fix(search): escape file content in OpenSearch highlights

---------

Co-authored-by: Ralf Haferkamp <r.haferkamp@opencloud.eu>
Co-authored-by: Florian Schade <f.schade@icloud.com>
2026-11-11 14:14:34 +01:00
Alex Ababii d7e5b97bdf Merge pull request #3857 from maki5/fix/expired_user_token_in_guest_session
Fix/expired user token in guest session
2026-11-11 11:18:06 +01:00
Dominik Schmidt 078a209c4e Merge pull request #3896 from opencloud-eu/fix/csp-media-src-blob
fix(proxy): allow blob: in media-src for motion and live photo playback
2026-11-11 10:43:56 +01:00
André Duffeck 487313d06c Remove redis-sentinel from store descriptions
Redis isn't supported anymore. Also note that the posix driver needs
nats-js-kv for the id cache.
2026-11-10 12:26:09 +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
Jörn Friedrich Dreyer bd4325b75b feat(policies): pass request lengths to the proxy policies
The proxy policies middleware now passes the Content-Length of the
request body and the TUS Upload-Length header to the policies engine
as input.request.content_length and input.request.upload_length. This
allows rejecting uploads that are too big before any data is
transferred, instead of only in postprocessing after the upload has
completed.

We add them to the request instead of setting resource.size, because
the resource describes the target of the request (the middleware may
even stat it) and in postprocessing resource.size is the actual file
size.

This can only be an early check. The TUS concatenation extension
allows merging several smaller uploads into one file, so the file size
still has to be checked in postprocessing.

protojson encodes uint64 values as strings with camelCase keys, so
NewEnvironmentFromPB copies the lengths explicitly.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-11-05 15:28:49 +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
Dominik Schmidt 44ef380168 fix(proxy): allow blob: in media-src for motion and live photo playback 2026-11-04 12:14:54 +01:00
micbar b7bb4fbe8c fix: client address for clients in a private network and behind the proxy 2026-11-02 10:25:18 +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
Viktor Scharf ae4970d92c chore: bump reva to 2.52.0 (#3820) 2026-10-27 12:46:43 +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
Andre Duffeck 51e2192476 Merge pull request #3729 from opencloud-eu/feat/guest-role-definitions
fix: allow guests to list role definitions
2026-10-15 16:05:34 +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
micbar 3662a94ca7 fix: nats checks were missing the configured auth 2026-10-14 17:45:44 +02:00
Anja Barz 25791bbd19 fix(proxy): make metrics table MDX-compatible (#3680) 2026-10-12 09:00:25 +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
André Duffeck 713b9c5095 Only enable guest_link auth when the feature is enabled 2026-10-06 09:52:02 +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
Alex Ababii a1a8221f68 feat(guestauth): global flag to disable the guest links feature 2026-10-06 08:08:26 +02:00
Alex Ababii cbf3ee8c0b feat(guestauth): guestauth service rename to auth-guest 2026-10-06 08:07:44 +02:00
Alex Ababii b920654815 feat(guetauth): upd the redeem route 2026-10-06 08:07:43 +02:00
Alex Ababii 402a0c04a1 feat(guestauth): register guestauth proxy 2026-10-06 08:07:43 +02:00
Viktor Scharf af425afb3b [full-ci] chore: bump reva to 2.51.0 (#3657)
* chore: bump reva to 2.51.0

* replaceversion placeholder
2026-10-05 17:08:52 +02:00