Repository navigation
fix: prefix OAuth state cookie Path with the server.external-url path - #21
Merged
Merged
Conversation
Behind a reverse proxy that strips a path prefix, /auth/login set UC_OAUTH_STATE with Path=/api/1.0/unity-control/auth, the mount path the server sees. The browser returns to /callback under the prefix, so the cookie was never sent and the callback failed with "Missing login state". redirect_uri is already built from server.external-url. Set and clear the state cookie on the same path: external-url path + mount path. No change when external-url is unset or has no path; UC_TOKEN (Path=/) is unaffected. Closes #20.
hpkoh
force-pushed
the
fix/state-cookie-behind-path-prefix
branch
from
October 8, 2026 03:50
9945c3f to
6810070
Compare
hujincalrin41
approved these changes
Oct 8, 2026
This was referenced Oct 8, 2026
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.
Behind a reverse proxy that strips a path prefix, /auth/login set UC_OAUTH_STATE with Path=/api/1.0/unity-control/auth, the mount path the server sees. The browser returns to /callback under the prefix, so the cookie was never sent and the callback failed with "Missing login state".
redirect_uri is already built from server.external-url. Set and clear the state cookie on the same path: external-url path + mount path. No change when external-url is unset or has no path; UC_TOKEN (Path=/) is unaffected.
Closes #20.
What this does
redirect_uri<external-url>/api/1.0/unity-control/auth/callbackUC_OAUTH_STATEPath (set at/login, cleared at/callback)/api/1.0/unity-control/auth<external-url path>/api/1.0/unity-control/authUC_TOKENPath/With
server.external-url=https://api.example.com/unitycatalog, the state cookie is now scoped to/unitycatalog/api/1.0/unity-control/auth, the directory ofredirect_uri, so the browser sendsit to
/callback. The deletion uses the same path, since a cookie is only removed by aSet-Cookiethat names its path.No change when
external-urlis unset or has no path. That covers every setup that serves theserver at the root of its host, including the deploy scripts in this repo.
Tests
New
AuthServiceHostedLoginBehindPrefixTest(2 cases):external-urlwith a prefix and a trailingslash; checks
redirect_uri, the state cookie path, its deletion path at/callback, and thatUC_TOKENstays atPath=/. Verified in reverse: without the fix, both cases fail.AuthServiceHostedLoginTest(11 cases) still passes.