Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
5772a70
[Server] Read server settings from UC_ environment variables
shba24 Nov 3, 2026
85fb47b
[CLI] Drop a comment that restates the code
shba24 Nov 3, 2026
1943aef
[Server] Point the client secret warning at bin/uc auth login
shba24 Nov 4, 2026
476239b
[CLI] Test reading the client secret from the environment
shba24 Nov 4, 2026
db8c642
[Server] Read the database password from an environment variable
shba24 Nov 3, 2026
67b25ea
[Docs] Leave the database password out of AGENTS.md
shba24 Nov 3, 2026
a733445
[Server] Drop a comment that restates getOverride
shba24 Nov 3, 2026
35945bb
[Server] Read the token signing key from an operator key file
shba24 Nov 3, 2026
a3e42d2
[Helm] Drop readOnly from the signing key Secret mounts
shba24 Nov 3, 2026
f4e3882
[Server] Drop a missing key file test that another test repeats
shba24 Nov 3, 2026
d48deb5
[Server] Drop the byte-level PKCS #1 wrapping test
shba24 Nov 3, 2026
de45a1b
[Server] Drop the RS256 internal token test
shba24 Nov 3, 2026
e4e0ec3
[Docs] Point the generated key note at the auth upgrade notes
shba24 Nov 3, 2026
749d64a
[Docs] Drop the signing key paragraph from the Docker Compose guide
shba24 Nov 3, 2026
2c278f3
[Server] Leave the openssl command out of the SecurityConfiguration J…
shba24 Nov 3, 2026
7376e27
Merge main into stack/ep31-config-secrets-env
shba24 Nov 5, 2026
d668515
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 5, 2026
0284bef
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 5, 2026
e34f160
[Helm] Keep the old secret variables for custom server.properties tem…
shba24 Nov 5, 2026
c1e476c
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 5, 2026
4ecaf5d
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 5, 2026
f437c79
[Docs] Fix wording from the AI review
shba24 Nov 5, 2026
b81663d
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 5, 2026
5b06d99
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 5, 2026
6dabc23
[Docs] Name the one token signing key file setting
shba24 Nov 5, 2026
b7c2155
[Server] Rewrap a Javadoc line over 100 characters
shba24 Nov 5, 2026
a1f926c
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 5, 2026
3bd964a
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 5, 2026
ccf1dc3
Merge main into stack/ep31-config-secrets-env
shba24 Nov 6, 2026
50c79b9
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 6, 2026
e43de6c
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
45908d7
Skip the env log line for the client secret; note auth.enabled in the…
shba24 Nov 6, 2026
bce4fd4
Rewrap the Helm upgrading note
shba24 Nov 6, 2026
ae24f11
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 6, 2026
4245b74
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
c04f82f
Test the secrets-in-file warnings and the Helm secret wiring
shba24 Nov 6, 2026
52a6c8d
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 6, 2026
82fe59f
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
c6d1143
Pass whole storage credentials to the server; precompile env patterns
shba24 Nov 6, 2026
c24eb54
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 6, 2026
53488b7
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
03c0541
Keep storage credentials out of the generated server.properties
shba24 Nov 6, 2026
39433fe
Rewrap the Helm upgrading note
shba24 Nov 6, 2026
86957eb
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 6, 2026
b3af7ba
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
b63005a
Drop the precompiled env patterns
shba24 Nov 6, 2026
765315f
Test the secrets-in-file warnings through the log
shba24 Nov 6, 2026
c556936
Drop the docs note on exact-name variables
shba24 Nov 6, 2026
b39674e
Drop the rotation rationale from the docs
shba24 Nov 6, 2026
68c80c7
Shorten the secretEnv comment
shba24 Nov 6, 2026
0a43917
Restore the secrets fixture comment
shba24 Nov 6, 2026
6af48d7
Say that the UC_ variables take precedence over a custom template
shba24 Nov 6, 2026
52be2ac
Merge stack/ep31-config-secrets-env into stack/ep31-db-password-env
shba24 Nov 6, 2026
2b96c36
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
1d74a69
Merge main into stack/ep31-db-password-env
shba24 Nov 6, 2026
b7da133
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
9ade813
Warn about a DB password in server.properties unless the environment …
shba24 Nov 6, 2026
0ed1bdf
Check the DB password Secret in the Helm render step
shba24 Nov 6, 2026
f45629d
Say the secretEnv helper also covers the DB password
shba24 Nov 6, 2026
a822d69
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 6, 2026
07a508b
Test the ignored DB password warning in server.properties
shba24 Nov 7, 2026
48c3827
Correct the DB_PASSWORD_KEY Javadoc and drop its alias
shba24 Nov 7, 2026
a81ad0b
Merge main into stack/ep31-db-password-env
shba24 Nov 7, 2026
da9fdec
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 7, 2026
814b02b
[Helm] Keep the database password when the MySQL driver env is added
shba24 Nov 7, 2026
e5025e7
Merge remote-tracking branch 'origin/stack/ep31-db-password-env' into…
shba24 Nov 7, 2026
0aba501
Check the ignored DB password next to the secrets loop
shba24 Nov 10, 2026
eed6b86
Merge main into stack/ep31-db-password-env
shba24 Nov 10, 2026
802da62
Merge stack/ep31-db-password-env into stack/ep31-signing-key-dir
shba24 Nov 10, 2026
bde7e4d
Merge main into stack/ep31-signing-key-dir
shba24 Nov 19, 2026
71f1ae5
Merge main into stack/ep31-signing-key-dir
shba24 Nov 19, 2026
b0d17cb
[Server] Drop the key_id.txt and certs.json checks merged from main
shba24 Nov 19, 2026
c7c3140
[Server] Create the configuration folder when a key file is set
shba24 Nov 20, 2026
7a7af68
[Helm] Check that the server gets the key file in the render step
shba24 Nov 20, 2026
c5f088b
[Server] Create the token file's folder for an empty configuration fo…
shba24 Nov 21, 2026
51e82ab
[Server] Test more unusable token signing key files
shba24 Nov 21, 2026
fe618eb
[Server] Keep an existing token.txt in the working directory during t…
shba24 Nov 21, 2026
0c2a00a
Merge main into stack/ep31-signing-key-dir
shba24 Nov 23, 2026
8ac7af2
[Server] Test the empty configuration folder in a zip file under @Tem…
shba24 Nov 23, 2026
5ac94bb
[Server] Test that only RS512 and the configured key sign the server'…
shba24 Nov 23, 2026
f681566
Keep the Helm key file the server reads, not the first one set
shba24 Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/helm-chart-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ jobs:
grep -qF -- '- --upgrade-schema' <<<"$upgrade"
grep -qF -- 'mountPath: /home/unitycatalog/etc/conf' <<<"$upgrade"
grep -qF -- 'name: db-volume' <<<"$upgrade"
# The init container points the server at the key in the Secret mount, and the server mounts it.
init="$(sed -n '/^ - name: init$/,/^ - name: upgrade-schema$/p' <<<"$out")"
grep -qF "printf '\nserver.token-signing-private-key-file=%s\n' \"\$PRIVATE_KEY\" >> /home/unitycatalog/etc/conf/server.properties" \
<<<"$init"
# The server reads the last line that sets the key file: the init container keeps it only if non-empty.
guard="$(sed -n '/# A key file set to a non-empty value/,/^ *fi$/p' <<<"$init" | sed 's#/home/unitycatalog/etc/conf/server.properties#"$1"#')"
props="$(mktemp)"
key=server.token-signing-private-key-file
for case in "$key=/k/a|/k/a" "$key=|/secret/key" "$key=/k/a\n$key=|/secret/key" "$key=\n$key=/k/b|/k/b"; do
printf "${case%|*}\n" > "$props"
PRIVATE_KEY=/secret/key sh -c "$guard" sh "$props"
grep "^$key" "$props" | tail -n 1 | grep -qxF "$key=${case#*|}"
done
server="$(sed -n '/^ - name: server$/,/^ volumes:$/p' <<<"$out")"
grep -A1 -- '- name: jwt-key-volume$' <<<"$server" | grep -qF 'mountPath: /home/unitycatalog/etc/confJwtKey'
# An in-memory database keeps the init container: --upgrade-schema succeeds on it without doing anything.
for override in 'server.env=test' 'server.env: prod'$'\n''server.env=test'; do
out="$(helm template uc helm --show-only templates/server/deployment.yaml --set-string "server.config.override=$override")"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ python_engine.log
etc/conf/certs.json
etc/conf/*.txt
etc/conf/*.der
etc/conf/*.pem
connectors/spark/etc/conf/certs.json
connectors/spark/etc/conf/*.txt
connectors/spark/etc/conf/*.der
Expand Down
35 changes: 34 additions & 1 deletion docs/server/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,38 @@ Move `server.client-secret` from `server.properties` to the `UC_SERVER_CLIENT_SE
where you run `bin/uc auth login`; the server does not read it. The file still works, but is deprecated (see
[Secrets](configuration.md#secrets)).

Set `server.token-signing-private-key-file` to your own private key. To keep the tokens issued before the upgrade
working, point it at the key the server already has, `etc/conf/private_key.der`, or a copy of it; a new key makes
those tokens fail with 401. A server without the setting keeps signing with the key it generated in `etc/conf`, which
is deprecated (see [Configuration](configuration.md#configuration)).

Other changes to the server's own tokens:

- A token signed with a different key always gets 401. Before, one with a key ID the server did not know got 500,
which clients such as the Spark connector retried.
- The server's own tokens must be signed with RS512. Before, RS256 and RS384 tokens signed with the server's key were
also accepted; the server and the Helm chart have always signed with RS512.
- The server no longer writes `etc/conf/key_id.txt` or `etc/conf/certs.json`, and leaves existing ones in place. An
earlier version generates a new key when `key_id.txt` is missing, so before rolling back a server that was first
started on this version, create `etc/conf/key_id.txt` with any value, for example `uc`. An earlier version also
ignores the key file setting, so before rolling back a server that uses it, write its key to `etc/conf` in the
formats an earlier version reads:
`openssl pkcs8 -topk8 -nocrypt -in private_key.pem -outform DER -out etc/conf/private_key.der` and
`openssl rsa -in private_key.pem -pubout -outform DER -out etc/conf/public_key.der`.
- A newly generated `etc/conf/private_key.der` is readable by its owner only, on file systems with POSIX permissions.
- With authorization enabled and no key file setting, the server logs a warning at each start.
- Helm: use the server image from the chart's release, which is the default. An older server image ignores the key
file setting and generates its own key in each pod, so tokens from other pods and from the create-users job are
rejected.
- Helm: an earlier chart requires `key_id.txt` in the key Secret: with `jwtKeypairSecret.create: true` its render fails,
and with `create: false` its init container exits. A Secret this chart creates has none, and neither does one made
with the [Helm guide](helm.md#token-signing-key). Before rolling back to an earlier chart, add a `key_id.txt` key with
any value to the Secret.
- Helm: if the key Secret holds both `private_key.pem` and `private_key.der`, the chart uses `private_key.pem`.
- Helm: a key file setting set through `server.config.override` or `extraProperties` must point at the key in the key
Secret. The create-users job signs with that key and retries without a limit, so with another key the install or
upgrade waits until Helm's timeout.

### Permission-check migration

`server.authorization.strict-privilege-checks` is a temporary migration setting. It defaults to
Expand Down Expand Up @@ -450,7 +482,8 @@ bin/start-uc-server

Behind the scenes, on startup, the UC server will configure itself with the following:

* Creation of internal signing keys and authentication files in `etc/conf`
* Creation of an internal signing key in `etc/conf` on first start, unless the
[token signing key file](configuration.md#configuration) is set; generating the key is deprecated
* Creation of an admin access token in `etc/conf/token.txt`
* Creation of an admin account in the user database
* Granting the admin account as the metastore admin for the server
Expand Down
15 changes: 15 additions & 0 deletions docs/server/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ The server config file is at the location `etc/conf/server.properties` (relative
any principal who can create a table can use it. Each entry must be a local path; an entry such as an `s3://` URL
fails server startup. As with `storage-root.*`, a relative path containing `/` (for example `./uc-external`) is
resolved against the server's working directory, and a directory that does not exist yet is accepted.
- `server.token-signing-private-key-file`: The RSA private key the server signs and checks its own tokens with: an
unencrypted PKCS #8 key in PEM or DER, or a PKCS #1 one in PEM. The server derives the public key from it once,
at startup. A file that is set must exist. Use the same key on every server instance. The server only reads the
file, so it can be a read-only mount of a Kubernetes Secret. Create a key with:

```sh
openssl genrsa -out private_key.pem 2048
```

!!! warning "Deprecated: the generated signing key"
When the key file is not set, the server signs with a key it keeps in `etc/conf`
(`private_key.der`, `public_key.der`), generating it on first start; with authorization enabled it logs a
warning at each start. This still works, but is deprecated; set the key file setting instead. A newly
generated private key is readable by its owner only. Before rolling back to an earlier version, see
[Upgrading](auth.md#upgrading) in the authentication docs.
- `server.iceberg-table.enabled`: Turns on the write endpoints of the [Iceberg REST catalog](../usage/api/iceberg.md),
such as creating, committing to, renaming and dropping tables. Defaults to `true`. Set it to `false` to reject
namespace and table changes through the Iceberg REST catalog. Tables that were already created stay readable.
Expand Down
22 changes: 22 additions & 0 deletions docs/server/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,28 @@ With `obsPort` set, the liveness probe, when turned on, checks `/livez` on the s

The endpoints are unauthenticated. See [Observability](observability.md) for restricting access to the port.

## Token signing key

The server signs its tokens with the RSA private key in the Secret named by `server.jwtKeypairSecret.name` (by
default, the server's full name plus `-jwt-key`, for example `unitycatalog-server-jwt-key`). By default
(`server.jwtKeypairSecret.create: true`), the chart generates that Secret on install and keeps it on upgrade. This is
deprecated, and a later release will stop generating the key.

For an existing release, keep its key: set `create: false` and `name` to the Secret the chart generated. A new key makes
every token issued so far fail with 401. For a new install, create the Secret yourself:

```sh
openssl genrsa -out private_key.pem 2048
kubectl create secret generic uc-token-signing-key --namespace unitycatalog --from-file=private_key.pem
```

```yaml
server:
jwtKeypairSecret:
create: false
name: uc-token-signing-key
```

## Upgrade and uninstall

To upgrade, read the release notes, scale the server to 0 replicas (`kubectl scale deployment` with the chart's
Expand Down
3 changes: 3 additions & 0 deletions etc/conf/server.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ server.client-id=
# variable of the shell that runs that command instead (see Secrets in docs/server/configuration.md).
server.client-secret=
server.redirect-port=
# The RSA private key the server signs its tokens with (unencrypted PEM, or PKCS #8 DER). Without
# it, the server uses a key it keeps in etc/conf, generating it on first start; that is deprecated.
# server.token-signing-private-key-file=/path/to/private_key.pem

# Privilege decisions use Casbin by default. OPA requires server.authorization=enable.
# Native grant/revoke/list APIs remain available, but their grants do not affect OPA decisions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public void testAuthAccess()
.withSubject(securityContext.getServiceName())
.withIssuer(securityContext.getLocalIssuer())
.withIssuedAt(new Date())
.withKeyId(securityConfiguration.getKeyId())
.withJWTId(UUID.randomUUID().toString())
.withClaim(JwtClaim.TOKEN_TYPE.key(), JwtTokenType.ACCESS.name())
.withClaim(JwtClaim.SUBJECT.key(), "missing@localhost")
Expand Down Expand Up @@ -198,7 +197,6 @@ public void testAuthAccess()
.withSubject(securityContext.getServiceName())
.withIssuer(securityContext.getLocalIssuer())
.withIssuedAt(new Date())
.withKeyId(securityConfiguration.getKeyId())
.withJWTId(UUID.randomUUID().toString())
.withClaim(JwtClaim.TOKEN_TYPE.key(), JwtTokenType.ACCESS.name())
.withClaim(JwtClaim.SUBJECT.key(), "test@localhost")
Expand Down
21 changes: 15 additions & 6 deletions helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,8 @@ not set
<td>Tag for the server image

Use the server image from the same release as the chart. The chart passes secrets to
the server as environment variables that older server images don't read.
the server as environment variables that older server images don't read. The chart also
sets the token signing key file, which older server images ignore.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -1298,7 +1299,10 @@ true
</td>
<td>Create keypair secret

If set to true, the secret will be created with a random keypair
If set to true, the chart creates the secret with a random private key on install and keeps
it on upgrade. **Deprecated:** a later release will stop generating the key. Set `create` to
false and `name` to the secret the chart generated (`<server full name>-jwt-key`), which
keeps the current key, or to a secret you created; a new key makes existing tokens fail.
</td>
</tr>
<tr>
Expand All @@ -1310,11 +1314,16 @@ derived from the chart parameters and metadata
</td>
<td>Name of the keypair secret for JWT signing

The secret must contain the following keys:
- `private_key.der` or `private_key.pem`: Private key in DER or PEM format
- `key_id.txt`: Key ID
The secret must contain `private_key.pem` or `private_key.der`: the RSA private key the
server signs its tokens with, in PEM, or in PKCS #8 DER. A `key_id.txt` key is
ignored; keep it while you may still roll back to an earlier chart, which requires it.

[Kubernetes docs](https://github.com/unitycatalog/unitycatalog/blob/main/server/src/main/java/io/unitycatalog/server/security/SecurityConfiguration.java)
Create one with:

```sh
openssl genrsa -out private_key.pem 2048
kubectl create secret generic <name> --from-file=private_key.pem
```
</td>
</tr>
<tr>
Expand Down
7 changes: 7 additions & 0 deletions helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if and .Values.server.enabled .Values.server.jwtKeypairSecret.create }}
WARNING: server.jwtKeypairSecret.create=true is deprecated. The chart generates the key the
server signs its tokens with, and a later release will stop doing so. Set
server.jwtKeypairSecret.create=false and server.jwtKeypairSecret.name to the Secret the chart
generated ({{ include "unitycatalog.server.jwtKeypairSecretName" . }}), which keeps the current key,
or to your own Secret holding private_key.pem.
{{- end }}
8 changes: 1 addition & 7 deletions helm/templates/server/create-users-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ spec:
echo "Private key not found in /key directory. Exiting."
exit 1
fi
if [ -f /key/key_id.txt ]; then
KID=$(cat /key/key_id.txt)
else
echo "Key ID not found in /key directory. Exiting."
exit 1
fi

TOKEN=$(jwt encode --kid ${KID} --jti $(uuidgen | tr '[:upper:]' '[:lower:]') --iss internal --sub admin --alg RS512 --secret "@${KEY}")
TOKEN=$(jwt encode --jti $(uuidgen | tr '[:upper:]' '[:lower:]') --iss internal --sub admin --alg RS512 --secret "@${KEY}")

until curl --fail-with-body -H "Authorization: Bearer ${TOKEN}" \
-X GET "http://{{ include "unitycatalog.server.fullname" . }}:{{ .Values.server.service.port }}/api/1.0/unity-control/scim2/Users" \
Expand Down
46 changes: 17 additions & 29 deletions helm/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,43 +48,29 @@ spec:
- /bin/sh
- -c
- |-
apk add --no-cache envsubst openssl curl
apk add --no-cache envsubst curl
envsubst < /home/unitycatalog/etc/confTemplates/server.properties.template > /home/unitycatalog/etc/conf/server.properties
# Copied, not envsubst-ed: envsubst would blank the Log4j ${hostName} lookup.
cp /home/unitycatalog/etc/confTemplates/server.log4j2.properties.template /home/unitycatalog/etc/conf/server.log4j2.properties
envsubst < /home/unitycatalog/etc/confTemplates/hibernate.properties.template > /home/unitycatalog/etc/conf/hibernate.properties

echo "Generating DER format keys (private_key.der and public_key.der) if they do not exist..."
if [ -f /home/unitycatalog/etc/conf/private_key.der ] && [ -f /home/unitycatalog/etc/conf/public_key.der ]; then
echo "DER format keys already exist, skipping generation."
elif [ -f /home/unitycatalog/etc/confJwtKey/private_key.der ]; then
echo "Using /home/unitycatalog/etc/confJwtKey/private_key.der..."
cp /home/unitycatalog/etc/confJwtKey/private_key.der /home/unitycatalog/etc/conf/private_key.der
openssl rsa -pubout -inform DER -outform DER \
-in /home/unitycatalog/etc/confJwtKey/private_key.der \
-out /home/unitycatalog/etc/conf/public_key.der
elif [ -f /home/unitycatalog/etc/confJwtKey/private_key.pem ]; then
echo "Using /home/unitycatalog/etc/confJwtKey/private_key.pem..."
openssl pkcs8 -topk8 -inform PEM -outform DER -nocrypt \
-in /home/unitycatalog/etc/confJwtKey/private_key.pem \
-out /home/unitycatalog/etc/conf/private_key.der
openssl rsa -pubout -inform PEM -outform DER \
-in /home/unitycatalog/etc/confJwtKey/private_key.pem \
-out /home/unitycatalog/etc/conf/public_key.der
# The server reads the private key from the Secret mount and derives the public key.
KEY_DIR=/home/unitycatalog/etc/confJwtKey
if [ -f "$KEY_DIR/private_key.pem" ]; then
PRIVATE_KEY="$KEY_DIR/private_key.pem"
elif [ -f "$KEY_DIR/private_key.der" ]; then
PRIVATE_KEY="$KEY_DIR/private_key.der"
else
echo "ERROR: No private_key.der or private_key.pem found in /home/unitycatalog/etc/conf or /home/unitycatalog/etc/confJwtKey"
echo "ERROR: No private_key.pem or private_key.der in the token signing key Secret"
exit 1
fi

echo "Looking up key_id.txt..."
if [ -f /home/unitycatalog/etc/conf/key_id.txt ]; then
echo "Key ID file already exists, skipping..."
elif [ -f /home/unitycatalog/etc/confJwtKey/key_id.txt ]; then
echo "Using /home/unitycatalog/etc/confJwtKey/key_id.txt..."
cp /home/unitycatalog/etc/confJwtKey/key_id.txt /home/unitycatalog/etc/conf/key_id.txt
else
echo "ERROR: No key_id.txt found in /home/unitycatalog/etc/confJwtKey"
exit 1
# A key file set to a non-empty value through server.config.override or extraProperties is kept.
# The server reads the last line that sets it, and extraProperties render after the override.
LAST_KEY_FILE="$(grep -E '^[[:space:]]*server\.token-signing-private-key-file([[:space:]=:]|$)' \
/home/unitycatalog/etc/conf/server.properties | tail -n 1)"
if ! printf '%s\n' "$LAST_KEY_FILE" | grep -q -E \
'^[[:space:]]*server\.token-signing-private-key-file(([[:space:]]*[=:][[:space:]]*[^[:space:]])|([[:space:]]+[^[:space:]=:]))'; then
printf '\nserver.token-signing-private-key-file=%s\n' "$PRIVATE_KEY" >> /home/unitycatalog/etc/conf/server.properties
fi

{{- if and (eq .Values.server.db.type "postgresql") .Values.server.db.postgresqlConfig.ssl.enabled }}
Expand Down Expand Up @@ -292,6 +278,8 @@ spec:
{{- end }}

volumeMounts: {{- include "unitycatalog.server.volumeMounts" . | nindent 12 }}
- name: jwt-key-volume
mountPath: /home/unitycatalog/etc/confJwtKey
{{- with .Values.server.deployment.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
14 changes: 1 addition & 13 deletions helm/templates/server/keypair-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,10 @@ data:
Generate RSA private-key for JWT signing
*/}}
{{- $privateKeyPEM := genPrivateKey "rsa" }}
{{/*
Generate a random hex string for key_id as expected by SecurityConfiguration.java
SecurityConfiguration.java uses SecureRandom to generate 32 random bytes and converts to hex
*/}}
{{- $keyId := "" }}
{{- range until 32 }}
{{- $keyId = printf "%s%02x" $keyId (randInt 0 255) }}
{{- end }}
private_key.pem: {{ $privateKeyPEM | b64enc | quote }}
key_id.txt: {{ $keyId | b64enc | quote }}
{{- else -}}
{{- if and (not (hasKey $secret.data "private_key.pem")) (not (hasKey $secret.data "private_key.der")) }}
{{- fail (printf "Secret '%s' is missing required key 'private_key.der'" $secretName) }}
{{- end }}
{{- if not (hasKey $secret.data "key_id.txt") }}
{{- fail (printf "Secret '%s' is missing required key 'key_id.txt'" $secretName) }}
{{- fail (printf "Secret '%s' must contain 'private_key.pem' or 'private_key.der'" $secretName) }}
{{- end }}
{{- end -}}
{{- end -}}
Loading
Loading