2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS authentication_logs (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT authentication_logs_pkey PRIMARY KEY,
|
2021-11-23 09:45:38 +00:00
|
|
|
time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
successful BOOLEAN NOT NULL,
|
2021-11-29 03:09:14 +00:00
|
|
|
banned BOOLEAN NOT NULL DEFAULT FALSE,
|
2021-11-23 09:45:38 +00:00
|
|
|
username VARCHAR(100) NOT NULL,
|
2021-12-02 10:28:16 +00:00
|
|
|
auth_type VARCHAR(8) NOT NULL DEFAULT '1FA',
|
2021-12-03 00:04:11 +00:00
|
|
|
remote_ip VARCHAR(39) NULL DEFAULT NULL,
|
2021-11-29 03:09:14 +00:00
|
|
|
request_uri TEXT,
|
2022-11-19 05:47:09 +00:00
|
|
|
request_method VARCHAR(8) NOT NULL DEFAULT ''
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
|
|
|
|
2021-11-29 03:09:14 +00:00
|
|
|
CREATE INDEX authentication_logs_username_idx ON authentication_logs (time, username, auth_type);
|
|
|
|
CREATE INDEX authentication_logs_remote_ip_idx ON authentication_logs (time, remote_ip, auth_type);
|
2021-11-23 09:45:38 +00:00
|
|
|
|
2021-11-30 06:58:21 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS identity_verification (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT identity_verification_pkey PRIMARY KEY,
|
2021-11-30 06:58:21 +00:00
|
|
|
jti CHAR(36),
|
|
|
|
iat TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2021-12-03 00:04:11 +00:00
|
|
|
issued_ip VARCHAR(39) NOT NULL,
|
2021-11-30 06:58:21 +00:00
|
|
|
exp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
|
|
username VARCHAR(100) NOT NULL,
|
|
|
|
action VARCHAR(50) NOT NULL,
|
2021-12-03 00:04:11 +00:00
|
|
|
consumed TIMESTAMP WITH TIME ZONE NULL DEFAULT NULL,
|
2022-11-19 05:47:09 +00:00
|
|
|
consumed_ip VARCHAR(39) NULL DEFAULT NULL
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
|
|
|
|
2022-11-19 05:47:09 +00:00
|
|
|
CREATE UNIQUE INDEX identity_verification_jti_key ON identity_verification (jti);
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS totp_configurations (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT totp_configurations_pkey PRIMARY KEY,
|
2021-11-23 09:45:38 +00:00
|
|
|
username VARCHAR(100) NOT NULL,
|
2021-11-29 03:09:14 +00:00
|
|
|
issuer VARCHAR(100),
|
2021-11-23 09:45:38 +00:00
|
|
|
algorithm VARCHAR(6) NOT NULL DEFAULT 'SHA1',
|
|
|
|
digits INTEGER NOT NULL DEFAULT 6,
|
2021-12-02 01:24:10 +00:00
|
|
|
period INTEGER NOT NULL DEFAULT 30,
|
2022-11-19 05:47:09 +00:00
|
|
|
secret BYTEA NOT NULL
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
|
|
|
|
2022-11-19 05:47:09 +00:00
|
|
|
CREATE UNIQUE INDEX totp_configurations_username_key ON totp_configurations (username);
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS u2f_devices (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT u2f_devices_pkey PRIMARY KEY,
|
2021-11-23 09:45:38 +00:00
|
|
|
username VARCHAR(100) NOT NULL,
|
|
|
|
description VARCHAR(30) NOT NULL DEFAULT 'Primary',
|
|
|
|
key_handle BYTEA NOT NULL,
|
2022-11-19 05:47:09 +00:00
|
|
|
public_key BYTEA NOT NULL
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
|
|
|
|
2022-11-19 05:47:09 +00:00
|
|
|
CREATE UNIQUE INDEX u2f_devices_lookup_key ON u2f_devices (username, description);
|
|
|
|
|
2021-12-01 03:32:58 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS duo_devices (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT duo_devices_pkey PRIMARY KEY,
|
2021-12-01 03:32:58 +00:00
|
|
|
username VARCHAR(100) NOT NULL,
|
|
|
|
device VARCHAR(32) NOT NULL,
|
2022-11-19 05:47:09 +00:00
|
|
|
method VARCHAR(16) NOT NULL
|
2021-12-01 03:32:58 +00:00
|
|
|
);
|
|
|
|
|
2022-11-19 05:47:09 +00:00
|
|
|
CREATE UNIQUE INDEX duo_devices_username_key ON duo_devices (username);
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS user_preferences (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT user_preferences_pkey PRIMARY KEY,
|
2021-11-23 09:45:38 +00:00
|
|
|
username VARCHAR(100) NOT NULL,
|
2022-11-19 05:47:09 +00:00
|
|
|
second_factor_method VARCHAR(11) NOT NULL
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
|
|
|
|
2022-11-19 05:47:09 +00:00
|
|
|
CREATE UNIQUE INDEX user_preferences_username_key ON user_preferences (username);
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS migrations (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT migrations_pkey PRIMARY KEY,
|
2021-11-23 09:45:38 +00:00
|
|
|
applied TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
version_before INTEGER NULL DEFAULT NULL,
|
|
|
|
version_after INTEGER NOT NULL,
|
2022-11-19 05:47:09 +00:00
|
|
|
application_version VARCHAR(128) NOT NULL
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
2021-11-25 01:56:58 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS encryption (
|
2022-11-19 05:47:09 +00:00
|
|
|
id SERIAL CONSTRAINT encryption_pkey PRIMARY KEY,
|
|
|
|
name VARCHAR(100),
|
|
|
|
value BYTEA NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX encryption_name_key ON encryption (name);
|