Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ dist/
downloads/
eggs/
.eggs/
/lib/
lib64/
parts/
sdist/
Expand Down
1 change: 0 additions & 1 deletion gotrue/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dist/
downloads/
eggs/
.eggs/
/lib/
lib64/
parts/
sdist/
Expand Down
1 change: 0 additions & 1 deletion gotrue/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
__version__ = '0.2.0'

from . import lib
from . import api
from . import client
from .client import Client
Empty file added gotrue/lib/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions gotrue/lib/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GOTRUE_URL = 'http://localhost:9999'
AUDIENCE = ''
DEFAULT_HEADERS = {}
EXPIRY_MARGIN = 60 * 1000
STORAGE_KEY = 'supabase.auth.token'
COOKIE_OPTIONS = {
"name": 'sb:token',
"lifetime": 60 * 60 * 8,
"domain": '',
"path": '/',
"sameSite": 'lax',
}
87 changes: 78 additions & 9 deletions infra/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,99 @@
# docker-compose.yml
version: '3'
services:
gotrue:
gotrue: # Signup enabled, autoconfirm off
image: supabase/gotrue:latest
ports:
- '9999:9999'
environment:
GOTRUE_JWT_SECRET: "37c304f8-51aa-419a-a1af-06154e63707a"
GOTRUE_MAILER_URLPATHS_CONFIRMATION: '/verify'
GOTRUE_JWT_SECRET: '37c304f8-51aa-419a-a1af-06154e63707a'
GOTRUE_JWT_EXP: 3600
GOTRUE_DB_DRIVER: postgres
DB_NAMESPACE: auth
API_EXTERNAL_URL: http://localhost
GOTRUE_API_HOST: 0.0.0.0
PORT: 9999
GOTRUE_DISABLE_SIGNUP: "false"
GOTRUE_SITE_URL: http://localhost
GOTRUE_MAILER_AUTOCONFIRM: "true"
GOTRUE_DISABLE_SIGNUP: 'false'
API_EXTERNAL_URL: http://localhost:9999
GOTRUE_SITE_URL: http://localhost:9999
GOTRUE_URI_ALLOW_LIST: https://supabase.io/docs
GOTRUE_MAILER_AUTOCONFIRM: 'false'
GOTRUE_LOG_LEVEL: DEBUG
GOTRUE_OPERATOR_TOKEN: super-secret-operator-token
DATABASE_URL: "postgres://postgres:postgres@db:5432/postgres?sslmode=disable"
GOTRUE_EXTERNAL_GOOGLE_ENABLED: "true"
DATABASE_URL: 'postgres://postgres:postgres@db:5432/postgres?sslmode=disable'
GOTRUE_EXTERNAL_GOOGLE_ENABLED: 'true'
GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID: 53566906701-bmhc1ndue7hild39575gkpimhs06b7ds.apps.googleusercontent.com
GOTRUE_EXTERNAL_GOOGLE_SECRET: Sm3s8RE85rDcS36iMy8YjrpC
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI: http://localhost:9999/callback
GOTRUE_SMTP_HOST: mail
GOTRUE_SMTP_PORT: 2500
GOTRUE_SMTP_USER: GOTRUE_SMTP_USER
GOTRUE_SMTP_PASS: GOTRUE_SMTP_PASS
GOTRUE_SMTP_ADMIN_EMAIL: admin@email.com
GOTRUE_MAILER_SUBJECTS_CONFIRMATION: 'Please confirm'
GOTRUE_EXTERNAL_PHONE_ENABLED: 'true'
GOTRUE_SMS_PROVIDER: "twilio"
GOTRUE_SMS_TWILIO_ACCOUNT_SID: "${GOTRUE_SMS_TWILIO_ACCOUNT_SID}"
GOTRUE_SMS_TWILIO_AUTH_TOKEN: "${GOTRUE_SMS_TWILIO_AUTH_TOKEN}"
GOTRUE_SMS_TWILIO_MESSAGE_SERVICE_SID: "${GOTRUE_SMS_TWILIO_MESSAGE_SERVICE_SID}"
GOTRUE_SMS_AUTOCONFIRM: 'false'
depends_on:
- db
restart: on-failure
autoconfirm: # Signup enabled, autoconfirm on
image: supabase/gotrue:latest
ports:
- '9998:9998'
environment:
GOTRUE_JWT_SECRET: '37c304f8-51aa-419a-a1af-06154e63707a'
GOTRUE_JWT_EXP: 3600
GOTRUE_DB_DRIVER: postgres
DB_NAMESPACE: auth
GOTRUE_API_HOST: 0.0.0.0
PORT: 9998
GOTRUE_DISABLE_SIGNUP: 'false'
API_EXTERNAL_URL: http://localhost:9998
GOTRUE_SITE_URL: http://localhost:9998
GOTRUE_MAILER_AUTOCONFIRM: 'true'
GOTRUE_SMS_AUTOCONFIRM: 'true'
GOTRUE_LOG_LEVEL: DEBUG
GOTRUE_OPERATOR_TOKEN: super-secret-operator-token
DATABASE_URL: 'postgres://postgres:postgres@db:5432/postgres?sslmode=disable'
GOTRUE_EXTERNAL_PHONE_ENABLED: 'true'
GOTRUE_SMS_AUTOCONFIRM: 'true'
depends_on:
- db
restart: on-failure
disabled: # Signup disabled
image: supabase/gotrue:latest
ports:
- '9997:9997'
environment:
GOTRUE_JWT_SECRET: '37c304f8-51aa-419a-a1af-06154e63707a'
GOTRUE_JWT_EXP: 3600
GOTRUE_DB_DRIVER: postgres
DB_NAMESPACE: auth
GOTRUE_API_HOST: 0.0.0.0
PORT: 9997
GOTRUE_DISABLE_SIGNUP: 'true'
GOTRUE_ENABLE_SIGNUP: 'false'
API_EXTERNAL_URL: http://localhost:9997
GOTRUE_SITE_URL: http://localhost:9997
GOTRUE_MAILER_AUTOCONFIRM: 'false'
GOTRUE_LOG_LEVEL: DEBUG
GOTRUE_OPERATOR_TOKEN: super-secret-operator-token
DATABASE_URL: 'postgres://postgres:postgres@db:5432/postgres?sslmode=disable'
GOTRUE_EXTERNAL_PHONE_ENABLED: 'false'
GOTRUE_EXTERNAL_EMAIL_ENABLED: 'false'
depends_on:
- db
restart: on-failure
mail:
image: phamhieu/inbucket:latest
ports:
- '2500:2500' # SMTP
- '9000:9000' # web interface
- '1100:1100' # POP3
db:
image: supabase/postgres
ports:
Expand All @@ -35,4 +104,4 @@ services:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_PORT: 5432
25 changes: 19 additions & 6 deletions tests/test_gotrue.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from gotrue.lib.constants import GOTRUE_URL
from gotrue.client import Client
import os
import random
Expand All @@ -9,7 +10,8 @@

