Supabase for Backend
Hi everyone,
I’m currently considering building a backend with Swift Vapor and using Supabase for storage and authentication. My question is: Can I use Supabase exclusively on the backend for everything, including user creation and JWT refresh? Or do I still need to integrate Supabase directly into the iOS app for authentication tasks like creating users and refreshing JWT tokens?
9 Replies
Authentication can be handled by supabase and it comes in various ways i.e email/password, oauth social logins via google/supabase, magick link sign in and so on. See this for a full list https://supabase.com/docs/guides/auth
Auth | Supabase Docs
Use Supabase to Authenticate and Authorize your users.
That’s nice. But should the user be created on Front or Backend side?
usually you would use the supabase client to sign up a user on the frontend e.g
where you have a form for email or password and some additional logic to confirm email you don't have to pass the email/password to the backend but if you wanted to do it in a backend you could do
but anything with
admin
uses your service role key which should not be used on the client sideSo in this case, I would just verify the JWT in the backend from Supabase?
you don't have to do jwt verification this is built into supabase. After you sign up a user you can have an email sent to them to confirm which redirects them back to you website and finishes email confirmation. Then the user signs in using
and this creates the bearer token for the user. and sets them to 'authenticated'
now when you interact with the backend the user profile is used and so you would use thing like RLS to restrict what the user can view/edit https://supabase.com/docs/guides/database/postgres/row-level-security
Row Level Security | Supabase Docs
Secure your data using Postgres Row Level Security.
thats for databases but generally you can set policies on all sorts of things like storage buckets (i believe)
So, I’m trying to figure out how to set up Supabase as an authentication provider for my backend. I was wondering if I could just call the sign-in and sign-up methods from the backend, or is there a different flow I should be following?
yeah calling sign in/up/out is one way to go if that is what you want. Users need to confirm their email by default. It explains it more here https://supabase.com/docs/reference/javascript/auth-signup.