Repository navigation
Wildcard issuer/audience matching and subject-token principal resolution - #1661
s-maling-celonis wants to merge 6 commits into
Conversation
e094ac2 to
31dc6da
Compare
Mirror issuer-style wildcard matching for JWT aud claims during token exchange, including exact and single-label wildcard patterns. A lone * disables audience validation for dynamic OAuth client UUID audiences. Co-authored-by: Cursor <[email protected]> Signed-off-by: s-maling-celonis <[email protected]>
Allow issuer allowlist entries such as https://*.dev.example.com so UC can accept tokens from any tenant on a realm without listing each issuer explicitly. Reuse the same wildcard matcher for audience validation via AudienceAllowlist. Signed-off-by: s-maling-celonis <[email protected]> Co-authored-by: Cursor <[email protected]> Signed-off-by: s-maling-celonis <[email protected]>
Drop OAuth client credentials on POST /auth/tokens and map service principals via azp or non-URL aud to UC user externalId after email resolution fails. Co-authored-by: Cursor <[email protected]> Signed-off-by: s-maling-celonis <[email protected]>
Add a unique index on uc_users.external_id, prefer externalId over sub for access_token subjects without an email claim, and assert issued UC token sub in integration tests. Co-authored-by: Cursor <[email protected]> Signed-off-by: s-maling-celonis <[email protected]>
31dc6da to
3a75f32
Compare
UC access tokens previously had no exp claim. Add server.access-token-timeout (default PT24H), set JWT expiration in SecurityContext, and return expires_in from the token exchange response. Co-authored-by: Cursor <[email protected]> Signed-off-by: s-maling-celonis <[email protected]> Co-authored-by: Cursor <[email protected]>
51cd13e to
dec19d4
Compare
61568b1 to
e50e266
Compare
Defer beforeRequest authorization until processPeekData has buffered and successfully parsed the full JSON payload, so payload-derived resource keys such as catalog_name are available before SpEL evaluation. Check the accumulated payload buffer for completion instead of the current chunk. Co-authored-by: Cursor <[email protected]> Signed-off-by: s-maling-celonis <[email protected]> Co-authored-by: Cursor <[email protected]>
e50e266 to
520bd14
Compare
| peekDataHandler.processPeekData(data); | ||
| Map<SecurableType, UUID> resourceIds = mapResourceKeys(resourceKeys, nonResourceValues); | ||
| evaluateAction.beforeRequest(principal, expression, resourceIds, nonResourceValues); | ||
| if (peekDataHandler.processPeekData(data)) { |
There was a problem hiding this comment.
We are aware of this. But adding back this if alone will bring back the auth skipping vulnerability. processPeekData could always return false for a valid request.
I am revamping #1494 to fix it.
Can you revert these 3 lines for now please?
There was a problem hiding this comment.
Sure, i will be closing this PR anyway in favor of the 3 new independent changes. Wrt. this change, i think we can just manually apply the changes from the linked PR onto our fork.
|
This is valuable work, but the PR bundles several independent changes on the auth path. Since these are all security-sensitive, each needs to be reviewed carefully on its own — bundled together it's hard to reason about any one of them, and they get tied to the same merge. Can we split it into different PRs? Rough breakdown, in dependency order:
This lets the expiry and wildcard changes land quickly and keeps each PR focused. Thank you! |
|
Closing in favor of three focused PRs (per review feedback to split security-sensitive auth changes):
The chunked JSON authorization fix ( |
…#1689) ## Summary Split from #1661 (PR 1 of 3). UC access tokens previously had no `exp` claim. This adds: - `server.access-token-timeout` (default `PT24H`) - JWT expiration via `withExpiresAt` in `SecurityContext.createAccessToken` - `expires_in` in the `/auth/tokens` response so clients can cache and refresh correctly - Cookie max-age capped to `min(server.cookie-timeout, server.access-token-timeout)` when `ext=cookie` - Helm support via `auth.accessTokenTimeout` ## Behavior change Previously, UC access tokens issued by `/auth/tokens` had **no `exp` claim** and did not expire. This PR changes the default lifetime to **24 hours** (`server.access-token-timeout=PT24H`). **Impact:** - Clients must re-exchange tokens (or refresh using `expires_in`) at least once per day with default settings. - Deployments that relied on non-expiring tokens must set `server.access-token-timeout` explicitly (for example to a longer duration) if they need backward-compatible behavior during migration. **Scope:** Applies only to UC access tokens issued by `/auth/tokens` token exchange (`JwtTokenType.ACCESS`). The bootstrap admin token in `etc/conf/token.txt` (service token, `JwtTokenType.SERVICE`) is unchanged and still does not expire. ## Test plan - [x] `sbt "server/testOnly io.unitycatalog.server.service.AuthServiceTest, io.unitycatalog.server.utils.ServerPropertiesTest"` - [x] Token exchange returns `expires_in` matching configured timeout - [x] Issued UC access token JWT includes valid `exp` claim (`exp ≈ iat + TTL`) - [x] Expired access tokens are rejected with 401 - [x] Cookie max-age does not exceed access token lifetime --------- Signed-off-by: s-maling-celonis <[email protected]> Co-authored-by: Cursor <[email protected]>
Summary
Extends token exchange for multi-tenant OAuth deployments with four related changes:
Wildcard
server.allowed-issuers(supersedes #1657)IssuerAllowlistfor single-DNS-label wildcard issuer patterns (e.g.https://*.dev.example.com)AudienceAllowlistWildcard
server.audiencesaudafter signature verification (any token audience may match any configured entry)server.audiences=*alone to disable audience checks for dynamic OAuth client UUID audiencesSubject-token principal resolution (service principals)
UC resolves the principal from the subject token on
POST /auth/tokens— no OAuth client credentials on the UC request:id_token(CLI/browser):emailclaim orsub→getUserByEmail, thenexternalIdfallback viaazp/non-URLaudaccess_token(M2M): if noemailclaim,externalIdviaazp/non-URLaudfirst, thensub; otherwise same asid_tokenThe issued UC access token always uses the resolved user's email as
sub(for grants/authorization).Additional behavior:
azpor non-URLaudmatches a registered UC userexternalIdare accepted even when the client UUID is not inserver.audiencesuc_users.external_id(multipleNULLvalues still allowed)externalIdflow overserver.audiences=*for per-tenant service principalsUC access token expiry
server.access-token-timeout(defaultPT24H) for access tokens issued by token exchangeexpviawithExpiresAtinSecurityContext.createAccessTokenexpires_inin the/auth/tokensresponse so clients can cache and refresh correctlyChunked JSON payload authorization
UnityAccessDecoratorpreviously ranbeforeRequeston everypeekDatachunk, before the full JSON body was buffered and parsed. For chunkedPOSTrequests (e.g.POST /schemas), authorization could run on a partial payload and fail to resolve payload-derived resource keys such ascatalog_name, causing:This fix:
processPeekDatahas successfully parsed the complete JSON payloadExample multi-tenant configuration:
Bootstrap UC users with
emailfor grants andexternalId= OAuthclient_id.