Skip to content
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

Server-Side Integration with Auth0 #229

Open
4 tasks
mahid797 opened this issue Feb 23, 2025 · 0 comments
Open
4 tasks

Server-Side Integration with Auth0 #229

mahid797 opened this issue Feb 23, 2025 · 0 comments
Assignees
Labels
Backend Backend Related Issue Core Work to do on the core system of the App
Milestone

Comments

@mahid797
Copy link
Collaborator

We will configure NextAuth to conditionally load either CredentialsProvider or Auth0Provider. When AUTH_METHOD=auth0, the app will use Auth0’s Universal Login to authenticate users. We also need to sync user data into Supabase (or at least ensure a user record exists) so that features like roles and collaboration remain consistent.

Goals & Scope

  • Conditionally Add Auth0 Provider based on AUTH_METHOD.
  • Use Universal Login flow (redirect to Auth0, then callback).
  • Create/Update Supabase user records upon successful Auth0 login.
  • Retain Credentials approach when AUTH_METHOD=credentials is set.

Detailed Tasks

  1. Auth0 Environment Variables

    • Accept AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, and AUTH0_ISSUER_BASE_URL.
    • Set AUTH_METHOD=auth0 to enable Auth0 in NextAuthOptions.
  2. NextAuth Configuration

    • In [...nextauth]/route.ts, conditionally add Auth0Provider(...) if AUTH_METHOD=auth0.
    • Remove or comment out any ROPG logic—we are using Universal Login.
  3. User Sync to Supabase

    • Within callbacks.signIn or callbacks.jwt, check if the Auth0 user (via profile or token) already exists in Supabase.
    • If not, create a Supabase user record with the relevant fields (email, name, etc.).
    • Decide if we only sync basic info (name, email) or also handle roles/status.
  4. Testing & Verification

    • Manual test by setting AUTH_METHOD=auth0 locally.
    • Confirm you can log in via Auth0’s hosted page.
    • Confirm a new record appears in Supabase upon first-time login.
  5. Fallback to Credentials

    • When AUTH_METHOD=credentials, verify that the existing login and sign-up flows continue working.

Acceptance Criteria

  • Auth0Provider is successfully added to NextAuth when AUTH_METHOD=auth0.
  • Logging in via Auth0’s Universal Login flow creates/updates Supabase user data.
  • No conflicts with the Credentials-based logic when AUTH_METHOD=credentials.
  • Relevant environment variables (AUTH0_CLIENT_ID, etc.) are documented or at least recognized in code.
@mahid797 mahid797 added New Feature New feature to be implemented Core Work to do on the core system of the App Backend Backend Related Issue and removed New Feature New feature to be implemented labels Feb 23, 2025
@mahid797 mahid797 added this to the v0.1 milestone Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Backend Related Issue Core Work to do on the core system of the App
Projects
None yet
Development

No branches or pull requests

2 participants