avam-client and oauth2

This commit is contained in:
2024-10-17 00:56:02 +02:00
parent bfc5cbf624
commit f93eb3c429
50 changed files with 5674 additions and 277 deletions

View 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";

View 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);