Kryat Docs Image

Authentication with Supabase

Authentication with Supabase

KikiWriting uses Supabase Auth for authentication, supporting both server-side authentication with service keys and client-side authentication with JWT tokens.

Understanding Supabase Authentication

Supabase provides two main authentication mechanisms:

  1. Service Role Key (server-side): Has full access to your database, bypassing Row Level Security (RLS)
  2. JWT Authentication (client-side): User-specific tokens that respect Row Level Security policies

Server-Side Authentication with Supabase Secret

Step 1: Configuring Supabase Secret

Store your Supabase secret key in your .env file:

SUPABASE_URL=project-url
SUPABASE_KEY=your-anon-key

Step 2: Validating JWT Tokens

Ensure that you replace your-supabase-url.supabase.co and your-public-anon-key with your actual Supabase project URL and public key.

Client-Side Authentication with JWT Tokens

Using JWT Tokens for Authentication

To authenticate users on the client side, you can use the Supabase client library. Here's an example:

dotnet add package System.IdentityModel.Tokens.Jwt
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer

I will implement a JWT Validate Service and write to the docs later.

On this page