forked from Chewing_Bever/rusty-bever
First draft of refresh_tokens table
parent
4ccee64323
commit
eefaf7acaa
|
@ -3,7 +3,10 @@ CREATE TABLE users (
|
||||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||||
|
|
||||||
username varchar(32) UNIQUE NOT NULL,
|
username varchar(32) UNIQUE NOT NULL,
|
||||||
password text NOT NULL
|
-- Hashed + salted representation of the username
|
||||||
|
password text NOT NULL,
|
||||||
|
-- Wether the user is currently blocked
|
||||||
|
blocked boolean DEFAULT false
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Permissions that a user can have
|
-- Permissions that a user can have
|
||||||
|
@ -15,3 +18,17 @@ CREATE TABLE permissions (
|
||||||
|
|
||||||
UNIQUE (user_id, name)
|
UNIQUE (user_id, name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- TODO security reports table (e.g. when a user is blocked)
|
||||||
|
|
||||||
|
-- Stores refresh tokens
|
||||||
|
CREATE TABLE refresh_tokens (
|
||||||
|
-- This is more efficient than storing the text
|
||||||
|
token bytea PRIMARY KEY,
|
||||||
|
-- The user for whom the token was created
|
||||||
|
user_id uuid NOT NULL REFERENCES users(id),
|
||||||
|
-- When the token expires
|
||||||
|
expires_at timestamp NOT NULL,
|
||||||
|
-- When the token was last used (is NULL until used)
|
||||||
|
last_used_at timestamp
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue