Skip to content

[Server] Read the token signing key from an operator key file - #2081

Merged
yili-db merged 81 commits into
unitycatalog:mainfrom
shba24:stack/ep31-signing-key-dir
Nov 24, 2026
Merged

yili-db merged 81 commits into
unitycatalog:mainfrom
shba24:stack/ep31-signing-key-dir

Conversation

@shba24

@shba24 shba24 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • 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.
  • 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 is part 3 of 4 in a stack; each PR handles one kind of secret end to end (server, Helm chart, docs, tests). Review only this PR's changes with its incremental link above.

Description of changes

Operators can now give the server its token signing key as a file they choose, for example a read-only mount of a Kubernetes Secret. Before, the key had to be in etc/conf: the server generated it there on first start, and the Helm chart copied its key Secret into etc/conf (converting PEM to DER) to fit.

  • One setting: server.token-signing-private-key-file, an unencrypted RSA private key: PKCS Add issue templates #8 in PEM or DER, or PKCS Update the supported Engines section #1 in PEM (as the chart and some openssl genrsa versions write it). Other PEM blocks in the file, such as a certificate, are skipped. The server only reads the file and derives the public key from it once, at startup, so checking a token costs nothing extra. A missing file, an encrypted key or an unreadable key stops startup with a message naming the file.
  • Without it the key source does not change: the server uses the key in etc/conf and generates it on first start. That is now deprecated: with authorization enabled the server logs a warning at each start (without authorization no request checks the key, but it still signs token.txt at startup), and a newly generated private key is readable by its owner only (0600).
  • One key, no key ID. The server checks its own tokens directly with that key, with RS512 only, so it no longer writes etc/conf/certs.json, and it no longer uses a key ID: new tokens carry none, and checks ignore one. A token signed with another key is now rejected with 401 "Invalid access token", instead of a 500 that clients retried.
  • Helm: the init container points the setting at private_key.pem (or private_key.der) in the Secret mount; it no longer copies keys into etc/conf or needs openssl. A key file you set yourself (server.config.override or extraProperties) is kept. The Secret no longer needs key_id.txt, and the create-users job no longer sets one. Generating the key Secret (server.jwtKeypairSecret.create: true, the default) still works for this release, but is deprecated: values.yaml, the install notes and the new "Token signing key" section in the Helm guide say how to keep the current key or bring your own.
  • Docs: configuration (the setting and the deprecation), the auth upgrade and rollback notes, the Helm guide, and the sample server.properties.
openssl genrsa -out private_key.pem 2048
# server.properties
server.token-signing-private-key-file=/etc/uc/private_key.pem

Follow-ups: #2363 (derive the public key on the deprecated key-folder path), #2364 (a key file path that is a directory), #2365 (a key too small for RS512), #2366 (write the generated key atomically).

📐 Design notes & details

Why this shape. This follows Apache Polaris: the operator provides the key, and the server checks its own tokens against that one key with no key ID. Polaris's chart never generates keys, and its production-readiness check flags a generated key. Unlike Polaris, which takes both key files, UC takes only the private key: the public key is part of it, so a second setting would only add a way to configure a pair that doesn't match.

Why the key ID and certs.json could go.

  • The key ID decided nothing. The server published one key, so the key ID only ever picked that key. With the same key the ID matched anyway; with a different key the signature failed anyway.
  • certs.json had no readers. It was a JWKS copy of the public key that only the server read back, to reuse the JWKS code it uses for external identity providers. No endpoint served it.
  • A wrong key ID returned 500. It surfaced as SigningKeyNotFoundException → INTERNAL, which the Java client used by the Spark and Hadoop connectors retries (5xx, 3 attempts).
  • The checker for the server's own tokens and both keys are built once at startup.

Compatibility. Users see these in the Upgrading section of docs/server/auth.md.

  • Existing tokens keep working: they carry a key ID, which is now ignored, and are signed by the same key. To keep them when moving to the setting, point it at etc/conf/private_key.der or a copy of it; a new key makes them fail with 401.
  • Mixed versions during a rolling upgrade work: a server on the previous version accepts the new tokens without a key ID, because its certs.json holds one key. I checked jwks-rsa 0.24.1 UrlJwkProvider: no kid with one key returns that key, and a wrong kid throws SigningKeyNotFoundException.
  • Internal tokens signed with RS256 or RS384 were accepted before (the algorithm came from the token header) and now get 401. The server itself only ever signed with RS512.
  • Rollback: an existing key_id.txt and certs.json are left in place, which a previous version needs. The docs say to keep them while a rollback is possible, and how to write the operator's key to etc/conf in the formats an earlier version reads.
  • Rollback after a fresh install on this version: there is no key_id.txt, so an earlier server generates a new key (tokens must be reissued), and an earlier chart stops without one in the Secret. The docs say to add a key_id.txt with any value first.
  • Helm upgrade: the generated Secret is kept on upgrade (resource-policy: keep), so its key and its old key_id.txt stay.
  • Helm with a pinned older server image: that image ignores the setting and generates its own key in each pod, so tokens from other pods and the create-users job are rejected. The image tag note in values.yaml says to use the image from the chart's release.
  • Helm Secret with both private_key.pem and private_key.der: the chart now uses the PEM one (before: the DER one).
  • Helm with a key file set through server.config.override or extraProperties: it must point at the key in the Secret. The create-users job signs with that key and retries without a limit, so with another key the install waits until Helm's timeout.

Not done (on purpose).

  • Key rotation is separate work.
  • No defaultMode on the Secret volume. The private key mount keeps today's mode.

