Skip to content

fix(deploy): let UC_EXTERNAL_URL carry the path prefix the cookie fix depends on - #24

Merged
hujincalrin41 merged 3 commits into
mainfrom
feature/external-url-prefix
Oct 8, 2026
Merged

hujincalrin41 merged 3 commits into
mainfrom
feature/external-url-prefix

Conversation

@hujincalrin41

Copy link
Copy Markdown
Contributor

Closes #22

What

deploy-uc.sh rejected any UC_EXTERNAL_URL with a path and exited, while the state-cookie fix from #21 only takes effect when server.external-url has one. The two conditions were mutually exclusive: anyone deploying through this repo's own script could not reach the fix, and the sample file and both guides told them a path was a mistake.

A path is required when a gateway serves UC under a prefix and strips it before forwarding — the redirect_uri registered with the identity provider carries it, and the state cookie must be scoped to it.

Changes

Location Change
deploy/deploy-uc.sh Accept scheme://host[:port][/path]; keep rejecting a trailing slash, an empty segment, a query, a fragment and a missing scheme. Comment and error text restated
ServerProperties.java The property's comment no longer says (scheme + host [+ port]) and notes that the path also scopes the OAuth state cookie
deploy/uc.env.example The behind-a-prefix case with a worked example, next to the headers-stripped case
deploy/README.md, deploy/README.zh-CN.md A "Behind a path prefix" section with the example and the redirect URI to register; config table rows updated

The Secure flag reads only the scheme, so a path never affects it; a host-only value renders byte-identically to before.

Shape check, walked by hand

Value Result
https://uc.example.com accept
https://uc.example.com:8443 accept
https://api.example.com/unitycatalog accept (was rejected)
https://api.example.com/a/b accept (was rejected)
https://uc.example.com/ reject
https://api.example.com//uc reject
https://uc.example.com?x=1 reject
https://uc.example.com#f reject
uc.example.com reject

Verified end to end, locally

A prefix-stripping gateway in front of the server with UC_EXTERNAL_URL=https://…/unitycatalog, deployed through deploy-uc.sh (now accepted), signing in against a mock OIDC provider: the redirect_uri carries the prefix, the state cookie is scoped to /unitycatalog/api/1.0/unity-control/auth, the browser returns it, the callback sets the session cookie and clears the state on the same path, and the session is usable through the gateway. AuthServiceHostedLoginBehindPrefixTest was also mutated (both call sites back to the unprefixed path) to confirm both cases turn red.

One thing this does not change, and that the same run shows: after a successful callback the browser is sent to Location: /, the gateway root, rather than back under the prefix. The session is established regardless. Tracked separately from #22.

🤖 Generated with Claude Code

… depends on

deploy-uc.sh rejected any UC_EXTERNAL_URL with a path and exited, while the
state-cookie fix from #21 only takes effect when server.external-url has one.
The two conditions were mutually exclusive: anyone deploying through this
repo's own script could not reach the fix, and the sample file and both guides
told them a path was a mistake.

A path is required when a gateway serves UC under a prefix and strips it before
forwarding -- the redirect_uri registered with the identity provider carries it,
and the state cookie must be scoped to it. Accept scheme://host[:port][/path];
keep rejecting what can only be a slip: a trailing slash, an empty segment, a
query, a fragment, a missing scheme. The Secure flag reads only the scheme, so a
path never affects it, and a host-only value renders byte-identically to before.

Say so where operators read: the property's comment, the sample file, and a
'behind a path prefix' section in both deployment guides with the worked example
and the redirect URI to register.

Closes #22
@hujincalrin41
hujincalrin41 merged commit 8f3ecdb into main Oct 8, 2026
12 checks passed
@hujincalrin41
hujincalrin41 deleted the feature/external-url-prefix branch October 8, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy-uc.sh rejects the external-url path that the #21 cookie fix depends on

1 participant