mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
bc3b0fda35
This adds additional logging to the authentication logs such as type, remote IP, request method, redirect URL, and if the attempt was done during a ban. This also means we log attempts that occur when the attempt was blocked by the regulator for record keeping purposes, as well as record 2FA attempts which can be used to inform admins and later to regulate based on other factors. Fixes #116, Fixes #1293.
71 lines
2.1 KiB
SQL
71 lines
2.1 KiB
SQL
CREATE TABLE IF NOT EXISTS authentication_logs (
|
|
id INTEGER AUTO_INCREMENT,
|
|
time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
successful BOOLEAN NOT NULL,
|
|
banned BOOLEAN NOT NULL DEFAULT FALSE,
|
|
username VARCHAR(100) NOT NULL,
|
|
auth_type VARCHAR(5) NOT NULL DEFAULT '1FA',
|
|
remote_ip VARCHAR(47) NULL DEFAULT NULL,
|
|
request_uri TEXT NOT NULL,
|
|
request_method VARCHAR(4) NOT NULL DEFAULT '',
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
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);
|
|
|
|
CREATE TABLE IF NOT EXISTS identity_verification_tokens (
|
|
id INTEGER AUTO_INCREMENT,
|
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
token VARCHAR(512),
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY (token)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS totp_configurations (
|
|
id INTEGER AUTO_INCREMENT,
|
|
username VARCHAR(100) NOT NULL,
|
|
issuer VARCHAR(100),
|
|
algorithm VARCHAR(6) NOT NULL DEFAULT 'SHA1',
|
|
digits INTEGER NOT NULL DEFAULT 6,
|
|
totp_period INTEGER NOT NULL DEFAULT 30,
|
|
secret BLOB NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY (username)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS u2f_devices (
|
|
id INTEGER AUTO_INCREMENT,
|
|
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 KEY (username, description)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS user_preferences (
|
|
id INTEGER AUTO_INCREMENT,
|
|
username VARCHAR(100) NOT NULL,
|
|
second_factor_method VARCHAR(11) NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY (username)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS migrations (
|
|
id INTEGER AUTO_INCREMENT,
|
|
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)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS encryption (
|
|
id INTEGER AUTO_INCREMENT,
|
|
name VARCHAR(100),
|
|
value BLOB NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY (name)
|
|
);
|