Skip to content

Commit ef6b631

Browse files
authored
[Core] Add Support for TOTP / 2FA to LORIS (#9972)
This adds support for time based one time passwords (TOTP) to LORIS based on RFC6238 (the standard used by authenticator apps such as Authy or Microsoft Authenticator). There is a new subpage of my_preferences where a user can register an authenticator app to their account using a QR code. After validating the code, the secret key used to generate it is saved to the users table. After this point, any attempts to log in will check if they have a valid 2FA code by using a new MFA middleware. The middleware intercepts requests and prompts for the code if it has not yet been provided.
1 parent 93a2e6b commit ef6b631

34 files changed

+1905
-292
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ locales:
135135
msgfmt -o modules/module_manager/locale/ja/LC_MESSAGES/module_manager.mo modules/module_manager/locale/ja/LC_MESSAGES/module_manager.po
136136
msgfmt -o modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.mo modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.po
137137
msgfmt -o modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.mo modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.po
138+
npx i18next-conv -l ja -s modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.po -t modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.json --compatibilityJSON v4
139+
npx i18next-conv -l hi -s modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.po -t modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.json --compatibilityJSON v4
140+
msgfmt -o modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.mo modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.po
138141
msgfmt -o modules/next_stage/locale/ja/LC_MESSAGES/next_stage.mo modules/next_stage/locale/ja/LC_MESSAGES/next_stage.po
139142
msgfmt -o modules/next_stage/locale/es/LC_MESSAGES/next_stage.mo modules/next_stage/locale/es/LC_MESSAGES/next_stage.po
140143
msgfmt -o modules/oidc/locale/ja/LC_MESSAGES/oidc.mo modules/oidc/locale/ja/LC_MESSAGES/oidc.po
@@ -198,3 +201,8 @@ server_processes_manager: modules/server_processes_manager/locale/ja/LC_MESSAGES
198201

199202
conflict_resolver:
200203
target=conflict_resolver npm run compile
204+
205+
my_preferences: modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.mo modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.mo
206+
npx i18next-conv -l ja -s modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.po -t modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.json --compatibilityJSON v4
207+
npx i18next-conv -l hi -s modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.po -t modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.json --compatibilityJSON v4
208+
target=my_preferences npm run compile

SQL/0000-00-00-schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ CREATE TABLE `users` (
105105
`Active` enum('Y','N') NOT NULL default 'Y',
106106
`Password_hash` varchar(255) default NULL,
107107
`PasswordChangeRequired` tinyint(1) NOT NULL default 0,
108+
`TOTPSecret` binary(64) DEFAULT NULL,
108109
`Pending_approval` enum('Y','N') default 'Y',
109110
`Doc_Repo_Notifications` enum('Y','N') default 'N',
110111
`language_preference` integer unsigned default NULL,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE users ADD COLUMN TOTPSecret binary(64) DEFAULT NULL AFTER PasswordChangeRequired;

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"laminas/laminas-diactoros" : "^3.5",
1616
"ext-json": "*",
1717
"bjeavons/zxcvbn-php": "^1.0",
18-
"aws/aws-sdk-php": "^3.209"
18+
"aws/aws-sdk-php": "^3.209",
19+
"selective/base32": "^2.0",
20+
"chillerlan/php-qrcode": "^5.0"
1921
},
2022
"require-dev" : {
2123
"squizlabs/php_codesniffer" : "^3.5",

0 commit comments

Comments
 (0)