Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(enterprise/dbcrypt): encrypt ai_providers and ai_provider_keys at rest - #25326

Merged
dannykopping merged 5 commits into
mainfrom
dk/aibridge-providers-dbcrypt
May 15, 2026
Merged

feat(enterprise/dbcrypt): encrypt ai_providers and ai_provider_keys at rest#25326
dannykopping merged 5 commits into
mainfrom
dk/aibridge-providers-dbcrypt

Conversation

@dannykopping

Copy link
Copy Markdown
Contributor

No description provided.

@dannykopping
dannykopping force-pushed the dk/aibridge-providers-dbcrypt branch from df25e7f to 2573348 Compare May 14, 2026 10:57
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-db branch from 1a61871 to 692e9c3 Compare May 14, 2026 10:57
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-dbcrypt branch 3 times, most recently from fffa3e9 to 1d16ab9 Compare May 14, 2026 13:20
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-db branch from 22dabfa to 62b664c Compare May 14, 2026 13:20
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-dbcrypt branch from 1d16ab9 to da18210 Compare May 14, 2026 13:38
@dannykopping
dannykopping changed the base branch from dk/aibridge-providers-db to graphite-base/25326 May 14, 2026 14:10
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-dbcrypt branch from da18210 to 86dbfac Compare May 14, 2026 14:11
@dannykopping
dannykopping force-pushed the graphite-base/25326 branch from 17d922e to 841b777 Compare May 14, 2026 14:11
@graphite-app
graphite-app Bot changed the base branch from graphite-base/25326 to main May 14, 2026 14:11
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-dbcrypt branch from 86dbfac to f78b55a Compare May 14, 2026 14:11
dannykopping and others added 2 commits May 15, 2026 10:13
…t rest

Adds dbcrypt overrides for the ai_providers.settings and
ai_provider_keys.api_key columns so secrets are encrypted at rest on
deployments configured with CODER_EXTERNAL_TOKEN_ENCRYPTION_KEYS.

Includes key-rotation support in cliutil.Rotate so existing rows are
re-encrypted with the new primary cipher, and a DeleteAIProviderByID
override so soft-deleted rows return decrypted fields like every other
read path.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Catches dbcrypt up with the upstream ai_providers query simplification
and rename: DeleteAIProviderByID/DeleteAIProviderKey are now :exec so
their wrappers are no longer needed, GetAIProviders takes a plain
sql.NullBool, and UpdateAIProviderSettings was renamed to
UpdateEncryptedAIProviderSettings.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dannykopping
dannykopping force-pushed the dk/aibridge-providers-dbcrypt branch from f78b55a to f16f248 Compare May 15, 2026 11:39
…oader coverage

The cliutil tests added in dcdf9cf covered ai_providers only, while
none of the other dbcrypt-managed tables (user_links,
external_auth_links, chat_providers, user_secrets, etc.) have any
cliutil coverage. Drop them so the gap can be closed comprehensively
rather than per-table. Tracked in #25389; the original test bodies
remain recoverable from dcdf9cf.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

dannykopping and others added 2 commits May 15, 2026 15:25
…tate

The previous skip condition (!Valid || matches) silently dropped rows
with NULL settings_key_id / api_key_key_id from the rotation loop. That
made the "enable encryption for the first time" path a no-op for any
existing plaintext data, diverging from how user_links, user_secrets,
and chat_providers all handle the same case.

Mirror the chat_providers shape: skip empty/blank values, skip rows
already on the new primary digest, fall through to UpdateEncryptedX
otherwise and let the dbcrypt wrapper encrypt.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ropic

ai_providers.settings is stored as the discriminated
{"_type":"bedrock","_version":1,...} JSON shape (5bfb65f). The
TestAIProviders fixture was using the old flat bedrock_* keys on an
OpenAI-typed provider. Switch the seed to AnthropicProviderType with
the Bedrock base URL so Bedrock-shaped settings only appear where
they're actually meaningful, and update the settings blob (both the
initial value and the UpdateAIProvider sub-test) to the current
discriminated shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dannykopping
dannykopping marked this pull request as ready for review May 15, 2026 13:26
@dannykopping
dannykopping requested a review from johnstcn May 15, 2026 13:26
@dannykopping
dannykopping merged commit 985ae9e into main May 15, 2026
27 checks passed
@dannykopping
dannykopping deleted the dk/aibridge-providers-dbcrypt branch May 15, 2026 13:42
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants