Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should OIDC middleware be refreshing a code id_token when close to expiry? #517

Open
nbevans opened this issue Dec 11, 2023 · 3 comments
Open

Comments

@nbevans
Copy link

nbevans commented Dec 11, 2023

Setting the UseTokenLifetime to false gives the cookie a really long lifetime and seemingly the exp is no longer honoured? So the token has expired (as they're only 60-90mins in duration) from AAD.

Setting UseTokenLifetime to true makes the cookie expire at the same time as the token - but if the user is still using the web app they get kicked out to the logon screen. Shouldn't it be auto-refreshing the token when its >50% into its lifetime?

It's all a bit confusing the way expiry works on this thing.

@Tratcher
Copy link
Member

The OIDC token is used to log into your app. However once you're logged in you are then working with the local cookie auth, not the token. When UseTokenLifetime is false the lifetime is configured using CookieAuthenticationOptions, adjust it as you see fit. This cookie will auto-renew locally while they're active, it won't check with OIDC server until a new login is needed (e.g. they signed out or went idle and expired).

When UseTokenLifetime is true then the cookie lifetime is fixed to the token lifetime, which tend to be short (1h), and there is no auto re-new. When it expires they will be sent back to the OIDC server for a fresh token. If they're still current on the OIDC server then that new token can be obtained automatically, otherwise they'll be prompted. The redirect happens regardless.

@nbevans
Copy link
Author

nbevans commented Dec 11, 2023

Okay so does this mean that the RefreshToken never gets used by this middleware?

@Tratcher
Copy link
Member

No it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants