born05 / craft-twofactorauthentication
Craft 4 plugin for two-factor or two-step login using Time Based OTP.
Installs: 89 919
Dependents: 1
Suggesters: 0
Security: 2
Stars: 36
Watchers: 8
Forks: 26
Open Issues: 1
Type:craft-plugin
Requires
- php: ^8.1
- craftcms/cms: ^4.0.0-alpha
- endroid/qr-code: ^5.0.0
- spomky-labs/otphp: ^11.0.0
- dev-craft-4
- 3.4.0
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.1
- 3.0.0
- 3.0.0-beta.1
- 2.11.1
- 2.11.0
- 2.10.1
- 2.10.0
- 2.9.0
- 2.8.1
- 2.8.0
- 2.7.4
- 2.7.3.1
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.7.0-beta.1
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.1.0-beta.2
- 2.1.0-beta.1
- 2.0.1
- 2.0.0
- 2.0.0-beta.14
- 2.0.0-beta.13
- 2.0.0-beta.12
- 2.0.0-beta.11
- 2.0.0-beta.10
- 2.0.0-beta.9
- 2.0.0-beta.8
- 2.0.0-beta.7
- 2.0.0-beta.6
- 2.0.0-beta.5
- 2.0.0-beta.4
- 2.0.0-beta.3
- 2.0.0-beta.2
- 2.0.0-beta.1
- 2.0.0-beta
- 1.1.0
- 1.0.1
- 1.0.0
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-craft-3.1
- dev-feature/non-cp-login-redirect
- dev-override-base-components
- dev-craft-2
This package is auto-updated.
Last update: 2024-10-27 08:35:00 UTC
README
Two-Factor Authentication
Craft 4 plugin for two-factor or two-step login using Time Based OTP (TOTP, like Google Authenticator). Every user can setup TOTP themselves, the plugin does not force users. Admins can list usage in user tables.
Inner working
Login works as usual for users without 2-factor auth.
When enabled, the user is redirected to the 2-factor verification page after login. This means the user is already logged in. When the user tries to visit an other Control Panel page than the public ones before verification, the logout is triggered. This blocks the user from visiting the CP unverified.
Requirements
- Craft 4.0.0 and up
- PHP 8.1 and up
Setting up back end 2FA
- Set
verifyBackEnd
totrue
in the config file (this is the default). - Set
forceBackEnd
totrue
if you want to prevent users from accessing the control panel without first enabling 2FA.
Setting up front end 2FA
When using a login for front end users, the following steps add 2FA support.
- Copy the two-factor-authentication.php file to your
config/
folder. - Set
verifyFrontEnd
totrue
in the config file. - Define what urls should be protected with 2FA verification. Choose between using the
frontEndPathAllow
orfrontEndPathExclude
! Using both will block everything! See config for additional info. - Build a 2FA login-verify form accessible by url like the example twig.
- Set the
verifyPath
. For ourlogin-verify.twig
example the path would belogin-verify
. - Allow users setting up 2FA in front end by building a template like the example twig.
- Set the
settingsPath
. For ourtwo-factor-settings.twig
example the path would betwo-factor-settings
.
Setting up config
Copy the two-factor-authentication.php file to your config/
folder.
Resetting a user's 2FA
Simply remove the user's twofactorauthentication_user
record. This disables 2FA for that user.
Screens
Setting screen when turning 2FA on
Setting screen when turning 2FA off
Login verification screen
License
Copyright © Born05
See license