Skip to content

feat(dashboard-api): move Slack secrets to Secrets Manager - #446

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/slack-secrets-manager
Jul 26, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/slack-secrets-manager

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Why

The Slack client_secret + signing_secret were plaintext Lambda environment variables — readable by anyone with lambda:GetFunctionConfiguration and surfaced in the console/CLI. (Found while surveying dashboard-api for the portal Slack surface.) This moves them into a single Secrets Manager secret; the exec role gets secretsmanager:GetSecretValue on just that ARN.

What

  • slack_secrets.go — loadSlackSecrets() (a sync.Once cache) reads the secret named by SLACK_SECRETS_ARN (JSON {"client_secret","signing_secret"}), fetched once per cold start (these are app-level, effectively static creds — no per-request call). Accessors slackClientSecret() / slackSigningSecret().
  • mergeSlackSecrets() — pure parse + precedence helper, unit-tested: a non-empty field in the secret wins; an absent/empty field keeps the env fallback; malformed JSON returns the fallback untouched with an error.
  • Swapped all 5 functional callsites (OAuth callback, token rotate, workspace store, HMAC state signer, token refresh) from os.Getenv to the accessors.

Backward-compatible by design

With SLACK_SECRETS_ARN unset, it falls back to the existing env vars. So this code deploys before the secret is wired, and the plaintext env vars are removed only after — no flag-day, no Slack downtime. Deploy sequence: create secret → grant role → deploy this code → set SLACK_SECRETS_ARN → remove the two plaintext env vars.

Tests

slack_secrets_test.go covers the merge precedence (both/partial/empty-field/empty-object/malformed). go build ./... + go test ./... green.

…ack)

The Slack client_secret + signing_secret were PLAINTEXT Lambda environment
variables — readable by anyone with lambda:GetFunctionConfiguration and
surfaced in the console/CLI. Move them into a single Secrets Manager secret
(ARN via SLACK_SECRETS_ARN), fetched once per cold start and cached; the exec
role gets secretsmanager:GetSecretValue on just that ARN.

- slack_secrets.go: loadSlackSecrets() (sync.Once cache) reads the secret JSON
  {"client_secret","signing_secret"} and layers it over the legacy env vars;
  slackClientSecret()/slackSigningSecret() accessors.
- mergeSlackSecrets(): pure parse+precedence helper, unit-tested (secret wins
  when non-empty; env fallback for absent/empty fields; malformed JSON → error
  + fallback untouched).
- Swapped all 5 functional callsites (OAuth callback, token rotate, workspace
  store, HMAC state signer, token refresh) from os.Getenv to the accessors.

Backward-compatible by design: with SLACK_SECRETS_ARN unset it falls back to
the existing env vars, so this code deploys BEFORE the secret is wired and the
plaintext env vars are removed only AFTER — no flag-day, no Slack downtime.
@scttfrdmn
scttfrdmn merged commit 6cbb952 into main Jul 26, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/slack-secrets-manager branch July 26, 2026 16:59
scttfrdmn added a commit that referenced this pull request Jul 28, 2026
Backfills Unreleased entries for #443 (spawn onboard), #444, #445 and #446,
which merged without changelog entries, and commits the generated reference
for spawn onboard — check-docs only diffs tracked files, so docs-gen/onboard.md
was never added when the command landed.

Sections reordered to Keep-a-Changelog order (Added first), matching prior
releases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant