From 9bfb8e968fcecbe4dc729b89017d0606d271b287 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 3 Jan 2019 16:53:09 -0800 Subject: OIDC auth table, and is_active editor flag --- rust/migrations/2018-05-12-001226_init/down.sql | 1 + rust/migrations/2018-05-12-001226_init/up.sql | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'rust') diff --git a/rust/migrations/2018-05-12-001226_init/down.sql b/rust/migrations/2018-05-12-001226_init/down.sql index d156370e..b2666083 100644 --- a/rust/migrations/2018-05-12-001226_init/down.sql +++ b/rust/migrations/2018-05-12-001226_init/down.sql @@ -42,6 +42,7 @@ DROP TABLE IF EXISTS creator_ident CASCADE; DROP TABLE IF EXISTS creator_edit CASCADE; DROP TABLE IF EXISTS abstracts CASCADE; +DROP TABLE IF EXISTS auth_oidc CASCADE; DROP TABLE IF EXISTS editor CASCADE; DROP TABLE IF EXISTS editgroup CASCADE; DROP TABLE IF EXISTS changelog CASCADE; diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index db2e835f..0d9d81d0 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -19,6 +19,7 @@ CREATE TABLE editor ( username TEXT NOT NULL UNIQUE, -- TODO: alphanum and length constraints? is_admin BOOLEAN NOT NULL DEFAULT false, is_bot BOOLEAN NOT NULL DEFAULT false, + is_active BOOLEAN NOT NULL DEFAULT true, registered TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL, auth_epoch TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL, wrangler_id UUID REFERENCES editor(id), @@ -28,6 +29,17 @@ CREATE TABLE editor ( CREATE INDEX active_editgroup_idx ON editor(active_editgroup_id); CREATE INDEX editor_username_idx ON editor(username); +CREATE TABLE auth_oidc ( + id BIGSERIAL PRIMARY KEY, + created TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL, + editor_id UUID REFERENCES editor(id) NOT NULL, + provider TEXT NOT NULL, + oidc_iss TEXT NOT NULL, + oidc_sub TEXT NOT NULL, + UNIQUE (editor_id, provider), + UNIQUE (oidc_iss, oidc_sub) +); + CREATE TABLE editgroup ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), editor_id UUID REFERENCES editor(id) NOT NULL, -- cgit v1.2.3