mlim-usfca / PersonalKnowledge

https://personal-knowledge.vercel.app
0 stars 0 forks source link

oauth implemenation #19

Closed inhwaS closed 7 months ago

inhwaS commented 7 months ago

We are using Google OAuth credentials for local supabase authentication.

For this implementation, I assuem that You already successfully running dev version of supabase and web UI

If you already running supabase that Hazal created, you need to move .env.local file under web.

  1. Assume that you are under the root folder
  2. copy .env.local into web
    cp ./server/.env.local ./web 
  3. Go to server folder and update supabase configuration
    cd server/supabase 

Paste this content inside of config.toml

[auth.external.google]
enabled = true
client_id = "YOUR_GOOGLE_CREDENTIALS_CLIENT_ID"
# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead:
secret = "YOUR_GOOGLE_CREDENTIALS_SECRET"
# Overrides the default auth redirectUrl.
redirect_uri = "http://localhost:54321/auth/v1/callback"
# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure,
# or any other third-party OIDC providers.
url = ""

replace YOUR_GOOGLE_CREDENTIALS_CLIENT_ID and YOUR_GOOGLE_CREDENTIALS_SECRET into your google oauth credentials. If you don't have any credentials availabe, you can either create your own or I can provide you mine.

If you are using your own credentials, make sure that you properly added authorized javascript and redirect URIs like;

Screenshot 2024-04-02 at 10 17 47 PM

http://localhost:3000 http://localhost:54321/auth/v1/callback

To generate Google Credentials, you can follow this tutorial.

hazalsenturk commented 7 months ago

couple comments after that we are good to merge: 1- in the auth enabled=true 2- google oauth creds should be created with the domain url (which is currently our local) and supabase API url.