Skip to content

Support wildcard patterns in server.allowed-issuers and server.audiences - #1690

Merged
yili-db merged 7 commits into
unitycatalog:mainfrom
s-maling-celonis:feat/wildcard-issuer-audience
Jul 29, 2026
Merged

yili-db merged 7 commits into
unitycatalog:mainfrom
s-maling-celonis:feat/wildcard-issuer-audience

Conversation

@s-maling-celonis

@s-maling-celonis s-maling-celonis commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds wildcard matching for OAuth issuer and audience allowlists in multi-tenant deployments:

  • WildcardAllowlist — shared matcher for exact entries and single-DNS-label * wildcards
  • ServerProperties — volatile cached getIssuerAllowlist() / getAudienceAllowlist() getters that rebuild when the raw property value changes
  • AuthService — validates issuer (before JWKS fetch) and audience during token exchange via those allowlists
  • server.audiences=* alone disables audience validation for dynamic OAuth client UUID audiences

Example configuration:

server.allowed-issuers=https://*.dev.example.com
server.audiences=unity-catalog-local,https://*.dev.example.com

Test plan

  • sbt "server/testOnly io.unitycatalog.server.utils.WildcardAllowlistTest io.unitycatalog.server.utils.ServerPropertiesTest io.unitycatalog.server.service.AuthServiceWildcardIssuerTest io.unitycatalog.server.service.AuthServiceWildcardAudienceTest io.unitycatalog.server.service.AuthServiceWildcardAudiencePatternTest io.unitycatalog.server.service.AuthServiceAllowlistConfigurationTest io.unitycatalog.server.service.AuthServiceTest"
  • Exact and wildcard issuer/audience entries match expected tokens
  • Lone * audience entry disables audience validation
  • Missing server.allowed-issuers / server.audiences returns 400 with clear error message

@s-maling-celonis
s-maling-celonis force-pushed the feat/wildcard-issuer-audience branch 3 times, most recently from 9f6a777 to 269839b Compare July 22, 2026 09:08
@s-maling-celonis
s-maling-celonis requested a review from yili-db July 22, 2026 09:14
@s-maling-celonis
s-maling-celonis force-pushed the feat/wildcard-issuer-audience branch from 269839b to 10081ba Compare July 22, 2026 09:15
Comment thread etc/conf/server.properties Resolved
@s-maling-celonis
s-maling-celonis force-pushed the feat/wildcard-issuer-audience branch 2 times, most recently from f21628f to d11d9d7 Compare July 24, 2026 08:33
@s-maling-celonis
s-maling-celonis requested a review from yili-db July 24, 2026 08:35
try {
JWTVerifier jwtVerifier =
jwksOperations.verifierForIssuerAndKey(issuer, keyId, alg, audiences);
jwksOperations.verifierForIssuerAndKey(issuer, keyId, alg, List.of());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The audiences parameter of verifierForIssuerAndKey becomes dead code after this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 62da767 — removed the audiences parameter from JwksOperations.verifierForIssuerAndKey; audience validation stays in AuthService via WildcardAllowlist after signature verification.

validateAudienceConfiguration();
}

private void validateAudienceConfiguration() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to this function, server.allowed-issuers should be check that it doesn't contain any lone *, especially server.allowed-issuers=*. Because it doesn't do what users would usually expect: server.audiences accepts * to disable check but server.allowed-issuers doesn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 62da767 — validateAuthAllowlistConfiguration() now rejects server.allowed-issuers=* (and any comma-separated entry that is exactly *) at startup with a clear error message. Added ServerPropertiesTest.testRejectsLoneWildcardAllowedIssuers.

Comment thread docs/server/auth.md
server.allowed-issuers=https://*.dev.example.com
```

Wildcard audience patterns use the same `*` rules. For example, `https://*.dev.example.com`

@yili-db yili-db Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing worth calling out in the docs: with exact-match issuers the server only ever fetches JWKS from a fixed list of URLs. A wildcard like https://*.dev.example.com lets an unauthenticated caller pick which host we fetch from (the issuer check runs before signature verification), so it's effectively an SSRF surface.

Can you please add a note that wildcard issuers should only be used where necessary and only cover domains with no internal/sensitive hosts, and prefer https://? Not blocking, but people will copy these examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 62da767 — added a Wildcard issuer security subsection to docs/server/auth.md covering JWKS fetch before signature verification and SSRF-style considerations, plus brief pointers in etc/conf/server.properties and Helm values.yaml.

@s-maling-celonis
s-maling-celonis force-pushed the feat/wildcard-issuer-audience branch from 76d4efc to 81f903e Compare July 27, 2026 08:03
@s-maling-celonis
s-maling-celonis requested a review from yili-db July 27, 2026 08:06
@yili-db

yili-db commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

@tdas please take a look.

@tdas tdas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good but it would be good to fix the logging as i have commented before merging.

s-maling-celonis and others added 7 commits July 29, 2026 10:03
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]>
Replace IssuerAllowlist and AudienceAllowlist with WildcardAllowlist, which
parses the raw CSV property value and tracks source for cache invalidation.
ServerProperties exposes volatile cached getters that rebuild when config
changes; AuthService uses them during token exchange to restore wildcard
issuer validation and enforce audience allowlists. Add integration and
configuration tests, and update server.properties comments and docs.

