Skip to content

feat: add Slack OAuth admin authentication - #46

Open
DJCrossman wants to merge 1 commit into
mainfrom
feat/admin-01-auth
Open

feat: add Slack OAuth admin authentication#46
DJCrossman wants to merge 1 commit into
mainfrom
feat/admin-01-auth

Conversation

@DJCrossman

Copy link
Copy Markdown
Contributor

Stack 1/4 — foundation for the Eventbrite admin dashboard. Next: Eventbrite data layer → events list UI → event detail with show-up predictions.

Summary

  • Slack OIDC sign-in via next-auth@5.0.0-beta.32 (pinned exactly; peer-supports Next 16). JWT sessions (12h), no database.
  • Admin-only: the signIn callback verifies the id_token's https://slack.com/team_id claim against SLACK_TEAM_ID, then calls users.info with the bot token and only allows is_admin || is_owner || is_primary_owner. Fails closed on any error.
  • proxy.ts (Next 16's middleware convention) guards /admin/:path* and /api/admin/:path* — pages redirect to /admin/login?callbackUrl=…, APIs get 401 JSON. requireAdmin() / requireAdminOrRedirect() in lib/adminAuth.ts provide a second, defense-in-depth check used by the admin layout (and by admin API routes in the next PR).
  • /admin/login: server-action "Sign in with Slack" button; shows the access-denied message for signed-in non-admins; sanitizes callbackUrl (must start with /).
  • /admin: placeholder shell (replaced by the events list in PR 3/4).

Configuration (already done on the Slack app "HackRegina" A04G3FDT4TU)

  • Redirect URLs: https://hackregina.com/api/auth/callback/slack, https://localhost:3000/api/auth/callback/slack
  • Bot scope users:read added + reinstall
  • New env vars (local + production): AUTH_SECRET, AUTH_SLACK_ID, AUTH_SLACK_SECRET, SLACK_TEAM_ID (+ AUTH_URL=https://localhost:3000 for local HTTPS dev only)

Note: Vercel preview deployments cannot complete Slack OAuth (redirect URLs must be pre-registered), so sign-in is testable locally (bun run dev:https) and on production.

Test plan

  • bun run lint / bun run build pass
  • Logged out: /admin → 307 /admin/login?callbackUrl=%2Fadmin; /api/admin/* → 401 {"error":"Unauthorized"}; /, /events, /techmap unaffected
  • Browser (needs Slack app creds in env): admin sign-in lands on /admin; sign-out returns to login; non-admin gets the AccessDenied message

🤖 Generated with Claude Code

Adds next-auth v5 (pinned beta) with the Slack OIDC provider. Only
administrators of the HackRegina Slack workspace can sign in: the signIn
callback verifies the workspace team id and checks is_admin/is_owner via
users.info (requires the bot token to have users:read). Sessions are
stateless JWTs (12h), so no database is needed.

- proxy.ts protects /admin/* and /api/admin/*: pages redirect to
  /admin/login, APIs get 401 JSON
- requireAdmin()/requireAdminOrRedirect() in lib/adminAuth.ts give admin
  routes and layouts a second, defense-in-depth check
- /admin/login renders a Sign in with Slack button and the AccessDenied
  message for non-admins
- /admin is a placeholder shell replaced by the events list in a
  follow-up PR
- Slack requires HTTPS redirect URLs, so local dev uses bun run dev:https

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
website Ready Ready Preview Aug 21, 2026 5:06pm

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