feat: Add pluggable secret providers (1Password, Infisical, HashiCorp Vault) (#1360)
* Add pluggable secret provider foundation
Introduces a provider-agnostic secret backend abstraction so stacks can
pull deploy-time secrets from 1Password, Infisical or HashiCorp Vault.
Providers implement the SecretProvider contract in secretproviders/shared.ts
and advertise which of the two resolution modes they support:
- reference interpolation: a variable's value is an inline reference in
the backend's own syntax (e.g. 1Password's op://vault/item/field)
- bulk pull: every secret under a provider-defined selector, fetched as
a flat key/value map
Adding a backend means dropping a file in secretproviders/ and registering
it in the index; no caller changes.
Four providers ship here: 1Password service account (references + bulk),
1Password Connect (references), Infisical (bulk) and HashiCorp Vault KV v2
(bulk). Provider config is persisted as an encrypted JSON blob in the new
secret_providers table, mirroring the existing notification_settings
type+config pattern, and stack_sources gains a nullable secret_provider_id.
Decrypted tokens stay in the provider modules for the duration of a call
and are never written to disk or returned to the client.
Co-authored-by: GooRoo <sergey.olendarenko@gmail.com>
* Add secret provider API routes and permissions
CRUD plus two test-connection endpoints under /api/secret-providers. The
unsaved variant validates a config posted from the provider form; the
stored variant tests a persisted provider by id.
Responses only ever carry provider summaries (id, type, name, timestamps).
The decrypted config never leaves the server.
Adds a "secrets" permission resource with view/create/edit/delete actions,
wired through the permission type, the role editor and the seeded roles,
and a secret_provider audit entity type so provider changes are logged.
Config rotations are audited as a boolean rather than a value.
* Resolve provider secrets at stack deploy time
Stacks can bind a secret provider; when one is bound, its secrets are
resolved and merged into the vars handed to docker compose.
Bulk pull is triggered by a selector variable: OP_ENVIRONMENT_ID, kept for
compatibility with the original 1Password integration, or the generic
DOCKHAND_SECRET_SELECTOR for any bulk-capable provider. The selector is
consumed by the provider and stripped before the vars reach the stack.
Values the bound provider recognises as inline references are resolved in
place, and references found only in the stack's .env file are promoted into
the secret set so they are never written back as literals.
Resolution is applied on deploy, on up, on recreate and on service update.
Explicitly configured secrets always win over bulk-pulled ones. A missing
or unsupported provider warns and leaves values untouched rather than
failing the deploy; a provider that errors mid-resolution fails it.
* Add secret provider settings UI and stack binding
A Secrets tab under settings lists configured providers and drives the
create/edit modal, which switches its fields on the selected provider type
and can test a connection before saving.
Both stack modals gain a provider selector so a stack can be bound to a
provider or left unbound. When a provider is bound, the bulk selector
variables are no longer reported as unused compose variables, since they
are consumed by the provider rather than the compose file.
---------
Co-authored-by: GooRoo <sergey.olendarenko@gmail.com>
Co-authored-by: Jarek Krochmalski <jotka@users.noreply.github.com>
This commit is contained in:
39 files changed
+3094
-31
No files matched your search
@@ -775,7 +775,8 @@ async function seedDatabase(): Promise<void> {
|
||||
audit_logs: ['view'],
|
||||
activity: ['view'],
|
||||
schedules: ['view', 'edit', 'run'],
|
||||
templates: ['view', 'deploy', 'manage']
|
||||
templates: ['view', 'deploy', 'manage'],
|
||||
secrets: ['view', 'create', 'edit', 'delete']
|
||||
});
|
||||
|
||||
const operatorPermissions = JSON.stringify({
|
||||
@@ -795,7 +796,8 @@ async function seedDatabase(): Promise<void> {
|
||||
audit_logs: [],
|
||||
activity: ['view'],
|
||||
schedules: ['view', 'edit', 'run'],
|
||||
templates: ['view', 'deploy']
|
||||
templates: ['view', 'deploy'],
|
||||
secrets: ['view']
|
||||
});
|
||||
|
||||
const viewerPermissions = JSON.stringify({
|
||||
@@ -815,7 +817,8 @@ async function seedDatabase(): Promise<void> {
|
||||
audit_logs: [],
|
||||
activity: ['view'],
|
||||
schedules: ['view'],
|
||||
templates: ['view']
|
||||
templates: ['view'],
|
||||
secrets: [],
|
||||
});
|
||||
|
||||
// Seed template sources if table is empty
|
||||
@@ -920,6 +923,7 @@ export const userRoles = schemaProxy.userRoles;
|
||||
export const gitCredentials = schemaProxy.gitCredentials;
|
||||
export const gitRepositories = schemaProxy.gitRepositories;
|
||||
export const gitStacks = schemaProxy.gitStacks;
|
||||
export const secretProviders = schemaProxy.secretProviders;
|
||||
export const stackSources = schemaProxy.stackSources;
|
||||
export const vulnerabilityScans = schemaProxy.vulnerabilityScans;
|
||||
export const auditLogs = schemaProxy.auditLogs;
|
||||
@@ -968,6 +972,8 @@ export type {
|
||||
NewGitRepository,
|
||||
GitStack,
|
||||
NewGitStack,
|
||||
SecretProviderRow,
|
||||
NewSecretProviderRow,
|
||||
StackSource,
|
||||
NewStackSource,
|
||||
VulnerabilityScan,
|
||||
|
||||
@@ -282,6 +282,19 @@ export const gitCredentials = sqliteTable('git_credentials', {
|
||||
updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`)
|
||||
});
|
||||
|
||||
// Pluggable secret providers (1Password, Infisical, HashiCorp Vault, ...).
|
||||
// `type` selects the backend; `config` is an encrypted JSON blob whose shape is
|
||||
// provider-specific (see src/lib/server/secretproviders/shared.ts). Mirrors the
|
||||
// notification_settings type+config pattern.
|
||||
export const secretProviders = sqliteTable('secret_providers', {
|
||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
||||
type: text('type').notNull(),
|
||||
name: text('name').notNull().unique(),
|
||||
config: text('config').notNull(),
|
||||
createdAt: text('created_at').default(sql`CURRENT_TIMESTAMP`),
|
||||
updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`)
|
||||
});
|
||||
|
||||
export const gitRepositories = sqliteTable('git_repositories', {
|
||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
||||
name: text('name').notNull().unique(),
|
||||
@@ -340,6 +353,7 @@ export const stackSources = sqliteTable('stack_sources', {
|
||||
gitStackId: integer('git_stack_id').references(() => gitStacks.id, { onDelete: 'set null' }),
|
||||
composePath: text('compose_path'), // Custom path to compose file (for stacks with non-default location)
|
||||
envPath: text('env_path'), // Custom path to .env file (for stacks with non-default location)
|
||||
secretProviderId: integer('secret_provider_id').references(() => secretProviders.id, { onDelete: 'set null' }),
|
||||
createdAt: text('created_at').default(sql`CURRENT_TIMESTAMP`),
|
||||
updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`)
|
||||
}, (table) => ({
|
||||
@@ -611,6 +625,9 @@ export type NewEnvironmentNotification = typeof environmentNotifications.$inferI
|
||||
export type GitCredential = typeof gitCredentials.$inferSelect;
|
||||
export type NewGitCredential = typeof gitCredentials.$inferInsert;
|
||||
|
||||
export type SecretProviderRow = typeof secretProviders.$inferSelect;
|
||||
export type NewSecretProviderRow = typeof secretProviders.$inferInsert;
|
||||
|
||||
export type GitRepository = typeof gitRepositories.$inferSelect;
|
||||
export type NewGitRepository = typeof gitRepositories.$inferInsert;
|
||||
|
||||
|
||||
@@ -285,6 +285,19 @@ export const gitCredentials = pgTable('git_credentials', {
|
||||
updatedAt: timestamp('updated_at', { mode: 'string' }).defaultNow()
|
||||
});
|
||||
|
||||
// Pluggable secret providers (1Password, Infisical, HashiCorp Vault, ...).
|
||||
// `type` selects the backend; `config` is an encrypted JSON blob whose shape is
|
||||
// provider-specific (see src/lib/server/secretproviders/shared.ts). Mirrors the
|
||||
// notification_settings type+config pattern.
|
||||
export const secretProviders = pgTable('secret_providers', {
|
||||
id: serial('id').primaryKey(),
|
||||
type: text('type').notNull(),
|
||||
name: text('name').notNull().unique(),
|
||||
config: text('config').notNull(),
|
||||
createdAt: timestamp('created_at', { mode: 'string' }).defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { mode: 'string' }).defaultNow()
|
||||
});
|
||||
|
||||
export const gitRepositories = pgTable('git_repositories', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull().unique(),
|
||||
@@ -343,6 +356,7 @@ export const stackSources = pgTable('stack_sources', {
|
||||
gitStackId: integer('git_stack_id').references(() => gitStacks.id, { onDelete: 'set null' }),
|
||||
composePath: text('compose_path'), // Custom path to compose file (for stacks with non-default location)
|
||||
envPath: text('env_path'), // Custom path to .env file (for stacks with non-default location)
|
||||
secretProviderId: integer('secret_provider_id').references(() => secretProviders.id, { onDelete: 'set null' }),
|
||||
createdAt: timestamp('created_at', { mode: 'string' }).defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { mode: 'string' }).defaultNow()
|
||||
}, (table) => ({
|
||||
|
||||
Reference in new issue
Block a user