Commit Graph
31 Commits
Author SHA1 Message Date
zerox80 23197a969c test(proxy): cover the audit log together with the logout markers
The merge with main had to decide two things about the audit log that no test
described yet:

- A backchannel logout is audited even if the cached claims cannot be removed
  afterwards, because the marker has ended the session by then.
- A token that a logout marker rejects is audited as a failed login. Only a
  token that failed its time validation is left out, as before.

Assisted-by: Claude Code:Claude Mythos 5.2
2026-11-30 10:25:52 +00:00
zerox80 b945a94532 Merge branch 'main' into codex/oidc-session-logout
main brought the audit log and reva v3. Besides the textual conflicts, some
code of both sides no longer fits together and is adapted here:

- newOIDCAuthenticator and loadMiddlewares take the logout markers and the
  audit emitter.
- The backchannel logout handler still writes the marker first. The logout is
  audited once the user is resolved, whether or not the cached claims can be
  removed afterwards, because the marker has ended the session by then.
- userForClaimKey reads the cached TokenRecord instead of a plain claims map.
- isExpectedTokenTimeError stays, because the audit log uses it to leave out
  expired tokens. A token rejected by a logout marker is still audited as a
  failed login, isExpectedTokenError only keeps it out of the error log.
- The audit test of the handler gets logout markers, an iat in the logout
  token and the new format of the cached record.
- The middleware test of the command package passes no markers.
- The logout tests import the events of reva v3.

Assisted-by: Claude Code:Claude Mythos 5.2
2026-11-30 10:25:52 +00: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
André Duffeck 2b77cb9a17 Bump reva to v3.0.1 2026-11-17 12:45:18 +01:00
zerox80 7b183f2293 fix(proxy): reject tokens covered by a backchannel logout
Multiple access tokens can be valid for one session, for example after a
refresh. A logout only removed the cached claims of the token in the session
lookup, so older tokens stayed accepted. With PROXY_OIDC_SKIP_USER_INFO=true,
even the removed token was accepted again, because a still valid JWT was
verified anew.

Write a marker on every verified logout and check it on every authenticated
request, for cached and uncached tokens. This also covers tokens the proxy
has not seen before the logout.

If the marker store cannot be read, the cached claims are not used and the
userinfo endpoint decides about the token. With
PROXY_OIDC_SKIP_USER_INFO=true there is no such check, so the request is
rejected. A corrupt marker always rejects.

The cached record now keeps the verified subject, session and issue time,
because a userinfo response can overwrite them in the claims. The cache
database is renamed to start with a fresh cache.

Markers get their own database because nats-js-kv only supports one TTL per
bucket. They are kept for the new PROXY_OIDC_MAX_ACCESS_TOKEN_LIFETIME plus a
buffer. A JWT access token with a longer lifetime or without an expiration
can outlive its marker, so the proxy logs a warning for it.

Logout tokens without iat are now rejected, as the spec requires the claim.

Publishing the logout event and removing cached records are now best effort,
so a failed publish no longer prevents the logout.
2026-11-10 22:27:38 +01:00
zerox80 faabeaebdc feat(proxy): add backchannel logout markers
Add a store-backed record of verified backchannel logouts. A marker holds
the iat of the logout token as a cutoff, for a session or, if the logout
token has no sid, for a subject. A token is covered if it belongs to the
marked session or subject and was issued at or before the cutoff.

Tokens issued later stay valid. Keycloak keeps issuing tokens with the same
sid to a client with an offline token after a logout, and reuses the sid for
a new login after a consent revocation, so a plain session marker would lock
those clients out until it expires.

Using the iat of the logout token means both timestamps come from the IDP
clock, and replaying a logout token cannot change the cutoff.
2026-11-10 22:27:37 +01:00
Pascal Wengerter 002a2e43fb chore: regenerate mockery outputs 2026-09-16 14:57:41 +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
Florian Schade c7fd33c919 fix: send the backchannel logout event only if a session exists 2026-02-27 11:16:53 +01:00
Florian Schade b69b9cd569 fix: simplify subject.session key parsing 2026-02-25 14:02:09 +01: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 910298aa05 chore: change naming 2026-02-25 14:02:09 +01:00
Florian Schade 7350050a05 test: add more backchannellogout tests 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 0c62c45494 enhancement: document idp side-effects 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 762062bfa3 add mapping to backchannel logout for subject => sessionid
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
2026-02-25 14:02:09 +01:00
Christian RichterandMichael Barz 291265afb0 add additional validation to logout token
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
Co-authored-by: Michael Barz <m.barz@opencloud.eu>
2026-02-25 14:02:09 +01:00
André Duffeck cbac5f1555 Switch to a different msgpack lib
The current one has a problem handling time.Time{} structs
2025-05-16 10:24:43 +02:00
André Duffeck e8d35e1280 Use the opencloud reva from now on 2025-01-21 11:16:38 +01:00
Jörn Friedrich Dreyer b07b5a1149 use plain pkg module
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-13 16:42:19 +01:00
Jörn Friedrich Dreyer 8e028f17e9 change module name
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-13 09:58:18 +01:00
Roman Perekhod eac5eaea8f Add the backchannel logout event 2024-06-25 12:13:24 +02:00
Jörn Friedrich Dreyer f8f864e566 always initialize http handler
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-04-24 10:39:12 +02:00
Christian Richter 5cc286b8ef incorporate requested changes
Signed-off-by: Christian Richter <crichter@owncloud.com>
2024-03-19 08:38:54 +01:00
Christian Richter d31f5b9e15 remove obsolete comment
Signed-off-by: Christian Richter <crichter@owncloud.com>
2024-03-18 16:56:10 +01:00
Christian Richter 29549fade7 kill oidc well known middleware and move it to static route
Signed-off-by: Christian Richter <crichter@owncloud.com>
2024-03-18 16:56:10 +01:00
Christian Richter 1323a554bc move static routes to seperate package
Signed-off-by: Christian Richter <crichter@owncloud.com>
2024-03-18 16:56:10 +01:00