-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(secret-manager): dynamic secret support for proxied services #7288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f448445
feat(secret-manager): dynamic secret support for proxied services
saifsmailbox98 751cdf7
fix(secret-manager): address review for dynamic secret proxied services
saifsmailbox98 8a62091
fix(secret-manager): collect dynamic secret lease inputs once per secret
saifsmailbox98 1a78315
chore(secret-manager): keep dynamic secret field choice generic
saifsmailbox98 6546fde
chore(secret-manager): trim explanatory comments to match codebase style
saifsmailbox98 d2908cd
chore(secret-manager): drop unused schema + unexport in-file-only hel…
saifsmailbox98 742daaf
docs(agent-proxy): fix stale dynamic-secret notes (generic fields, co…
saifsmailbox98 f21aa43
chore(secret-manager): use a real timestamp for the dynamic-secret mi…
saifsmailbox98 d5ca9f3
docs(agent-proxy): document Lease permission for dynamic-secret broke…
saifsmailbox98 d0b1be4
Merge remote-tracking branch 'origin/main' into saif/age2-42-dynamic-…
saifsmailbox98 e30f1b5
chore(secret-manager): cap dynamic secret credential columns with var…
saifsmailbox98 d6a6dc7
fix(secret-manager): don't disclose full principal allowlist in valid…
saifsmailbox98 dc60d35
improvement(secret-manager): submenu-based credential source picker f…
saifsmailbox98 4d267c5
improvement(secret-manager): restrict proxied-service credentials to …
saifsmailbox98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
backend/src/db/migrations/20260715184927_proxied-service-dynamic-secret-credentials.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Knex } from "knex"; | ||
|
|
||
| import { TableName } from "../schemas"; | ||
|
|
||
| export async function up(knex: Knex): Promise<void> { | ||
| const hasDynamicSecretName = await knex.schema.hasColumn(TableName.ProxiedServiceCredential, "dynamicSecretName"); | ||
|
|
||
| await knex.schema.alterTable(TableName.ProxiedServiceCredential, (t) => { | ||
| if (!hasDynamicSecretName) { | ||
| t.text("dynamicSecretName"); | ||
| t.text("dynamicSecretField"); | ||
| t.jsonb("dynamicSecretConfig"); | ||
| } | ||
|
|
||
| t.string("secretKey").nullable().alter(); | ||
| }); | ||
| } | ||
|
|
||
| export async function down(knex: Knex): Promise<void> { | ||
| await knex(TableName.ProxiedServiceCredential).whereNull("secretKey").delete(); | ||
|
|
||
| const hasDynamicSecretName = await knex.schema.hasColumn(TableName.ProxiedServiceCredential, "dynamicSecretName"); | ||
|
|
||
| await knex.schema.alterTable(TableName.ProxiedServiceCredential, (t) => { | ||
| if (hasDynamicSecretName) { | ||
| t.dropColumn("dynamicSecretName"); | ||
| t.dropColumn("dynamicSecretField"); | ||
| t.dropColumn("dynamicSecretConfig"); | ||
| } | ||
| t.string("secretKey").notNullable().alter(); | ||
| }); | ||
| } | ||
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
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
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
52 changes: 52 additions & 0 deletions
52
backend/src/ee/services/dynamic-secret/providers/dynamic-secret-provider-outputs.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { DYNAMIC_SECRET_PROVIDER_OUTPUTS } from "./dynamic-secret-provider-outputs"; | ||
| import { DynamicSecretProviders } from "./models"; | ||
|
|
||
| describe("DYNAMIC_SECRET_PROVIDER_OUTPUTS", () => { | ||
| it("has an entry for every provider", () => { | ||
| Object.values(DynamicSecretProviders).forEach((provider) => { | ||
| expect(DYNAMIC_SECRET_PROVIDER_OUTPUTS[provider]).toBeDefined(); | ||
| }); | ||
| }); | ||
|
|
||
| it("lists at least one output field for every provider (nothing is force-hidden)", () => { | ||
| Object.values(DynamicSecretProviders).forEach((provider) => { | ||
| expect(DYNAMIC_SECRET_PROVIDER_OUTPUTS[provider].outputFields.length).toBeGreaterThan(0); | ||
| }); | ||
| }); | ||
|
|
||
| it("exposes ssh key/cert fields for injection (e.g. into a request body)", () => { | ||
| expect(DYNAMIC_SECRET_PROVIDER_OUTPUTS[DynamicSecretProviders.Ssh].outputFields).toEqual([ | ||
| "PRIVATE_KEY", | ||
| "SIGNED_KEY" | ||
| ]); | ||
| }); | ||
|
|
||
| it("keeps the lowercase output-field oddballs verbatim", () => { | ||
| expect(DYNAMIC_SECRET_PROVIDER_OUTPUTS[DynamicSecretProviders.AzureEntraID].outputFields).toEqual([ | ||
| "email", | ||
| "password" | ||
| ]); | ||
| expect(DYNAMIC_SECRET_PROVIDER_OUTPUTS[DynamicSecretProviders.Couchbase].outputFields).toEqual([ | ||
| "username", | ||
| "password" | ||
| ]); | ||
| }); | ||
|
|
||
| it("only attaches a lease config schema to kubernetes and ssh", () => { | ||
| Object.values(DynamicSecretProviders).forEach((provider) => { | ||
| const { leaseConfigSchema } = DYNAMIC_SECRET_PROVIDER_OUTPUTS[provider]; | ||
| if (provider === DynamicSecretProviders.Kubernetes || provider === DynamicSecretProviders.Ssh) { | ||
| expect(leaseConfigSchema).toBeDefined(); | ||
| } else { | ||
| expect(leaseConfigSchema).toBeUndefined(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| it("validates the kubernetes namespace lease config", () => { | ||
| const schema = DYNAMIC_SECRET_PROVIDER_OUTPUTS[DynamicSecretProviders.Kubernetes].leaseConfigSchema!; | ||
| expect(schema.safeParse({ namespace: "prod" }).success).toBe(true); | ||
| expect(schema.safeParse({}).success).toBe(true); | ||
| expect(schema.safeParse({ unknown: "x" }).success).toBe(false); | ||
| }); | ||
| }); |
55 changes: 55 additions & 0 deletions
55
backend/src/ee/services/dynamic-secret/providers/dynamic-secret-provider-outputs.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| import { DynamicSecretProviders } from "./models"; | ||
|
|
||
| // keep field names in sync with the frontend mirror at frontend/src/hooks/api/dynamicSecret/providerOutputs.ts | ||
|
|
||
| type TDynamicSecretProviderOutputEntry = { | ||
| outputFields: string[]; | ||
| leaseConfigSchema?: z.ZodTypeAny; | ||
| }; | ||
|
|
||
| const DynamicSecretKubernetesLeaseConfigSchema = z.object({ namespace: z.string().trim().min(1).optional() }).strict(); | ||
|
|
||
| const DynamicSecretSshLeaseConfigSchema = z | ||
| .object({ principals: z.array(z.string().trim().min(1)).optional() }) | ||
| .strict(); | ||
|
|
||
| const DB_USER_PASS = ["DB_USERNAME", "DB_PASSWORD"]; | ||
|
|
||
| export const DYNAMIC_SECRET_PROVIDER_OUTPUTS: Record<DynamicSecretProviders, TDynamicSecretProviderOutputEntry> = { | ||
| [DynamicSecretProviders.SqlDatabase]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Clickhouse]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Cassandra]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.AwsIam]: { outputFields: ["ACCESS_KEY", "SECRET_ACCESS_KEY", "SESSION_TOKEN", "USERNAME"] }, | ||
|
saifsmailbox98 marked this conversation as resolved.
|
||
| [DynamicSecretProviders.Redis]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.AwsElastiCache]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.AwsMemoryDb]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.MongoAtlas]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.ElasticSearch]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.MongoDB]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.RabbitMq]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.AzureEntraID]: { outputFields: ["email", "password"] }, | ||
| [DynamicSecretProviders.AzureSqlDatabase]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Ldap]: { outputFields: ["USERNAME", "PASSWORD", "DN_ARRAY"] }, | ||
| [DynamicSecretProviders.SapHana]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Snowflake]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Totp]: { outputFields: ["TOTP", "TIME_REMAINING"] }, | ||
| [DynamicSecretProviders.SapAse]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Kubernetes]: { | ||
| outputFields: ["TOKEN"], | ||
| leaseConfigSchema: DynamicSecretKubernetesLeaseConfigSchema | ||
| }, | ||
| [DynamicSecretProviders.Vertica]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.GcpIam]: { outputFields: ["SERVICE_ACCOUNT_EMAIL", "TOKEN"] }, | ||
| [DynamicSecretProviders.Github]: { | ||
|
saifsmailbox98 marked this conversation as resolved.
|
||
| outputFields: ["TOKEN", "EXPIRES_AT", "PERMISSIONS", "REPOSITORY_SELECTION"] | ||
| }, | ||
| [DynamicSecretProviders.Couchbase]: { outputFields: ["username", "password"] }, | ||
| [DynamicSecretProviders.Milvus]: { outputFields: DB_USER_PASS }, | ||
| [DynamicSecretProviders.Ssh]: { | ||
| outputFields: ["PRIVATE_KEY", "SIGNED_KEY"], | ||
| leaseConfigSchema: DynamicSecretSshLeaseConfigSchema | ||
| }, | ||
| [DynamicSecretProviders.IbmApiConnect]: { outputFields: ["CLIENT_ID", "CLIENT_SECRET"] } | ||
| }; | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.