avam-client and oauth2
This commit is contained in:
5
migrations/20241012185353_oauth2.down.sql
Normal file
5
migrations/20241012185353_oauth2.down.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
-- Add down migration script here
|
||||
DROP TABLE "refresh_tokens";
|
||||
DROP TABLE "authorized_clients";
|
||||
DROP TABLE "authorization_code";
|
||||
DROP TABLE "clients";
|
40
migrations/20241012185353_oauth2.up.sql
Normal file
40
migrations/20241012185353_oauth2.up.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
-- Add up migration script here
|
||||
|
||||
CREATE TABLE "clients" (
|
||||
"id" uuid NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"secret" text NOT NULL,
|
||||
"redirect_uri" text NOT NULL,
|
||||
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "clients_name_key" UNIQUE ("name"),
|
||||
CONSTRAINT "clients_pkey" PRIMARY KEY ("id")
|
||||
) WITH (oids = false);
|
||||
|
||||
CREATE TABLE "authorization_code" (
|
||||
"code" text NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"client_id" uuid NOT NULL,
|
||||
"code_challenge" text NOT NULL,
|
||||
"code_challenge_method" text NOT NULL,
|
||||
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "authorization_code_pkey" PRIMARY KEY ("code")
|
||||
) WITH (oids = false);
|
||||
|
||||
CREATE TABLE "authorized_clients" (
|
||||
"user_id" uuid NOT NULL,
|
||||
"client_id" uuid NOT NULL,
|
||||
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP, -- last accessed
|
||||
CONSTRAINT "authorized_clients_pkey" PRIMARY KEY ("user_id", "client_id")
|
||||
) WITH (oids = false);
|
||||
|
||||
CREATE TABLE "refresh_tokens" (
|
||||
"token" text NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"client_id" uuid NOT NULL,
|
||||
"expires_at" timestamp DEFAULT CURRENT_TIMESTAMP + interval '30' day,
|
||||
CONSTRAINT "refresh_tokens_pkey" PRIMARY KEY ("token")
|
||||
) WITH (oids = false);
|
Reference in New Issue
Block a user