Persist JWT signing key across server restarts #34
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The server generates an ephemeral JWT signing key on every startup. When the server restarts, all previously issued agent tokens (access + refresh) become invalid. While the agent now handles this via auto re-registration (cameleer3 commit 8f7ad27), this causes a brief disruption and unnecessary re-registration traffic for all connected agents.
Solution
Persist the JWT signing key so it survives server restarts:
CAMELEER_AUTH_TOKEN+ salt)Option A is probably cleanest — generate once, store in Secret, load on subsequent starts.
Impact
Eliminates the root cause of agent reconnection storms after server restart. Agents keep working seamlessly across server restarts.
Implementation Plan
Approach
Add optional config properties for pre-configured signing keys. When set, use them; when absent, generate random (backward compatible for dev).
Java Changes
SecurityProperties.java— addjwtSecret,ed25519PrivateKey,ed25519PublicKeyfields (all optional strings, base64-encoded)JwtServiceImpl.java— ifjwtSecretis configured, decode and use it; otherwise generate random 256-bit key (current behavior)Ed25519SigningServiceImpl.java— if bothed25519PrivateKeyanded25519PublicKeyare configured, reconstruct keypair from PKCS8/X509 DER; otherwise generate fresh keypair (current behavior)SecurityBeanConfig.java— passSecurityPropertiestoEd25519SigningServiceImplconstructorConfig
K8s/CI
cameleer-signing-keyswith 3 keys, created idempotently in CI deploy stepdeploy/server.yamlreferences viasecretKeyRefCAMELEER_JWT_SECRET,CAMELEER_ED25519_PRIVATE_KEY,CAMELEER_ED25519_PUBLIC_KEYKey Generation (one-time)
Note
First deployment with persistent Ed25519 keys means agents with the old ephemeral key must re-register once.
Resolved in
a4de2a7. JWT secret is now configurable viaCAMELEER_JWT_SECRETenv var. If set, tokens survive restarts. Falls back to random secret (current behavior) if not set. Implemented as part of the RBAC + OIDC support commit.