Skip to content

Commit

Permalink
add preliminary CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Lee authored and Joel Lee committed Jan 25, 2021
1 parent 583da03 commit 5cfcae7
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Gotrue-py
**STATUS**: WIP. DO NOT USE
This is a hacky `gotrue-py` client conceived during a very draggy class. The design mirrors that of GoTrue-js
This is a hacky `gotrue-py` client conceived during a very draggy class. The design mirrors that of [GoTrue-js](https://github.com/supabase/gotrue-js/blob/master/infra/db/00-schema.sql)

## TODOs
- [] Support basic methods like auth/signin/signup
Expand Down
2 changes: 0 additions & 2 deletions gotrue_py/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def _request(path, options=[]):
if aud:
options.headers['X-JWT-AUD'] = aud


def settings():
pass

Expand Down Expand Up @@ -61,7 +60,6 @@ def currentUser():

def verify(type, token, remember):
requests.post("https://distracted-elion-6bf6a2.netlify.app/.netlify/identity/verify",data=json.dumps({"type": "signup", "token": "cixoe6C7k1tqx2UuYL_O3w"}))
pass

def _setRememberHeaders(remember):
if self.setCookie:
Expand Down
85 changes: 85 additions & 0 deletions infra/db/00-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
CREATE SCHEMA IF NOT EXISTS auth AUTHORIZATION postgres;
-- auth.users definition
CREATE TABLE auth.users (
instance_id uuid NULL,
id uuid NOT NULL,
aud varchar(255) NULL,
"role" varchar(255) NULL,
email varchar(255) NULL,
encrypted_password varchar(255) NULL,
confirmed_at timestamptz NULL,
invited_at timestamptz NULL,
confirmation_token varchar(255) NULL,
confirmation_sent_at timestamptz NULL,
recovery_token varchar(255) NULL,
recovery_sent_at timestamptz NULL,
email_change_token varchar(255) NULL,
email_change varchar(255) NULL,
email_change_sent_at timestamptz NULL,
last_sign_in_at timestamptz NULL,
raw_app_meta_data jsonb NULL,
raw_user_meta_data jsonb NULL,
is_super_admin bool NULL,
created_at timestamptz NULL,
updated_at timestamptz NULL,
CONSTRAINT users_pkey PRIMARY KEY (id)
);
CREATE INDEX users_instance_id_email_idx ON auth.users USING btree (instance_id, email);
CREATE INDEX users_instance_id_idx ON auth.users USING btree (instance_id);
-- auth.refresh_tokens definition
CREATE TABLE auth.refresh_tokens (
instance_id uuid NULL,
id bigserial NOT NULL,
"token" varchar(255) NULL,
user_id varchar(255) NULL,
revoked bool NULL,
created_at timestamptz NULL,
updated_at timestamptz NULL,
CONSTRAINT refresh_tokens_pkey PRIMARY KEY (id)
);
CREATE INDEX refresh_tokens_instance_id_idx ON auth.refresh_tokens USING btree (instance_id);
CREATE INDEX refresh_tokens_instance_id_user_id_idx ON auth.refresh_tokens USING btree (instance_id, user_id);
CREATE INDEX refresh_tokens_token_idx ON auth.refresh_tokens USING btree (token);
-- auth.instances definition
CREATE TABLE auth.instances (
id uuid NOT NULL,
uuid uuid NULL,
raw_base_config text NULL,
created_at timestamptz NULL,
updated_at timestamptz NULL,
CONSTRAINT instances_pkey PRIMARY KEY (id)
);
-- auth.audit_log_entries definition
CREATE TABLE auth.audit_log_entries (
instance_id uuid NULL,
id uuid NOT NULL,
payload json NULL,
created_at timestamptz NULL,
CONSTRAINT audit_log_entries_pkey PRIMARY KEY (id)
);
CREATE INDEX audit_logs_instance_id_idx ON auth.audit_log_entries USING btree (instance_id);
-- auth.schema_migrations definition
CREATE TABLE auth.schema_migrations (
"version" varchar(255) NOT NULL,
CONSTRAINT schema_migrations_pkey PRIMARY KEY ("version")
);
INSERT INTO auth.schema_migrations (version)
VALUES ('20171026211738'),
('20171026211808'),
('20171026211834'),
('20180103212743'),
('20180108183307'),
('20180119214651'),
('20180125194653');
-- Gets the User ID from the request cookie
create or replace function auth.uid() returns uuid as $$
select nullif(current_setting('request.jwt.claim.sub', true), '')::uuid;
$$ language sql stable;
-- Gets the User ID from the request cookie
create or replace function auth.role() returns text as $$
select nullif(current_setting('request.jwt.claim.role', true), '')::text;
$$ language sql stable;
GRANT ALL PRIVILEGES ON SCHEMA auth TO postgres;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA auth TO postgres;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA auth TO postgres;
ALTER USER postgres SET search_path = "auth";
38 changes: 38 additions & 0 deletions infra/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# docker-compose.yml
version: '3'
services:
gotrue:
image: supabase/gotrue:latest
ports:
- '9999:9999'
environment:
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_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"
GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID: 53566906701-bmhc1ndue7hild39575gkpimhs06b7ds.apps.googleusercontent.com
GOTRUE_EXTERNAL_GOOGLE_SECRET: Sm3s8RE85rDcS36iMy8YjrpC
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI: http://localhost:9999/callback
depends_on:
- db
db:
image: supabase/postgres
ports:
- '5432:5432'
volumes:
- ./db:/docker-entrypoint-initdb.d/
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432

0 comments on commit 5cfcae7

Please sign in to comment.