Bind OAuth2 SSO sessions to tokens issued by Zoraxy - #1263
Open
Elandrya2711 wants to merge 2 commits into
Open
Conversation
Elandrya2711
force-pushed
the
oauth2-session-store
branch
from
August 14, 2026 18:18
7a78058 to
e01df5c
Compare
Owner
|
The oauth (similar to forward auth), is a community maintained feature that I dont have infrastructure to test. |
Collaborator
|
If the PRs are meant to be additive, could you arrange them in a stack? https://docs.github.com/en/pull-requests/how-tos/stacked-pull-requests |
Author
|
They are stacked in git already (oauth2-session-store = oauth2-httponly-cookies + one commit), GitHub just cannot show it since a fork PR cannot use a fork branch as base. Once #1262 is merged I rebase this one right after. |
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.
The OAuth2 authorization check takes the
z-tokencookie value as a bearer token and calls the provider's UserInfo endpoint with it. Any HTTP 200 response is accepted as authorized. Nothing ties that token to the OAuth2 client Zoraxy is configured with, so a token issued by the same identity provider for a different client passes the check as well.This matters as soon as the provider serves more than one application: a token that legitimately belongs to another client is accepted by Zoraxy. The raw token is also handed on to upstream applications together with the remaining cookies.
This change stores the token server side in a TTL cache and puts an opaque random session id in the cookie instead. Only tokens obtained through Zoraxy's own code exchange can be used, and the token no longer travels to upstream applications. The per-request UserInfo call is kept, so revoked tokens still end the session.
Behaviour changes worth considering before merging:
z-token.An alternative approach would be to validate the
audclaim of an ID token against the configured client id via JWKS. That keeps the check stateless, but it adds a JWT dependency and requires the provider to issue ID tokens. Happy to rework it that way if you prefer.Builds on #1262.