born05 / craft-twofactorauthentication

Craft plugin for two-factor or two-step login using Time Based OTP.
MIT License
36 stars 26 forks source link

Issue using 2.6.3 for admin auth #47

Closed weotch closed 3 years ago

weotch commented 4 years ago

I installed 2.6.3 because I was having issues with 2.7.0 (see #46) onto Craft 3.5.13. I am being shown the field to enter my code:

image

However, the server is returning a 400 response on every submit. Looking into the web.log, I see errors like this:

2020-10-15 17:31:37 [-][-][-][error][yii\web\HttpException:403] yii\web\ForbiddenHttpException: Login Required in /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/yiisoft/yii2/web/User.php:456
Stack trace:
#0 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/craftcms/cms/src/web/Controller.php(267): yii\web\User->loginRequired()
#1 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/craftcms/cms/src/web/Controller.php(154): craft\web\Controller->requireLogin()
#2 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/yiisoft/yii2/base/Controller.php(178): craft\web\Controller->beforeAction(Object(yii\base\InlineAction))
#3 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Controller->runAction('login-process', Array)
#4 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('login-process', Array)
#5 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('two-factor-auth...', Array)
#6 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction('two-factor-auth...', Array)
#7 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#8 /Users/reinhard/Work/Clif Bar - Next/craft-cms/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /Users/reinhard/Work/Clif Bar - Next/craft-cms/web/index.php(21): yii\base\Application->run()
#10 /Users/reinhard/.composer/vendor/laravel/valet/server.php(191): require('/Users/reinhard...')
#11 {main}
2020-10-15 17:31:37 [-][-][-][info][application] $_GET = [
    'p' => 'admin/actions/two-factor-authentication/verify/login-process'
]

$_POST = [
    'authenticationCode' => '504287'
]

I am using 1Password as my 2FA client. It accepted the QR code generated by this package without issue. Any suggestions?

roelvanhintum commented 4 years ago

@weotch, thanks for the details! 1password works fine, this looks like a php thing. Sometimes the login expires and you have to login again before you can enter the 2fa code. When another control panel path (except login etc) is called before 2fa verification you are logged out again.

Did you encounter this more than once? Try refreshing the page (related to #11).

weotch commented 4 years ago

I figured it out, it's a conflict with this plugin: https://github.com/marionnewlevant/craft-snitch. Looks like it's already been reported here: https://github.com/marionnewlevant/craft-snitch/issues/19.

Thanks for the quick support and for making this package!

weotch commented 4 years ago

Sometimes the login expires and you have to login again before you can enter the 2fa code.

Is there any way to increase the time before this login expires?

roelvanhintum commented 3 years ago

@weotch i've just released a fix for regarding this in 2.7.4 Does this also work for you?

weotch commented 3 years ago

Thanks @roelvanhintum! I've added verifying that fix to our backlog.