-
-
Notifications
You must be signed in to change notification settings - Fork 283
fix: env to control tenant config visibility #989
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,8 @@ DATABASE_MULTITENANT_URL=postgresql://postgres:postgres@127.0.0.1:5433/postgres | |||||||||||||
| DATABASE_MULTITENANT_POOL_URL=postgresql://postgres:postgres@127.0.0.1:6454/postgres | ||||||||||||||
| REQUEST_X_FORWARDED_HOST_REGEXP=^([a-z]{20}).local.(?:com|dev)$ | ||||||||||||||
| SERVER_ADMIN_API_KEYS=apikey | ||||||||||||||
| # When set to false, GET /tenants endpoints omit decrypted secrets (database urls, jwt secret, service key, anon key, jwks). Defaults to true. | ||||||||||||||
| # ADMIN_RETURN_TENANT_SENSITIVE_DATA=true | ||||||||||||||
|
Comment on lines
+36
to
+37
|
||||||||||||||
| # When set to false, GET /tenants endpoints omit decrypted secrets (database urls, jwt secret, service key, anon key, jwks). Defaults to true. | |
| # ADMIN_RETURN_TENANT_SENSITIVE_DATA=true | |
| # When set to false, GET /tenants endpoints omit decrypted secrets (database urls, jwt secret, service key, anon key, jwks). Defaults to true. | |
| # Uses the legacy/current env var name below; `SERVER_ADMIN_RETURN_TENANT_SENSITIVE_DATA` is the convention-aligned equivalent for admin settings. | |
| # ADMIN_RETURN_TENANT_SENSITIVE_DATA=true | |
| # SERVER_ADMIN_RETURN_TENANT_SENSITIVE_DATA=true |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -59,6 +59,7 @@ type StorageConfigType = { | |||||||||||
| headersTimeout: number | ||||||||||||
| adminApiKeys: string | ||||||||||||
| adminRequestIdHeader?: string | ||||||||||||
| adminReturnTenantSensitiveData: boolean | ||||||||||||
| encryptionKey: string | ||||||||||||
| uploadFileSizeLimit: number | ||||||||||||
| uploadFileSizeLimitStandard?: number | ||||||||||||
|
|
@@ -302,6 +303,8 @@ export function getConfig(options?: { reload?: boolean }): StorageConfigType { | |||||||||||
| 'REQUEST_TRACE_HEADER', | ||||||||||||
| 'REQUEST_ADMIN_TRACE_HEADER' | ||||||||||||
| ), | ||||||||||||
| adminReturnTenantSensitiveData: | ||||||||||||
| getOptionalConfigFromEnv('ADMIN_RETURN_TENANT_SENSITIVE_DATA') !== 'false', | ||||||||||||
|
||||||||||||
| getOptionalConfigFromEnv('ADMIN_RETURN_TENANT_SENSITIVE_DATA') !== 'false', | |
| getOptionalConfigFromEnv( | |
| 'SERVER_ADMIN_RETURN_TENANT_SENSITIVE_DATA', | |
| 'ADMIN_RETURN_TENANT_SENSITIVE_DATA' | |
| ) !== 'false', |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,7 +131,8 @@ interface tenantDBInterface { | |
| disable_events?: string[] | null | ||
| } | ||
|
|
||
| const { dbMigrationFreezeAt, icebergEnabled, vectorEnabled } = getConfig() | ||
| const { dbMigrationFreezeAt, icebergEnabled, vectorEnabled, adminReturnTenantSensitiveData } = | ||
| getConfig() | ||
| const migrationQueueName = RunMigrationsOnTenants.getQueueName() | ||
|
|
||
| export default async function routes(fastify: FastifyInstance) { | ||
|
|
@@ -168,15 +169,19 @@ export default async function routes(fastify: FastifyInstance) { | |
| disable_events, | ||
| }) => ({ | ||
| id, | ||
| anonKey: decrypt(anon_key), | ||
| databaseUrl: decrypt(database_url), | ||
| databasePoolUrl: database_pool_url ? decrypt(database_pool_url) : undefined, | ||
| ...(adminReturnTenantSensitiveData | ||
| ? { | ||
| anonKey: decrypt(anon_key), | ||
| databaseUrl: decrypt(database_url), | ||
| databasePoolUrl: database_pool_url ? decrypt(database_pool_url) : undefined, | ||
| jwtSecret: decrypt(jwt_secret), | ||
| jwks, | ||
| serviceKey: decrypt(service_key), | ||
| } | ||
|
Comment on lines
+172
to
+180
|
||
| : {}), | ||
| databasePoolMode: database_pool_mode, | ||
| maxConnections: max_connections ? Number(max_connections) : undefined, | ||
| fileSizeLimit: Number(file_size_limit), | ||
| jwtSecret: decrypt(jwt_secret), | ||
| jwks, | ||
| serviceKey: decrypt(service_key), | ||
| migrationVersion: migrations_version, | ||
| migrationStatus: migrations_status, | ||
| tracingMode: tracing_mode, | ||
|
|
@@ -246,20 +251,24 @@ export default async function routes(fastify: FastifyInstance) { | |
| const capabilities = await getTenantCapabilities(request.params.tenantId) | ||
|
|
||
| return { | ||
| anonKey: decrypt(anon_key), | ||
| databaseUrl: decrypt(database_url), | ||
| databasePoolUrl: | ||
| database_pool_url === null | ||
| ? null | ||
| : database_pool_url | ||
| ? decrypt(database_pool_url) | ||
| : undefined, | ||
| ...(adminReturnTenantSensitiveData | ||
| ? { | ||
| anonKey: decrypt(anon_key), | ||
| databaseUrl: decrypt(database_url), | ||
| databasePoolUrl: | ||
| database_pool_url === null | ||
| ? null | ||
| : database_pool_url | ||
| ? decrypt(database_pool_url) | ||
| : undefined, | ||
| jwtSecret: decrypt(jwt_secret), | ||
| jwks, | ||
| serviceKey: decrypt(service_key), | ||
| } | ||
| : {}), | ||
| databasePoolMode: database_pool_mode, | ||
| maxConnections: max_connections ? Number(max_connections) : undefined, | ||
| fileSizeLimit: Number(file_size_limit), | ||
| jwtSecret: decrypt(jwt_secret), | ||
| jwks, | ||
| serviceKey: decrypt(service_key), | ||
| capabilities, | ||
| features: { | ||
| imageTransformation: { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sample env comment refers to "GET /tenants endpoints" but these routes are part of the admin API (served on the admin port / behind admin API keys). Consider clarifying the comment to avoid implying that the public API exposes this toggle.