OIDC Automatic token refresh #37632
-
Hi |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
/cc @pedroigor (oidc), @sberyozkin (oidc) |
Beta Was this translation helpful? Give feedback.
-
Hi @pmaciek When an already authenticated user accesses Quarkus, the expiry time of the ID token associated with the session cookie is checked, if the token has expired then if the refresh token is available and refreshing tokens is allowed, the tokens will be refreshed. To minimize the possibility of the browser dropping the session cookie when the cookie has expired, one can extend the session cookie lifespan with the configuration. Extending the cookie age does not extend the ID token age, only makes sure the tokens associated with the session cookie are made available to Quarkus, for it to check the ID token's expiry date, etc One can also use a proactive refreshment of the ID token which is still valid but has nearly expired by configuring a refresh skew - it requires a script using a background thread to ping the Quarkus endpoint every few mins or so. See https://quarkus.io/guides/security-oidc-code-flow-authentication#session-management for more info |
Beta Was this translation helpful? Give feedback.
-
Tokens are kept by default in the encrypted form in the session cookie, so a Quartz job approach does not really work. |
Beta Was this translation helpful? Give feedback.
-
@pmaciek Unfortunately everything what I said can be ignored because now that you have given the example, I see that you don't use OIDC client is totally independent from the server side OIDC adapter which is what I thought you were using. So OIDC client checks if the access token has expired and if yes it refreshes it. But what can happen is that it can propagate a nearly expired token and 401 will be returned as by the time it reaches the target, it will be expired possibly due to the clock issues. To minimise the risk of 401, you can also use the refresh skew, but in the HTH |
Beta Was this translation helpful? Give feedback.
@pmaciek Unfortunately everything what I said can be ignored because now that you have given the example, I see that you don't use
quarkus-oidc
but usequarkus-oidc-client
, I should've asked for more details earlier.OIDC client is totally independent from the server side OIDC adapter which is what I thought you were using.
So OIDC client checks if the access token has expired and if yes it refreshes it. But what can happen is that it can propagate a nearly expired token and 401 will be returned as by the time it reaches the target, it will be expired possibly due to the clock issues.
To minimise the risk of 401, you can also use the refresh skew, but in the
quarkus.oidc-client
namespace,…