Signed-off-by: s-maling-celonis <[email protected]>
Co-authored-by: Cursor <[email protected]>
Signed-off-by: s-maling-celonis <[email protected]>
Register allowed-issuers and audiences in ServerProperties.Property, make
WildcardAllowlist exact entries immutable, improve audience debug logging,
document DNS-label wildcard semantics in server.properties, and consolidate
AuthService allowlist integration tests into a single nested test class.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: s-maling-celonis <[email protected]>
Remove dead audiences parameter from JWKS verifier now that audience checks
run via WildcardAllowlist, reject lone '*' in server.allowed-issuers at startup,
and document wildcard issuer SSRF considerations in auth docs.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: s-maling-celonis <[email protected]>
Use Lombok getKey() in WildcardAllowlist and AuthServiceAllowlistTest;
Property.key is private to the nested enum.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: s-maling-celonis <[email protected]>
Malformed, issuer, signature, and audience failures on /tokens are now
visible when production log level is WARN or above.

Signed-off-by: s-maling-celonis <[email protected]>
Co-authored-by: Cursor <[email protected]>
@s-maling-celonis
s-maling-celonis force-pushed the feat/wildcard-issuer-audience branch from 81f903e to 0ee2563 Compare July 29, 2026 08:04
@s-maling-celonis

Copy link
Copy Markdown
Contributor Author

Thanks @tdas and @yili-db for the thorough review — all feedback is addressed now.

Logging (tdas): 0ee25635 promotes the four token-rejection logs in AuthService.grantToken() from debug to error (malformed token, invalid issuer, verification failed, audience not in allowlist).

Earlier review items (yili-db): issuer/audience wildcard matching, caching, config validation, docs, and test consolidation were addressed in prior commits on this branch.

Rebased onto latest upstream/main. Ready for another look when you have a moment.

