2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS authentication_logs (
|
|
|
|
id INTEGER,
|
|
|
|
time TIMESTAMP 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-11-29 03:09:14 +00:00
|
|
|
auth_type VARCHAR(5) NOT NULL DEFAULT '1FA',
|
|
|
|
remote_ip VARCHAR(47) NULL DEFAULT NULL,
|
|
|
|
request_uri TEXT,
|
2021-12-02 00:36:04 +00:00
|
|
|
request_method VARCHAR(8) NOT NULL DEFAULT '',
|
2021-11-23 09:45:38 +00:00
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
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 (
|
2021-11-23 09:45:38 +00:00
|
|
|
id INTEGER,
|
2021-11-30 06:58:21 +00:00
|
|
|
jti VARCHAR(36),
|
|
|
|
iat TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
exp TIMESTAMP NOT NULL,
|
|
|
|
used TIMESTAMP NULL DEFAULT NULL,
|
|
|
|
username VARCHAR(100) NOT NULL,
|
|
|
|
action VARCHAR(50) NOT NULL,
|
2021-11-23 09:45:38 +00:00
|
|
|
PRIMARY KEY (id),
|
2021-11-30 06:58:21 +00:00
|
|
|
UNIQUE (jti)
|
2021-11-23 09:45:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS totp_configurations (
|
|
|
|
id INTEGER,
|
|
|
|
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',
|
2021-11-29 03:09:14 +00:00
|
|
|
digits INTEGER NOT NULL DEFAULT 6,
|
2021-12-02 01:24:10 +00:00
|
|
|
period INTEGER NOT NULL DEFAULT 30,
|
2021-11-25 01:56:58 +00:00
|
|
|
secret BLOB NOT NULL,
|
2021-11-23 09:45:38 +00:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (username)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS u2f_devices (
|
|
|
|
id INTEGER,
|
|
|
|
username VARCHAR(100) NOT NULL,
|
|
|
|
description VARCHAR(30) NOT NULL DEFAULT 'Primary',
|
|
|
|
key_handle BLOB NOT NULL,
|
|
|
|
public_key BLOB NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (username, description)
|
|
|
|
);
|
|
|
|
|
2021-12-01 03:32:58 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS duo_devices (
|
|
|
|
id INTEGER,
|
|
|
|
username VARCHAR(100) NOT NULL,
|
|
|
|
device VARCHAR(32) NOT NULL,
|
|
|
|
method VARCHAR(16) NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (username)
|
|
|
|
);
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS user_preferences (
|
|
|
|
id INTEGER,
|
|
|
|
username VARCHAR(100) UNIQUE NOT NULL,
|
|
|
|
second_factor_method VARCHAR(11) NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS migrations (
|
|
|
|
id INTEGER,
|
|
|
|
applied TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
version_before INTEGER NULL DEFAULT NULL,
|
|
|
|
version_after INTEGER NOT NULL,
|
|
|
|
application_version VARCHAR(128) NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
2021-11-25 01:56:58 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS encryption (
|
|
|
|
id INTEGER,
|
|
|
|
name VARCHAR(100),
|
|
|
|
value BLOB NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (name)
|
|
|
|
);
|