Route OAuth callback through the vice-operator relay - #17
Merged
Conversation
Keycloak only treats * as a trailing wildcard in Valid Redirect URIs, so per-app VICE subdomains can never match https://*.cyverse.run:4343/*. Instead of sending its own subdomain as redirect_uri, vice-proxy now sends the operator's fixed callback URL and carries the original app URL in an HMAC-signed state blob (new go-mod/viceauth codec). The vice-operator relays the authorization code back to this app's subdomain, where the state cookie is still present and the code is exchanged as before. RequireKeycloakAuth encodes the signed state and uses OPERATOR_CALLBACK_URL as redirect_uri; HandleAuthorizationCode decodes and verifies the state, and the token-exchange redirect_uri now byte-matches the operator callback URL. The state-session cookie gains SameSite=Lax/Secure so it survives the extra cross-site redirect hop. OPERATOR_CALLBACK_URL and STATE_HMAC_SECRET are new required env vars when auth is enabled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
4 tasks
Collaborator
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
HandleAuthorizationCode now checks for a Keycloak ?error= response (e.g. the user denied consent) up front. Such responses carry no code or state, so without this the flow fell through to the state check and reported a confusing "no state found". Only the bounded RFC 6749 error code is echoed to the browser; the full description is logged. Also updates the frontendURL struct field comment — after the relay change it is no longer the OAuth redirect_uri (that is operatorCallbackURL), only the post-login browser redirect destination. Addresses code review feedback on PR #17. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
go-mod#11 merged and viceauth/v1.0.0 is tagged; move off the auth-relay pseudo-version to the released tag. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
redirect_uri— Keycloak only honors*as a trailing wildcard, sohttps://*.cyverse.run:4343/*can never match a real VICE subdomain (this is the "invalid parameter: redirect_uri" error seen in QA).redirect_uriand carries the original app URL inside an HMAC-signedstateblob (newgithub.com/cyverse-de/go-mod/viceauthcodec).Changes
RequireKeycloakAuth: encodes signed state (StateID+Origin); usesOPERATOR_CALLBACK_URLasredirect_uri.HandleAuthorizationCode: decodes/verifies state, comparesStateIDagainst the cookie; token-exchangeredirect_urinow byte-matches the operator callback URL.SameSite=Lax+Secure(gated on an HTTPS frontend) to survive the extra cross-site redirect hop.OPERATOR_CALLBACK_URL,STATE_HMAC_SECRET(delivered via the cluster-config Secret).Dependencies
viceauthmodule) — currently pinned to a pseudo-version of that branch; will be bumped toviceauth/v1.0.0once it merges.app-exposeradds the operator-side/auth/callbackrelay handler and the two new cluster-config keys.Test plan
go build ./...,go vet ./...,go test ./...,gofmt/auth/callbackURL in Keycloakstatewith off-domainOriginis rejected by the operator🤖 Generated with Claude Code