@yili-db
yili-db merged commit 697c2fc into unitycatalog:main Jul 29, 2026
16 checks passed
yili-db pushed a commit that referenced this pull request Oct 27, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2019/files) to
review incremental changes.
-
[**stack/ep3-helm-ci**](#2019)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2019/files)]
← _this PR_
-
[stack/ep3-helm-release](#2020)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2020/files/9090e88439087610b7240d3dd89c8464e6ac83d9..573a422bfdfcc8aa1e144e1a8d28c19879ed5b14)]
-
[stack/ep3-helm-docs](#2021)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2021/files/573a422bfdfcc8aa1e144e1a8d28c19879ed5b14..936a12fac01b260d4d3fa97706943c076c8ac757)]

---------
**Description of changes**

The UI moved from yarn to bun in #1732, but the Helm chart still starts
it with `yarn start`. Yarn 1 refuses to run in a project whose
`package.json` declares `packageManager: bun@…`. So with any UI image
built from today's `ui/`, the UI pod crash-loops and `helm install
--wait` times out.

This PR:

- starts the UI with `bun run start` when the image has bun, and with
`yarn start` otherwise. The UI stays on by default, as on main;
- adds a `helm test` hook that checks the server API, the UI page and
the UI's `/api` proxy. Its image is set by `test.image` (with
`test.imagePullSecrets`), so a mirrored registry can run it;
- adds a **Helm Chart Tests** workflow for pull requests that touch
`helm/`, `ui/` or the `Dockerfile`. It checks that the chart README is
current (helm-docs), runs `ct lint`, installs the chart on kind with
server and UI images built from the PR, and runs `helm test`;
- regenerates the chart README, which was missing the values added in
#1689 and #1690, and fixes two yamllint errors in `values.yaml`. The
yamllint fixes are whitespace only, and the parsed values are identical.

UI images built from today's `ui/` now start with bun. The published
`unitycatalog-ui:main` image (May 2025) predates bun and has only yarn,
so it keeps starting with yarn, and a default install or `helm upgrade`
from main keeps its UI. bun is checked first, because a bun image also
has yarn (from `node:18`), but yarn refuses to run there. Once each
release publishes a bun-based UI image (#2020, #2021), the yarn branch
can go.

**Tests:** on a local kind cluster, the unchanged chart crash-loops the
UI as described above. With this PR, the install is ready in about 30
seconds and `helm test` passes. CI installs the chart with its default
values, with server and UI images built from the PR. This stack changes
no JVM code, and the full `build/sbt test` suite passes locally.

<details><summary><b>📐 Design notes &amp; details</b></summary>

**Repro of the bug** (kind with Kubernetes 1.32, server image `v0.7.0`,
UI image built from `main`):

```
error This project's package.json defines "packageManager": "yarn@[email protected]". However the current global version of Yarn is 1.22.22.
```

With `bun run start`, the following all returned 200 through a
port-forward: the UI page, the server API, a read through the UI's
`/api` proxy, and creating and deleting a catalog and a schema through
that proxy.

**Why this workflow builds Docker images.** #1420 disabled the image
*publishing* workflows to protect their Docker Hub secrets. This
workflow builds images only to load them into a throwaway kind cluster:

- it pushes nothing and uses no secrets;
- `permissions: contents: read` and `persist-credentials: false`;
- it runs on `pull_request`, not `pull_request_target`;
- actions are pinned to commit SHAs and the helm-docs image to a digest;
- zizmor reports no findings for it.

**What the test checks.**

- The UI dev server enables its host check whenever it proxies the API.
In that mode it accepts `localhost`, `*.localhost` and IP addresses, and
rejects other hostnames such as the Service name (see #753). The test
sends `Host: localhost`, as a browser on `kubectl port-forward` does.
Ingress and HTTPRoute mode turn the proxy off, and the test then skips
the proxy check.
- With `auth.enabled`, the test has no token, so it checks only the UI
page. With auth on and the UI off, there is nothing to check, and no
test pod is rendered.
- A failed check prints which check failed, and CI runs `helm test
--logs` so the output reaches the job log. The test pod is kept after it
passes and replaced on the next run, because `--logs` reads it after the
test finishes.
- The test checks that the UI is served, not that the UI compiles: the
dev server serves `index.html` even after a compile error.
- Ingress and HTTPRoute installs aren't exercised, because they need a
controller in kind.

**Local limits.** This machine can't build the server image from source
(old Docker and kernel), so locally I ran the same steps with the
released `v0.7.0` server image. The first from-source build in this
workflow is this PR's CI run.

Tools: Helm 3.20.0, chart-testing-action 2.9.0 (ct 3.15.0), kind-action
1.15.1, helm-docs 1.14.2.

**Measured results** (kind, chart from this PR, UI on, images built from
the PR):

| Request | Status |
|---|---|
| server `GET /api/2.1/unity-catalog/catalogs` | 200 |
| UI `GET /` with `Host: localhost:3000` | 200, UI page |
| UI `GET /` with `Host: uc.example.com` | 200, but the body is `Invalid
Host header` (the dev server's rejection page, see #753) |
| through the UI: `GET /api/2.1/unity-catalog/catalogs` | 200 |
| through the UI: `POST /catalogs {"name": "ep3"}` | 200 |
| through the UI: the same `POST` again | 400 (already exists) |
| through the UI: `GET /catalogs/missing` | 404 |
| through the UI: `DELETE /catalogs/ep3` | 200 |
| unchanged chart (`yarn start`) | UI pod in CrashLoopBackOff; `helm
install --wait` times out |

**Security review: building images in CI again.** #1420 turned off the
workflows that built and pushed images, because they held Docker Hub
secrets. This workflow builds images again, for testing only. I reviewed
it, and also ran GLM 5.3 and Claude Opus reviews; every point below was
checked against the files, the actions at their pinned commits, and a CI
run.

*If a container in this job is compromised:*

| Where the bad code runs | What it can do |
|---|---|
| inside `docker build` (a base image, or an npm, Maven, apk or apt
package) | change the image under test; it gets no token and no secret |
| inside a kind pod (a chart helper image) | the same, unless it escapes
the pod |
| on the runner (helm, uv, ct, kind, helm-docs, or an escape from the
privileged kind node) | control this job: a read-only `GITHUB_TOKEN`, no
secrets, no way to push images, charts or code; it can make the test
pass or fail wrongly |

The one way out of the job was the GitHub Actions cache. A job running
on `main` writes caches that other workflows on `main` restore,
including the sbt and bun caches and `ai-review.yml`, which holds
secrets. So the workflow runs **only on pull requests**: a pull
request's caches are scoped to that pull request, and `main` never reads
them. A tampered helm-docs image could edit chart files before the
install, so the check now fails on any change under `helm/`, not only
`README.md`.

*Docker Hub credentials:* this workflow can't reach them under any
trigger. GitHub gives a job only the secrets it names, and this workflow
names none; pull requests from forks get no secrets at all. Before
anyone turns the old image workflows back on: they log in to Docker Hub
and use the `type=gha` build cache in the same job, so a poisoned cache
could reach the published images.

*Pinned inputs:* actions by commit SHA (`actions/checkout` at v7.0.1);
helm-docs, the Dockerfiles' base images and syntax frontend, the `helm
test` image and the kind node image
(`kindest/node:v1.37.0@sha256:a1ed…`) by digest; kind v0.33.0, kubectl
v1.37.1, helm v3.20.0 and uv 0.13.1 by version; the UI's npm packages by
`bun.lock`. The chart's other helper images still use `latest` here;
#2020 pins them. Not pinned, and pre-existing: `apk add bash` and
`apt-get install jq` during the image builds and `apk add` in the config
init container (signed packages, but versions move), and sbt's Maven
downloads and launcher jar (no hash lock).

*Follow-ups (not in this stack):* zizmor checks for all workflows.
Separately, the existing cache exposure this workflow avoids stays as it
is: `unit-tests.yml`, `lint-check.yml` and `cross-spark-build.yml` write
caches on `main`, and `ai-review.yml` restores caches while holding
secrets. zizmor's cache-poisoning audit doesn't flag the `ai-review.yml`
case (0 findings when run on it).

</details>

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

---------

Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]>
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.

3 participants