OIDC ID token auto-refresh support #11771
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR follows up #11718 (which adds an option to extend the session in order to keep RT around for longer) and adds another option to auto-refresh ID tokens if the validated ID token will expire within the configured
token.auto-refresh-interval
.This should offer a more robust solution, as extending the session on its own only relies on the possibility of the OP session still being active for the RT grant to work.
I've added a test and also verified that without adding a new property in the new
tenant-autorefresh
configuration the test fails.In this PR an exception is thrown for the recovery code in
CodeAuthenticationMechanism
which does refresh the tokens and updates the session to take control. The exception is thrown only after the ID token has been verified and the SecurityIdentity calculated - the difference in this case is that if the RT grant fails we still continue because the current ID token is still valid (not expired).Also some precautions are taken to 1) avoid auto-refreshing on the initial authentication request and 2) avoid looping as the refreshed tokens also get verified.