Commit Graph

74 Commits

Author SHA1 Message Date
Trong Huu Nguyen
cbfa3fe2e2 refactor(session): extract inactive session error 2023-06-09 13:52:33 +02:00
Trong Huu Nguyen
3a239a95c3 feat(reverseproxy): validate acr and redirect if applicable 2023-04-29 11:54:53 +02:00
Trong Huu Nguyen
d76e9ebbb5 feat(session): store acr 2023-04-29 10:27:53 +02:00
Trong Huu Nguyen
08c6e96670 refactor(session): wrap error for decrypt 2023-02-23 14:29:49 +01:00
Trong Huu Nguyen
afc8fd6962 style: formatting 2023-02-21 15:37:48 +01:00
Trong Huu Nguyen
2796e1c9bc refactor(session): remove duplicate method, token expiry must be shorter than inactivity timeout 2023-02-21 15:34:50 +01:00
Trong Huu Nguyen
ec572db957 refactor(session): remove internal method from Reader interface 2023-02-21 15:12:45 +01:00
Trong Huu Nguyen
59a2e7b7a0 refactor(session): simplify AccessToken method, don't export methods that are only used within package 2023-02-21 14:40:27 +01:00
Trong Huu Nguyen
5b33313ccb feat(session): add GetOrRefresh method 2023-02-21 14:12:56 +01:00
Trong Huu Nguyen
820fb733e6 refactor(session): separate handler into manager and reader, use session struct to avoid polluting exported methods 2023-02-21 13:25:07 +01:00
Trong Huu Nguyen
49a90f3dbf refactor(session/ticket): rename method for clarity, add doc comments, clean up error handling 2023-02-21 12:28:21 +01:00
Trong Huu Nguyen
db391a9e44 refactor(session/store): consolidate session errors and use multi-error wrapping 2023-02-21 10:06:44 +01:00
Trong Huu Nguyen
17f39f8c5f feat(session/data): add more validation methods 2023-02-21 09:59:38 +01:00
Trong Huu Nguyen
94d4b1a524 refactor(session): extract external ID function to separate file 2023-02-20 12:40:23 +01:00
Trong Huu Nguyen
0537c8172f feat(session): use tickets for per-session data encryption
Replace the usage of a single application-wide session crypter
with per-session crypters.

The application is no longer able to decrypt any session
encrypted with its symmetric key alone. Instead, a session ticket
with its associated data encryption key (DEK) is also required in order
to decrypt the associated session data. The ticket itself is
encrypted with the application's crypter; the latter of which is
effectively a key-encryption key (KEK).

Fixes #49.
2023-02-14 21:50:19 +01:00
Trong Huu Nguyen
1b2234f875 refactor(session/data): skip unnecessary base64 (un)marshalling 2023-02-13 20:14:38 +01:00
Trong Huu Nguyen
c81297c401 build(deps): various bumps, use go-redis v9 2023-02-10 14:58:15 +01:00
Trong Huu Nguyen
bd748b9cef refactor(openid/provider): use name from config instead of indirection layer 2023-02-10 14:57:56 +01:00
Trong Huu Nguyen
61a7a8f161 refactor: clean up errors and reverseproxy logging 2023-02-10 14:57:53 +01:00
Trong Huu Nguyen
6a142cf5a5 refactor(handler): use session cookie for frontchannel logout if available, clean up logout handlers 2023-02-10 14:57:48 +01:00
Trong Huu Nguyen
2f6dc9c779 refactor(session/handler): reduce log severity for lock release, adjust lock duration and timeout 2022-12-02 13:47:59 +01:00
Trong Huu Nguyen
0b381bbb00 test(session/data): fix flaky expire test 2022-10-17 12:06:03 +02:00
Trong Huu Nguyen
82743f76bb test(session/data): fix flaky timeout test 2022-10-17 12:00:44 +02:00
Trong Huu Nguyen
aaaaaaa38d feat(session): add session inactivity timeout feature
Fixes #52.
2022-09-22 10:03:17 +02:00
Trong Huu Nguyen
55a5f357d5 chore: remove metadata rollout toggle 2022-09-21 09:41:28 +02:00
Trong Huu Nguyen
ed56aac3d0 style: follow conventions for error variable names 2022-09-19 08:41:23 +02:00
Trong Huu Nguyen
b8785b7414 style: use shorthand time functions where possible 2022-09-19 08:41:21 +02:00
Trong Huu Nguyen
d732a5b3cd test(session/store): add missing assertion 2022-09-19 08:41:18 +02:00
Trong Huu Nguyen
27d2bc2c26 fix(session/handler): log errors for lock release failures 2022-09-09 10:19:22 +02:00
Trong Huu Nguyen
b22c130e60 fix(session/handler): invalidate session state if refresh attempt is a client error
A client error response for the refresh grant is assumed to be an
irrecoverable error; e.g. the refresh token is invalid, the
authorization is invalid, user is logged out, etc. In such cases we will
consider the session state to be invalid, and a new authorization grant
should be performed.
2022-09-04 17:15:40 +02:00
Trong Huu Nguyen
c0138f4b49 feat(session): use locks for refreshing
One of the changes in OAuth 2.1 addresses attacks with refresh token
replays by recommending the use of one-time use tokens. A refresh token
is thus rotated and invalid after exactly one use, returning a new token
for each successful grant. Any further attempts must thus use the most
recently acquired refresh token. Reusing a refresh token may also
cause the authorization server to invalidate the current active refresh
token, requiring a refresh authorization grant to be reacquired for
further refresh token usage.

The use of locks prevents multiple refresh grant attempts for a given
session from happening across concurrent requests.
2022-09-04 17:14:35 +02:00
Trong Huu Nguyen
c78674e54a fix(session/store): check for existence before update 2022-09-03 16:48:37 +02:00
Trong Huu Nguyen
92ee6313c5 refactor: remove unnecessary interfaces 2022-09-02 17:39:27 +02:00
Trong Huu Nguyen
619ae52d45 refactor: separate refresh-specific fields from session info; enable endpoint without refresh feature 2022-09-01 19:35:48 +02:00
Trong Huu Nguyen
cdba90bc5b test(session/data): add missing tests 2022-08-29 14:48:39 +02:00
Trong Huu Nguyen
af48778bf7 fix(session/handler): lock metadata operations behind feature gate until rollout 2022-08-29 10:00:43 +02:00
Trong Huu Nguyen
cdd07838f4 refactor(session/data): separate into object groups 2022-08-29 08:35:03 +02:00
Trong Huu Nguyen
1d9339e139 refactor(session/handler): extract predicates for readability 2022-08-26 18:09:40 +02:00
Trong Huu Nguyen
5ec969981d fix(session/handler): ensure access token is not expired before proxying 2022-08-26 17:58:39 +02:00
Trong Huu Nguyen
d5bbca9897 feat: rudimentary support for refresh tokens 2022-08-26 14:32:39 +02:00
Trong Huu Nguyen
08f570363a refactor(openid): extract magic strings 2022-08-19 11:44:38 +02:00
Trong Huu Nguyen
5990e4bb71 refactor(session): extract session handler 2022-08-19 11:44:13 +02:00
Trong Huu Nguyen
c15e00469b refactor: clean up session error handling 2022-08-18 21:35:15 +02:00
Trong Huu Nguyen
ae8028cc96 refactor: remove cookie session fallback store
The implementation is error-prone and difficult to maintain.
We instead just assume that the backing session store is highly
available.
2022-08-17 20:44:07 +02:00
Trong Huu Nguyen
eac2d5789d refactor: passthrough for consistency in openid configuration 2022-07-20 09:58:49 +02:00
Trong Huu Nguyen
3e62683cad refactor: use pointer receivers when possible 2022-07-19 19:24:28 +02:00
Trong Huu Nguyen
cbb6be135a feat(metrics): add metrics for successful logins and logouts 2022-07-19 09:25:43 +02:00
Trong Huu Nguyen
b674a0ffa7 refactor(session): wrap own error type instead of using store-specific errors 2022-07-19 08:39:02 +02:00
Trong Huu Nguyen
284fa2a76f fix(openid/client): ensure assertion time claims are rounded down instead of up
Hopefully fixes intermittent 'invalid_grant' errors from IdP.
2022-07-18 09:24:26 +02:00
Trong Huu Nguyen
aab249d78a refactor(jwt): skip parsing access tokens
Access Tokens are not necessarily JWTs. We also don't
have to validate them as we only pass it on as an opaque
string.

This also means that we don't log the JTI access tokens
anymore.

We also simplify handling of oidc callbacks.
2022-07-14 12:14:25 +02:00