mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: store login events (#3185)
## About the changes https://linear.app/unleash/issue/2-705/store-sign-on-events Adds a migration for a new `login_events` table. Also adds the new `loginEventLog` feature flag. <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: #2951 --------- Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
This commit is contained in:
parent
194c07ec24
commit
25b7af30b8
@ -74,6 +74,7 @@ exports[`should create default config 1`] = `
|
||||
"embedProxy": true,
|
||||
"embedProxyFrontend": true,
|
||||
"featuresExportImport": false,
|
||||
"loginEventLog": false,
|
||||
"maintenance": false,
|
||||
"maintenanceMode": false,
|
||||
"messageBanner": false,
|
||||
@ -96,6 +97,7 @@ exports[`should create default config 1`] = `
|
||||
"embedProxy": true,
|
||||
"embedProxyFrontend": true,
|
||||
"featuresExportImport": false,
|
||||
"loginEventLog": false,
|
||||
"maintenance": false,
|
||||
"maintenanceMode": false,
|
||||
"messageBanner": false,
|
||||
|
@ -67,6 +67,10 @@ const flags = {
|
||||
false,
|
||||
),
|
||||
notifications: parseEnvVarBoolean(process.env.NOTIFICATIONS, false),
|
||||
loginEventLog: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_LOGIN_EVENT_LOG,
|
||||
false,
|
||||
),
|
||||
};
|
||||
|
||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||
|
27
src/migrations/20230222084211-add-login-events-table.js
Normal file
27
src/migrations/20230222084211-add-login-events-table.js
Normal file
@ -0,0 +1,27 @@
|
||||
exports.up = function (db, cb) {
|
||||
db.runSql(
|
||||
`
|
||||
CREATE TABLE IF NOT EXISTS login_events (
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
username TEXT NOT NULL,
|
||||
auth_type TEXT NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||
successful BOOLEAN NOT NULL,
|
||||
ip INET,
|
||||
failure_reason TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS login_events_ip_idx ON login_events(ip);
|
||||
`,
|
||||
cb,
|
||||
);
|
||||
};
|
||||
|
||||
exports.down = function (db, cb) {
|
||||
db.runSql(
|
||||
`
|
||||
DROP INDEX IF EXISTS login_events_ip_idx;
|
||||
DROP TABLE IF EXISTS login_events;
|
||||
`,
|
||||
cb,
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user