Skip to content

feat: add ALLOWED_SPOTIFY_IDS login allowlist#211

Merged
cdtinney merged 2 commits into
mainfrom
cdtinney/login-allowlist
Apr 29, 2026
Merged

feat: add ALLOWED_SPOTIFY_IDS login allowlist#211
cdtinney merged 2 commits into
mainfrom
cdtinney/login-allowlist

Conversation

@cdtinney
Copy link
Copy Markdown
Owner

Summary

Mirrors the existing ADMIN_SPOTIFY_IDS pattern with a parallel ALLOWED_SPOTIFY_IDS env var that gates OAuth login itself. When set, the verify callback rejects unknown Spotify IDs (no user row created, redirect to the login page). When unset or empty, login stays open to anyone with a Spotify account — so this is a no-op for prod until the env var is added.

Primary use case: lock down staging without standing up Caddy basic_auth or an external identity provider.

Testing

  • New unit tests for isLoginAllowed covering unset, empty, whitespace-only, hit, miss, and dirty-formatting cases
  • New passportStrategy tests verifying that rejected logins call done(null, false) without invoking findOrCreateUser, and that allowlisted IDs still flow through normally
  • pnpm --filter spune-server test --run passes all 27 files / 92 tests
  • pnpm server:lint and the server type check are clean
  • After merge, set on the droplet and restart staging:
    echo "ALLOWED_SPOTIFY_IDS=cdtinney" >> /opt/spune-staging/.env
    cd /opt/spune-staging && docker compose restart staging-app

Mirrors the existing ADMIN_SPOTIFY_IDS pattern: when set, the OAuth
verify callback rejects users whose Spotify ID isn't on the list and
no user row is created. Unset/empty preserves the current open-login
behavior so this is a no-op for prod until the env var is added.

Primary use case is locking down staging without involving Caddy
basic_auth or a separate identity provider.
Inline comment in the verify callback to make it obvious that locking
down staging via .env doesn't affect prod, since each Compose stack
loads its own .env file.
@cdtinney cdtinney merged commit 995c2c1 into main Apr 29, 2026
6 checks passed
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