Implementing non OpenID custom auth
Hello, I have a website that requires dual auth provider sign ins for a valid session. Previous I would do this with supabase by using their JWT secret to sign my session cookie. This allowed supabase auth to work with my custom authenication system. I was wondering if there was a similar way to do this with Convex?
3 Replies
session utils
https://github.com/test-open-tournaments/2024-website/blob/main/lib/session.ts
first provider
https://github.com/test-open-tournaments/2024-website/blob/main/app/api/auth/callback/osu/route.ts
second provider
https://github.com/test-open-tournaments/2024-website/blob/main/app/api/auth/callback/discord/route.ts
supabase server client
https://github.com/test-open-tournaments/2024-website/blob/main/lib/supabase/server.ts
here's the code from my previous implementation with supabase for referenceEither:
- Don't use ctx.auth, pass your secret/credential as an argument to your function and validate it directly in them
- Do the self-signing trick, after validating credentials issue a JWT that has the Convex backend as the issuer. This is the approach the NextAuth example takes: https://stack.convex.dev/nextauth
Convex with Auth.js (NextAuth)
Learn how to use Auth.js with your Next.js server and Convex backend to build a full-featured authentication system.
Gotcha thanks for the info. The self signing trick looks interesting so I'll look into that.