Repository navigation
Add Azure workload identity for Blob storage and PostgreSQL - #134
Merged
Merged
Conversation
The Runtime and Platform can now log in to Azure Database for PostgreSQL with a Microsoft Entra token instead of a stored password. Each selects it with its own setting, LIGHTSPEED_POSTGRES_AUTH_MODE or LIGHTSPEED_PLATFORM_DATABASE_AUTH_MODE, and password remains the default. The URL must name the identity, hold no password, and set sslmode=verify-full, because the token is sent as a password inside TLS. The Runtime exchanges the projected token itself and updates the pool's connect options at half of each token's lifetime. The Platform uses @azure/identity through pg's password function. Temporal stays on password authentication and is planned separately. Pool settings now limit reconnects in both modes. The Platform pool also gains an error listener, because losing an idle connection previously ended the process, and TCP keepalive, because pg does not check connections before handing them out. Verified with unit tests, a token rotation test against a real PostgreSQL role, and the Platform migration and release packaging checks. Not yet run against a real Azure server; azure_postgres_live covers that from a federated workload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: lb <542828+lukebuehler@users.noreply.github.com>
Bump the product version and add release notes for workload identity and the connection pool changes. workflow-compat.sh v0.6.0 reports restart-in-place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: lb <542828+lukebuehler@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Azure deployments that prohibit account keys, SAS tokens, and stored database passwords can't run Lightspeed today. The Runtime only authenticates to Blob storage with a key or SAS token, and both the Runtime and Platform only log in to PostgreSQL with a password.
What changes
Both now authenticate with a projected Kubernetes service account token, exchanged for a Microsoft Entra access token. No secret is stored, and rotation doesn't need a restart. Nothing changes unless a deployment selects it.
LIGHTSPEED_OBJECT_STORE_AZURE_AUTH_MODE=workload_identityLIGHTSPEED_POSTGRES_AUTH_MODE=workload_identitypasswordLIGHTSPEED_PLATFORM_DATABASE_AUTH_MODE=workload_identitypasswordAll three read
AZURE_CLIENT_ID,AZURE_TENANT_ID,AZURE_FEDERATED_TOKEN_FILE, and optionallyAZURE_AUTHORITY_HOST. Those variables do nothing unless a setting selects this mode. A selected mode never falls back to another credential, and it rejects a conflicting key, SAS token, or URL password.Blob storage uses
object_store's own provider for the exchange and token caching. Two wrappers instore-pgadd what the library doesn't provide:Debugoutput prints the cached access token, so the provider is held behind one that shows only the file path.AADSTScodes, storage error codes, and request IDs.PostgreSQL sends the token as the login password. Database URLs must set
sslmode=verify-full, because the token would otherwise go to an unverified server.store-pgtherefore performs the exchange and updates the pool's connect options at half of each token's lifetime.@azure/identitythroughpg's password function.Changes that also affect password deployments
Pool settings now limit reconnects in every mode:
sqlx)pg)The Platform pool also gains an
errorlistener. Without one, losing an idle connection ended the process.Each process now holds connections longer, so check that the total stays under the server's
max_connections.Compatibility
No database migration, stored-object conversion, or API change. Existing paths, prefixes, and blob references stay valid.
@azure/identityis a new Platform production dependency.Checks
Passed:
store-pgtests andtemporal-runtimeconfig tests. Azure traffic runs through the real clients against a local TLS fake, covering wire content, token rotation, certificate and hostname rejection, failed authentication, and redaction.Not run:
azure_blob_liveandazure_postgres_live: these need a federated workload and a real Azure account, so nothing here has run against real Azure. Blob should be tested with Shared Key disabled.pg.Not included
🤖 Generated with Claude Code