Tests.

  • SecurityConfigurationTest:
    • readsTheOperatorsKeyFile, one row per format (PKCS Add issue templates #8 DER, PKCS Add issue templates #8 PEM, PKCS Update the supported Engines section #1 PEM, a certificate followed by a PEM key): reads the private key, derives the matching public key, and writes nothing to the configuration folder. The PEM headers are built at runtime so the secret scanner doesn't flag the test source;
    • rejectsAnEncryptedPrivateKey;
    • createsAGeneratedPrivateKeyReadableByItsOwnerOnly: a blank setting falls back to etc/conf, the generated key is rw-------, no key_id.txt is written, and a later start reuses the key.
  • AuthDecoratorTest.tokenSignedWithAnotherKeyIsRejected: with a key ID the server never had, which gave 500 before.
  • UnityCatalogServerTest.startupUsesTheTokenSigningKeyFileSettings: startup uses the setting, fails on a missing file, and creates a configuration folder that does not exist yet.
  • Old tokens: the access-control suites mint their tokens with a key ID, so tokens like those from earlier versions are checked through the real server.
  • helm template / chart lint: a key file set through extraProperties is kept; a blank one gets the chart's key. The CI render step checks that the init container appends the setting and that the server container mounts the key Secret: the CI installs run with authorization off, where a server given no key file falls back to a generated key. The init container's check was run against each form (=, :, a space, blank, commented out) under sh and BusyBox grep.
  • Checked by hand on an earlier revision of this PR that also had a public-key setting: a local server with an openssl genrsa PKCS Update the supported Engines section #1 PEM key (valid token 200, broken signature 401, no token 401; an encrypted key stops startup), and a fresh install on kind with PostgreSQL 18, auth and a create-users user.

This pull request and its description were written by Isaac.

@shba24

shba24 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Local AI review run

The CI /review workflow is skipped for this account, so the repository's reviewer roles were run locally once, on the stack before its final fixes (Claude models; the Codex role was not run):

  • uc-domain-reviewer and maintainer-claude-reviewer (one pass)
  • architecture-reviewer, docs-reviewer and test-coverage-reviewer (one pass)
  • a silent-failure pass

Each finding was checked against the code before acting on it.

Finding Outcome
A line break at the end of a Secret value broke env-sourced secrets (the old envsubst path dropped it) Fixed in #2079: dropped for the upper-case names
bin/uc-admin-token could generate a new key when run from another directory, and rewrote certs.json, which the server re-reads for every internal token check Fixed in #2082: reads the key only, fails if missing, writes no files, runs from the install directory
A stale public_key.der in the key directory could mismatch the signing key Fixed in #2081: the public key is always derived from the private key
token.txt deletion described as making the old token invalid Fixed in #2082: the comment, log and docs say copies stay valid until the key changes
Misleading warning for hibernate.connection.password in server.properties Fixed in #2080
Encryption key: untrimmed inline value, invalid base64 reported as wrong length, key file path missing from errors, name-based bean lookup Fixed in #2083
Weak test assertion on the in-memory token Fixed in #2082: the token is verified against the key
No AAD binding a ciphertext to its row; no bulk re-encryption; generic 500 when a key is missing Kept, documented in #2083
Public HibernateConfigurator(Properties) stores plaintext Kept: callers are tests only
PEM key path has no unit test Kept: the secret scanner blocks PEM headers in test sources; covered end to end with an openssl genrsa key and the chart's generated key on kind

Reviewed heads: 2f4bb5a, 690745f, 8b8356b, c0bc199, d7bf525. Current heads: 81e48b4, eba9f92, 99ae5a0, b91905f, b19e7a5.

@shba24
shba24 force-pushed the stack/ep31-signing-key-dir branch from 99ae5a0 to 2748528 Compare October 29, 2026 20:40
@shba24

shba24 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Local AI review run (round 2)

The CI /review workflow is skipped for this account, so the review pipeline was run locally on the reworked stack (two-file signing key, no key ID, no certs.json, encryption dropped). Each finding was checked against the code before acting on it.

  • Repository reviewer roles (.github/omnigent/reviewer, Claude): uc-domain-reviewer, maintainer-claude-reviewer, architecture-reviewer, test-coverage-reviewer, docs-reviewer. The Codex role was not run.
  • Isaac Review, twice.
  • pr-review-toolkit: code, tests, comments, silent failures, plus a docs-completeness pass for the deprecations.
Finding Outcome
bin/uc auth login read the client secret only from server.properties Fixed in #2079: reads SERVER_CLIENT_SECRET first
aws.sessionToken listed as a secret, but the server never reads it Fixed in #2079: dropped from the secret list and docs
docs/server/aws.md showed aws.s3.* keys the server does not read Fixed in #2079
A DB password in server.properties was ignored silently Fixed in #2080: warns that it is ignored
Password precedence test depended on the shell's environment Fixed in #2080
No test rejects an internal token signed with another key Fixed in #2081 (AuthDecoratorTest); deleting the signature check fails it
Deprecation warning for the generated key fired with authorization off Fixed in #2081: only with authorization enabled
Encrypted or malformed PEM keys gave errors without the file Fixed in #2081
Helm init container continued after an openssl failure Fixed in #2081
Advice to delete key_id.txt broke rollback Fixed in #2081: docs say keep it while a rollback is possible
Unused fields and an uncalled method across commits Fixed in #2081 / #2082
bin/uc-admin-token: wrong-directory key generation, rewrote certs.json, logs on stdout in Helm pods, stale-file failure on a read-only folder Fixed in #2082
Missing tests: ADLS env secret, both key settings, PEM public key, loadExisting, stray files after startup Added to existing tests
No check that the two key files are one pair Kept: operator's responsibility, as in Polaris
No PEM private-key unit test Kept: the pre-commit secret scanner blocks PEM private-key headers; covered end to end
Chart CI never renders the secret env vars (defaults only) Kept: checked on kind with PostgreSQL 18, auth, S3 and create-users
Shared owner for the secret lookup; security → utils dependency Kept for now (refactor, not a defect)

Verification on the current heads:

  • build/sbt clean test is green, and server Javadoc builds.
  • Each lower commit builds and passes its tests on its own.
  • Seven deliberate code breaks were each caught by a test.
  • Helm lints, renders and matches helm-docs at every commit.

Current heads: b2cb578, cf24a2d, 2748528, ccb9bf1.

@shba24

shba24 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@shba24
shba24 force-pushed the stack/ep31-signing-key-dir branch from 2748528 to b25ef87 Compare October 29, 2026 23:26
@shba24
shba24 marked this pull request as ready for review October 29, 2026 23:28
@shba24
shba24 force-pushed the stack/ep31-signing-key-dir branch 2 times, most recently from e417179 to 43bb125 Compare November 3, 2026 10:17
@shba24 shba24 changed the title [Server] Read the token signing key from an operator directory [Server] Read the token signing key from an operator key file Nov 3, 2026
shba24 and others added 13 commits November 4, 2026 00:19
Operators can now set any setting, including the OAuth client secret,
the AWS secret key, and the per-bucket S3 and ADLS secrets, in an
environment variable a shell can export: UC_, then the key in upper case
with `_` for each other character, such as UC_S3_SECRETKEY_0. The prefix
keeps variables that runtimes set for their own use, such as AWS_REGION,
from changing settings. A variable named exactly as the key still comes
first. At startup the server logs the name of each variable it uses,
never the value. `bin/uc auth login` also reads UC_SERVER_CLIENT_SECRET.

Secrets in server.properties keep working, but the server now logs a
deprecation warning for each one it reads from the file, and the docs
mark that way as deprecated.

The Helm chart passes the S3 and ADLS secrets to the server container as
environment variables instead of rendering them into server.properties,
and no longer gives the server the OAuth client secret, which only the
CLI reads.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The comment on reading UC_SERVER_CLIENT_SECRET repeated what the next lines do; keep the part that says why the name and trimming match the server.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The server never reads server.client-secret, but its deprecation warning told operators to set UC_SERVER_CLIENT_SECRET, and setting it in the server's environment silenced the warning. The warning now says only bin/uc auth login reads it, names the shell that runs that command, and is no longer silenced by the server's environment.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The CLI login tests pass --identity_token, so none reached the UC_SERVER_CLIENT_SECRET lookup in the OAuth flow. Move the lookup into Oauth2CliExchange.clientSecret and test it in CliAuthCrudTest: the variable wins over server.client-secret with a trailing line break dropped, and an absent, empty or line-break-only variable falls back to the file.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The database password could only come from hibernate.properties. The
server now also takes it from the UC_HIBERNATE_CONNECTION_PASSWORD
environment variable, which wins over the file. A system property is not
used for it: Hibernate copies system properties into its own settings,
and a password there makes the connection pool fail.

A password kept in hibernate.properties still works, but the server logs
a deprecation warning, and the docs mark that way as deprecated.

The Helm chart passes the password to the server container as an
environment variable instead of rendering it into hibernate.properties.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
AGENTS.md describes where the backends are configured, and a password in hibernate.properties still works; the configuration and deployment docs cover the environment variable.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The two-line private method says the same.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The server signed its tokens with a key it generated into etc/conf, and
the Helm chart copied its key Secret into etc/conf because the location
was fixed.

The new server.token-signing-private-key-file setting names the
operator's RSA private key, in PEM or DER; the server only reads it and
derives the public key from it once, at startup. Without it the server
keeps using the key in etc/conf, generating it on first start (a newly
generated private key is now readable by its owner only), and with
authorization enabled logs a deprecation warning.

The server now checks its own tokens with that key directly, with RS512
only. It no longer writes certs.json, and it no longer uses a key ID:
new tokens carry none and checks ignore it. Existing tokens keep
working, since they are signed with the same key, and a server on the
previous version accepts the new tokens, since its certs.json holds one
key. A token signed with another key is now rejected with 401 instead
of a 500.

The Helm chart points the setting at the private key in its Secret
mount and no longer needs key_id.txt or openssl in the init container.
Generating the key Secret (server.jwtKeypairSecret.create) still works
but is deprecated, and the install notes say how to keep the current
key.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Kubernetes always mounts Secret volumes read-only, so the flag changed nothing.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
UnityCatalogServerTest.startupUsesTheTokenSigningKeyFileSettings already starts the server with a key file that does not exist and checks the message.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The PKCS unitycatalog#1 PEM case of readsTheOperatorsKeyFile already reads a PKCS unitycatalog#1 key and checks it equals the original, so pkcs1ToPkcs8 can be private.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Only the holder of the server's key can sign an internal token, so accepting another RS algorithm from it would harm nobody; the RS512-only change stays documented in the auth upgrade notes.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The rollback steps for key_id.txt and certs.json are in the Upgrading section of auth.md; the configuration page now links there instead of repeating part of them.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…he startup test

The empty configuration folder case writes token.txt into the working
directory, which the test then deleted, losing a file that was already there.
It now restores the file's earlier content.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24
shba24 marked this pull request as draft November 21, 2026 04:25
@shba24

shba24 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

/review

shba24 added a commit to shba24/unitycatalog that referenced this pull request Nov 23, 2026
Brings in the tests for more unusable key files. SecurityContext and
UnityCatalogServerTest keep this branch's version: the server here
writes no token.txt, so unitycatalog#2081's folder creation before that write, and
its steps checking the written file, do not apply.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24
shba24 marked this pull request as ready for review November 23, 2026 21:22
@shba24
shba24 marked this pull request as draft November 23, 2026 22:41
No conflicts. Brings in ownership transfer (unitycatalog#2149), pool metrics (unitycatalog#2284)
and the check that tests leave the checkout clean (unitycatalog#2334).

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Algorithm.RSA512(
(RSAPublicKey) otherKey.getPublic(), (RSAPrivateKey) otherKey.getPrivate()));

assertThatThrownBy(this::serve).isInstanceOf(SignatureVerificationException.class);

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.

this tests a different key with RS512, not a different signing algorithm. could we also add parameterized cases with the server's own key for RS512 (succeeds) vs RS256, RS384, HS512, and unsigned tokens, and assert verifyNotDelegated() on the rejected ones? otherwise a later change could silently bring back RS256/RS384 acceptance.

.hibernateConfigurator(hibernateConfigurator)
.configurationFolder(missing)
.build()) {
assertThat(missing.resolve("token.txt")).isNotEmptyFile();

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.

a server that ignored the setting and generated a fresh key would also write a non-empty token.txt here. could we verify the token's signature against the configured key's public key, and check that no fallback keys were created?

 assertThat(missing.resolve("token.txt")).isNotEmptyFile();
+assertThat(missing.resolve("private_key.der")).doesNotExist();
+assertThat(missing.resolve("public_key.der")).doesNotExist();

throw new IllegalStateException(
"Cannot read the RSA private key in "
+ file.toAbsolutePath()
+ "; expected a PEM key, or a PKCS #8 DER one",

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.

EC, DSA, and OpenSSH keys hit this message even when they're already PEM, so an operator following it can still pass an unsupported key. could we spell out the full accepted format and maybe add an EC-key case to check the message?

-              + "; expected a PEM key, or a PKCS #8 DER one",
+              + "; expected an unencrypted RSA private key in PKCS #8 PEM or DER, or PKCS #1 PEM",

shba24 and others added 2 commits November 23, 2026 23:15
…pdir

The step used the working directory, the repository root, which tests
must not write to (AGENTS.md). An empty path in a zip file system has
no parent either, so the step still fails without the fix.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…s tokens

Tokens signed with the server's own key but another algorithm (RS256,
RS384, HS512 or none) are rejected without reaching the service. The
startup test checks that token.txt is signed with the configured key
and that no fallback key is generated. A key that is not an RSA key now
gets a message that says which keys the server reads.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Nov 24, 2026
Brings in main (ownership transfer, pool metrics, the checkout-clean
test check) through unitycatalog#2081. No conflicts.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Nov 24, 2026
Brings in the tests that only RS512 and the configured key sign the
server's tokens, and the clearer message for a key that is not RSA.
UnityCatalogServerTest keeps this branch's version: its new steps check
the token.txt that the server here does not write.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24
shba24 marked this pull request as ready for review November 24, 2026 00:13
@yili-db

yili-db commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

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.

[AI Assisted] Approving at 5ac94bb. Reviewed the PR's own change (main merged into the head, so the earlier #2080 commits drop out). The key file is read and validated at startup with clear errors that name the file, the existing key folder path still works, a token signed with the wrong key now gets a 401, and the targeted auth tests pass.

Follow-ups, fine to fix here if convenient, otherwise please track them as issues and link them from the description:

  1. helm/templates/server/deployment.yaml:68-70: the init guard checks the first server.token-signing-private-key-file line, but the server reads the last one (Properties keeps the later value, and extraProperties renders after server.config.override). With a non-empty value in the override and a blank extraProperties entry, the guard appends nothing, the server reads the blank value, and each pod generates its own key. Checking the last matching line would match what the server reads. A small case table in CI would cover it: non-empty only, blank only, non-empty then blank, blank then non-empty.
  2. SecurityConfiguration.java:75: the folder path reads public_key.der, while the key-file path derives the public key from the private key. If the two files do not match, the verifier and the signer use different keys, so internal tokens get a 401 and startup logs nothing. Deriving the public key here too (as publicKeyOf does), while still writing public_key.der for rollback, would remove this case.
  3. Description wording: "Without it nothing changes for existing setups" holds for the key source only, since the kid and RS512-only checks apply to every setup; maybe "Without it the key source does not change". And "(without authorization the key is unused)": the key still signs token.txt at startup, so maybe "without authorization no request checks the key, but it still signs token.txt at startup".

Nits:

  • UnityCatalogServer.java:755-757: the builder Javadoc says the folder holds the signing keys; with the setting it holds only token.txt.
  • docs/server/configuration.md:77-79: worth adding that the file must exist even with authorization off, that a new key takes effect at the next start, and that a relative path resolves against the working directory.
  • SecurityConfiguration.java:117: no minimum key size. A 512-bit key loads and then fails at startup when the service token is signed, with a message that does not name the file.
  • A key file path that points to a directory fails with "Is a directory" and no path; the missing, empty and encrypted cases do name the file.
  • JwksOperations.java:82-85: the null-context branch exists only for the JwksOperationsTest constructors.
  • AuthDecoratorTest.java:142: "earlier versions failed the lookup with a 500" describes history; describing the behavior would age better.
  • No server-level test pins that a rejected internal token gets HTTP 401.
  • SecurityConfiguration.java:161-166 (writeOwnerOnly): delete, create, then write is not atomic, so a crash in between leaves an empty private_key.der and the next start fails until it is removed. It fails closed and the folder path is deprecated, so this is a follow-up at most.

@shba24
shba24 marked this pull request as draft November 24, 2026 02:56
The init container appends the Secret's key file unless
server.properties already sets one. It checked whether any line sets a
non-empty value, while the server reads the last line: extraProperties
render after server.config.override, and Properties keeps the later
value. A non-empty override followed by a blank extraProperties entry
appended nothing, the server read the blank value, and each pod
generated its own key.

The guard now checks the last line that sets the key file. The render
check runs it on four cases: non-empty only, blank only, non-empty then
blank, blank then non-empty. On the old guard the third case fails.

Also reword the configurationFolder Javadoc, which said the folder
always holds the signing keys, and a test comment that described
history instead of behavior.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Nov 24, 2026
@shba24
shba24 marked this pull request as ready for review November 24, 2026 03:08
@shba24

shba24 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks Yi, this was a careful pass. Every item was checked against the code, and where possible with a local run. Changes are in f681566.

Follow-ups

  1. Helm guard: fixed. You were right: with a non-empty server.config.override value and a blank extraProperties entry, the old guard appended nothing and the server read the blank value. A local render of the chart, read back with java.util.Properties, showed it. The guard now checks the last line that sets the key file, as the server does (Properties.load keeps the later value). The render check runs the guard on your four cases; on the old guard, "non-empty then blank" fails.
  2. public_key.der on the folder path: this is unchanged by the PR. The code before the PR also read the two files separately. I ran the same mismatched pair on the base and on 5ac94bb: both start, and both reject their own token with SignatureVerificationException. Deriving the public key there is reasonable hardening for a path that is now deprecated, so I left it out of this PR.
  3. Description: updated to "Without it the key source does not change" and "without authorization no request checks the key, but it still signs token.txt at startup".

Nits

  • configurationFolder Javadoc: fixed; it now says the folder holds the signing keys only when the key file is not set.
  • AuthDecoratorTest comment: now describes the behavior ("The key ID is ignored: the token is checked against the server's own key").
  • configuration.md: the three facts are true, and the current text already says that a file that is set must exist and that the key is derived once at startup, so I left it as is.
  • Minimum key size: unchanged by the PR. A 512-bit key in the key folder behaved the same before it (it loads and then fails when the service token is signed), and startup still fails.
  • Key file path that is a directory: agreed, the message has no path; it still stops startup. Left as is.
  • Null context in JwksOperations: the constructor accepted null before the PR too; removing it means giving the external-issuer tests a real context, which I'd rather not mix in here.
  • HTTP 401 for a rejected internal token: AuthServiceTest.testExpiredAccessTokenIsRejected sends a rejected internal token through the running server and asserts 401. Wrong-key and wrong-algorithm tokens raise the same JWTVerificationException, which BaseExceptionHandler maps to 401.
  • writeOwnerOnly: agreed, it fails closed and the path is deprecated, so I left it as a follow-up.

@yili-db

yili-db commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db

yili-db commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

[AI Assisted] Merging this now. Thanks for the quick fixes: the Helm init guard now follows the last key-file line, and the new CI step covers all four cases.

One follow-up from the earlier review is still open, so could you open an issue for it? In the folder path, SecurityConfiguration.java:75 still reads public_key.der instead of deriving the public key from the private key (as publicKeyOf does on the key-file path). If the two files do not match, internal tokens get a 401 and startup logs nothing. It only affects the deprecated folder path and fails closed, so it does not need to hold this PR. The remaining nits from the review (configuration.md note, minimum key size, the "Is a directory" message, the null-context branch, a server-level 401 test, the non-atomic key write) can go in the same issue or a later cleanup.

@yili-db
yili-db merged commit aa8f434 into unitycatalog:main Nov 24, 2026
27 checks passed
@shba24

shba24 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks Yi, and thanks for merging. I opened one small issue per follow-up and linked them from the description:

The configuration.md note, the server-level 401 test and the JwksOperations null-context branch stay as answered above.

yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 25, 2026
…ests

- `AGENTS.md`: CI also fails on ignored, edited or deleted files under any `etc/conf`
- Drop `certs.json` from comments: since unitycatalog#2081 the server writes only its signing keys and `token.txt`
- `test_check_etc_conf.py`
  - A nested file, `etc/conf/keys/private_key.der`, must fail
  - Untracked and ignored files outside `etc/conf` must not
- `check_conf_stamps`: an `etc/conf` three levels deep must not be watched

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[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