def _random_string(length: int = 10) -> str:
"""Generate random string."""
return "".join(random.choices(string.ascii_uppercase + string.digits, k=length))
return "".join(
random.choices(string.ascii_uppercase + string.digits, k=length))


def _assert_authenticated_user(data: Dict[str, Any]):
Expand All @@ -29,11 +31,22 @@ def client():

supabase_url: str = os.environ.get("SUPABASE_TEST_URL")
supabase_key: str = os.environ.get("SUPABASE_TEST_KEY")
url: str = f"{supabase_url}/auth/v1"
return Client(
url=url,
headers={"apiKey": supabase_key, "Authorization": f"Bearer {supabase_key}"},
)
if supabase_url and supabase_key:
url: str = f"{supabase_url}/auth/v1"
return Client(
url=url,
headers={
"apiKey": supabase_key,
"Authorization": f"Bearer {supabase_key}"
},
)
else:
return Client(
url=GOTRUE_URL,
headers={
"Authorization":
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwicm9sZSI6InN1cGFiYXNlX2FkbWluIiwiaWF0IjoxNTE2MjM5MDIyfQ.0sOtTSTfPv5oPZxsjvBO249FI4S4p0ymHoIZ6H6z9Y8"
})


def test_user_auth_flow(client: Client):
Expand Down