Commit Graph

40 Commits

Author SHA1 Message Date
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
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
Ralf Haferkamp
cb8934081f proxy(oidc): Emit a UserSignedIn event on new session
Every time the OIDC middleware sees a new access token (i.e when it needs
to update the userinfo cache) we consider that as a new login. In this case
the middleware add a new flag to the context, which is then used by the
accountresolver middleware to publish a UserSignedIn event.
The event needs to be sent by the accountresolver middleware, because only
at that point we know the user id of the user that just logged in.

(It would probably makes sense to merge the auth and account middleware into a
single component to avoid passing flags around via context)
2024-09-17 16:02:47 +02:00
Ralf Haferkamp
109b23966c bump some jwt related go modules to current version
go-jwt/jwt to v5.2.1
MicahParks/keyfunc to v2.1.0
2024-08-26 15:35:15 +02:00
Jörn Friedrich Dreyer
b2255bb3d5 Log user agent and remote addr on auth errors
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-07-16 12:41:04 +02:00
Roman Perekhod
c7281599d4 replacement for TokenInfo endpoint 2024-05-28 09:29:08 +02:00
Jörn Friedrich Dreyer
45d1936384 verify expiry of cached claims (#8310)
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-01-31 14:58:18 +01:00
Jörn Friedrich Dreyer
5422586bfa allow skipping userinfo call
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-08-23 13:56:48 +02:00
Ralf Haferkamp
70a80125c3 Fix backchannel logout
Use access token to lookup session id. The userinfo endpoint does
not return the session id. Also add some debug logging.

Co-authored-by: Christian Richter <crichter@owncloud.com>
Co-authored-by: Michael Barz <mbarz@owncloud.com>
2023-04-20 18:04:52 +02:00
Christian Richter
a6ced1f99f Simplifiy Unmarshall function for stringAsBool struct
Co-authored-by: Julian Koberg <jkoberg@owncloud.com>
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-20 11:45:13 +02:00
Christian Richter
30bcf32062 incorporate requested changes
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-20 09:00:58 +02:00
Christian Richter
e88a0d7bc3 add tests for oidc backchannel logout
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:49 +02:00
Jörn Friedrich Dreyer
dc399a61ac implement backchannel logout, reuse useringo cache
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Christian Richter
a900d0ed8d Refactor caches
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
bc15b8a396 work on logout
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
b608d0b0f9 move verify access token code to oidc client
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
58dce9bed8 use our oidc client
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Jörn Friedrich Dreyer
97894acccd add missing error check, redirect stub
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-04-19 17:32:25 +02:00
Christian Richter
a3640b0565 extract full claims from jwt token to get session id
Signed-off-by: Christian Richter <crichter@owncloud.com>
2023-04-19 17:32:23 +02:00
André Duffeck
d640719b7a Fix oidc auth cache 2023-04-03 14:00:11 +02:00
Jörn Friedrich Dreyer
6bec87f582 Proxy accesstoken cache store (#5829)
* refactor middleware options

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use ocmemstore micro store implementaiton for token cache

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* refactor ocis store options, support redis sentinel

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* align cache configuration

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* database and tabe are used to build prefixes for inmemory stores

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add global persistent store options to userlog config

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* log cache errors but continue

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* drup unnecessary type conversion

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* Better description for the default userinfo ttl

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use global cache options for even more caches

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* don't log userinfo cache misses

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* default to stock memory store

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use correct mem store typo string

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* split cache options, doc cleanup

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* mint and write userinfo to cache async

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use hashed token as key

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* go mod tidy

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update docs

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update cache store naming

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* bring back depreceted ocis-pkg/store package for backwards compatability

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* Apply suggestions from code review

Co-authored-by: kobergj <jkoberg@owncloud.com>

* revert ocis-pkg/cache to store rename

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add waiting for each step 50 milliseconds

* starlack check

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Co-authored-by: kobergj <jkoberg@owncloud.com>
Co-authored-by: Viktor Scharf <scharf.vi@gmail.com>
2023-03-22 15:21:57 +01:00
Ralf Haferkamp
a34a3b2a98 Cleanup some oidc related bits (#5751)
* Remove unused code from oidc module

* Use already existing Metadata type for jwks discovery

ocis-pkg/oidc already provides a type for the oidc metadata. Switch to
that instead of defining yet another custom type.

* oidc: Add helper to get IDP metadata
2023-03-07 14:43:42 +01:00
Jörn Friedrich Dreyer
53d15d329e remove deprecated use of ioutil (#5205)
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2022-12-08 14:44:53 +01:00
Willy Kloucek
2d16779652 fix the oidc provider cache 2022-09-16 12:34:12 +02:00
David Christofas
12d42e0074 add missing comments 2022-08-22 14:24:12 +02:00
David Christofas
78d85b683d add missing comments 2022-08-16 12:47:44 +02:00
David Christofas
06ffd9cf8a some more cleaning up 2022-08-12 10:48:21 +02:00
David Christofas
ddfc01bff9 refactor unprotected paths check 2022-08-12 10:47:51 +02:00
David Christofas
f35c8b9205 clean up the authenticators middlewares 2022-08-12 10:47:48 +02:00
David Christofas
e96819bce8 rewrite the auth middleware
The old approach of the authentication middlewares had the problem that when an authenticator could not authenticate a request it would still send it to the next handler, in case that the next one can authenticate it. But if no authenticator could successfully authenticate the request, it would still be handled, which leads to unauthorized access.
2022-08-12 10:47:43 +02:00
Ralf Haferkamp
6e848c7254 Use mutex for lazy init function
To avoid possible threading issues
2022-08-03 12:00:31 +02:00
Ralf Haferkamp
8229567213 Allow to configure the JWKS refresh settings
This exposes a couple for knobs for the jwks keyfunc module to adjust
timeout and refresh intervals.
2022-08-03 12:00:31 +02:00
Ralf Haferkamp
eb94530433 Add option to configure access token verification
Allow to switch jwt access token verification and off. Many (most?) IDP
provide JWT encoded access tokens. If ocis is configure to assume jwt
access tokens (access_token_verify_method==jwt) we now properly verify
the tokens signature and a set of standard claims ("exp", "iat" and nbf"
by way of the jwt module's standard verification and "iss" explicitliy).

This change also allows for introduction of other access token verification
mechanism in the future (e.g. through introspection (RFC7662).
2022-08-03 12:00:31 +02:00
Ralf Haferkamp
454cea8a1c Try to verify access_token as JWT and extract expiry
We try to parse the access token as a JWT now. Verifying the signature
using the keys downloaded from the jwks_uri of the IDP. Currently we
only use it to extract the expiry information from the JWT. This could
be reworked to extract other claims from the token for authorization
purposes.

Fixes: #3841
2022-08-03 12:00:31 +02:00
Ralf Haferkamp
0b055ca621 Remove obsolete comment
Token/Userinfo caching is already present since a while
2022-08-03 12:00:31 +02:00
Ralf Haferkamp
db634ae062 Remove non-working access_token parsing code
The removed code was broken is serveral ways:
- The key use for verification was always empty
- Using a static key for access_token verification is incompatible
  with key rotation
- The type assertion (which was never hit anyways) to convert
  the return MapClaims to StandardClaims can't really work
So in the end we were always using the default ttl for caching
the userinfo.
2022-07-07 16:18:10 +02:00
Ralf Haferkamp
bd4150ab01 Remove reduntant addtion of claims to context 2022-07-07 16:18:10 +02:00
Christian Richter
f8f1320501 refactor extensions -> services
Signed-off-by: Christian Richter <crichter@owncloud.com>
2022-06-27 14:05:36 +02:00
Christian Richter
78064e6bab rename folder extensions -> services
Signed-off-by: Christian Richter <crichter@owncloud.com>
2022-06-27 14:05:36 +02:00