Quickstarty
Quickstart: Auth
Rejestracja i logowanie użytkowników z supabase-js w 3 krokach.
Auth (GoTrue) działa w każdym projekcie: e-mail + hasło, magic link, OAuth, MFA i passkeys.
Zmienne w przykładach: $HOSTBASE_TOKEN (token dostępu), $REF (ref projektu). SDK: @hostbase/management (TypeScript) i hostbase_management (Python), pełne API: /docs/api.
1. Zarejestruj użytkownika
Użyj klucza anon projektu.
curl -X POST https://abcdefghijklmnopqrst.host.ulewicz.space/auth/v1/signup -H "apikey: $ANON_KEY" -H "Content-Type: application/json" \
-d '{"email":"jan@example.com","password":"correct-horse-battery"}'const { data, error } = await supabase.auth.signUp({ email: "jan@example.com", password: "correct-horse-battery" });supabase.auth.sign_up({"email": "jan@example.com", "password": "correct-horse-battery"})hostbase db query "select count(*) from auth.users"2. Zaloguj
Odpowiedź zawiera access_token (JWT) do wywołań REST z RLS.
curl -X POST "https://abcdefghijklmnopqrst.host.ulewicz.space/auth/v1/token?grant_type=password" -H "apikey: $ANON_KEY" -H "Content-Type: application/json" \
-d '{"email":"jan@example.com","password":"correct-horse-battery"}'const { data } = await supabase.auth.signInWithPassword({ email: "jan@example.com", password: "correct-horse-battery" });session = supabase.auth.sign_in_with_password({"email": "jan@example.com", "password": "correct-horse-battery"})3. Zabezpiecz dane RLS
Polityka pozwala czytać tylko własne wiersze.
hostbase db pushalter table todos add column user_id uuid default auth.uid();
create policy own_rows on todos for select using (user_id = auth.uid());Dalej: /docs/auth, /docs/sso.