Bust auth creds cache after saving workforce/smtp integrations
After a successful PUT to /integrations/workforce or /integrations/smtp, fire-and-forget POST to auth's /internal/cache-bust so credential changes (including default location) propagate instantly without a container restart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
71650ed904
commit
558cce44fa
1 changed files with 14 additions and 0 deletions
|
|
@ -5,6 +5,17 @@ import { INTEGRATIONS, MASKED } from '../integrations/schema.js'
|
||||||
import { testConnection as newbookTest, fetchSiteList } from '../integrations/newbook.js'
|
import { testConnection as newbookTest, fetchSiteList } from '../integrations/newbook.js'
|
||||||
import { testConnection as resosTest } from '../integrations/resos.js'
|
import { testConnection as resosTest } from '../integrations/resos.js'
|
||||||
|
|
||||||
|
const AUTH_URL = process.env.AUTH_URL || 'http://10.10.10.101:3001'
|
||||||
|
|
||||||
|
function bustAuthCache() {
|
||||||
|
const secret = process.env.SETTINGS_SECRET || ''
|
||||||
|
fetch(`${AUTH_URL}/api/auth/internal/cache-bust`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { Authorization: `Bearer ${secret}` },
|
||||||
|
signal: AbortSignal.timeout(3000),
|
||||||
|
}).catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
function decryptSecrets(row) {
|
function decryptSecrets(row) {
|
||||||
if (!row.secrets) return {}
|
if (!row.secrets) return {}
|
||||||
try { return JSON.parse(decrypt(row.secrets)) } catch { return {} }
|
try { return JSON.parse(decrypt(row.secrets)) } catch { return {} }
|
||||||
|
|
@ -76,6 +87,9 @@ export async function integrationRoutes(app) {
|
||||||
`, [slug, schema.name, config, secretsEnc, enabled])
|
`, [slug, schema.name, config, secretsEnc, enabled])
|
||||||
|
|
||||||
const { rows: [updated] } = await pool.query('SELECT * FROM integrations WHERE slug = $1', [slug])
|
const { rows: [updated] } = await pool.query('SELECT * FROM integrations WHERE slug = $1', [slug])
|
||||||
|
|
||||||
|
if (slug === 'workforce' || slug === 'smtp') bustAuthCache()
|
||||||
|
|
||||||
return maskRow(updated)
|
return maskRow(updated)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue