feat(auth): add periodic upstream OIDC revalidation with refresh-token support#164
Open
paulojmdias wants to merge 3 commits into
Open
feat(auth): add periodic upstream OIDC revalidation with refresh-token support#164paulojmdias wants to merge 3 commits into
paulojmdias wants to merge 3 commits into
Conversation
…n support Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
…on mode Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
|
doc-check has already been removed, so the failure can be ignored. |
Author
|
Thanks @hrntknr! Please let me know if I should increase the code coverage 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds periodic upstream IdP re-validation so the proxy honors IdP-side deprovisioning (suspension, group removal, password reset) without waiting for the downstream JWT to expire.
When enabled, every authenticated request whose cached upstream session is older than
--auth-revalidate-intervaltriggers a call to the OIDC provider's/userinfoendpoint (with transparent refresh-token rotation whenoffline_accessis granted). On a fatal IdP response, every downstream access token issued for the subject is revoked, and the user is forced to re-authenticate.Type of Change
Behavior
Mirrors
oauth2-proxy's fatal/non-fatal model by default:invalid_grant,invalid_client, HTTP 401/403 from/userinfo) → revoke all downstream tokens for the subject, return 401.invalid_request, timeouts) → allow the request through, retry on the next interval. Configurable via--auth-revalidate-on-failure=denyto revoke instead — useful when the upstream IdP returns non-fatal-coded errors for revoked sessions (e.g. dex emitsinvalid_requestfor revoked refresh tokens) or when operators prefer security over availability during IdP outages.--auth-revalidate-timeout(default10s) so an unresponsive IdP cannot hang proxy request latency. Exceeding it is treated as a non-fatal failure.Concurrent requests for the same subject are deduplicated via
singleflightso a single IdP round-trip serves all in-flight requests. The revalidation context is decoupled from any single caller viacontext.WithoutCancelso a client disconnect does not cancel the in-flight call shared by other waiters.Configuration
New flags (and matching env vars):
--auth-revalidate-intervalAUTH_REVALIDATE_INTERVAL60s0to disable.--auth-revalidate-timeoutAUTH_REVALIDATE_TIMEOUT10s/userinfo). Bounds the impact of an unresponsive IdP on request latency.--auth-revalidate-on-failureAUTH_REVALIDATE_ON_FAILUREallowallow(default, oauth2-proxy parity) logs a warning and proceeds; favors availability during IdP outages.denyrevokes the subject's tokens and rejects the request; favors security and is recommended when the IdP returns non-fatal-coded errors for revoked sessions.For graceful refresh-token rotation, request the
offline_accessscope:--oidc-scopes "openid,profile,email,offline_access"Without
offline_access, most IdPs (including Okta) will not issue a refresh token, and the user will be forced to re-authenticate when the upstream access token expires.Assisted-By: Claude Opus 4.7