diff --git a/Classes/Controller/LoginController.php b/Classes/Controller/LoginController.php index f9c8118..58f606c 100644 --- a/Classes/Controller/LoginController.php +++ b/Classes/Controller/LoginController.php @@ -94,7 +94,7 @@ public function askForSecondFactorAction(?string $username = null) * @throws StopActionException * @throws SessionNotStartedException */ - public function checkOtpAction(string $otp) + public function checkSecondFactorAction(string $otp) { $account = $this->securityContext->getAccount(); diff --git a/Classes/Http/Middleware/SecondFactorMiddleware.php b/Classes/Http/Middleware/SecondFactorMiddleware.php index 70d6023..9dac2f5 100644 --- a/Classes/Http/Middleware/SecondFactorMiddleware.php +++ b/Classes/Http/Middleware/SecondFactorMiddleware.php @@ -21,6 +21,8 @@ class SecondFactorMiddleware implements MiddlewareInterface { const LOGGING_PREFIX = 'Sandstorm/NeosTwoFactorAuthentication: '; + const SECOND_FACTOR_LOGIN_URI = 'neos/second-factor-login'; + const SECOND_FACTOR_SETUP_URI = 'neos/second-factor-setup'; /** * @Flow\Inject @@ -128,7 +130,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface && $authenticationStatus === AuthenticationStatus::AUTHENTICATION_NEEDED ) { // WHY: We use the request URI as part of state. This prevents the middleware to enter a redirect loop. - $isAskingForOTP = str_ends_with($request->getUri()->getPath(), 'neos/two-factor-login'); + $isAskingForOTP = str_ends_with($request->getUri()->getPath(), self::SECOND_FACTOR_LOGIN_URI); if ($isAskingForOTP) { return $next->handle($request); } @@ -143,7 +145,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface // See Sandstorm/NeosTwoFactorAuthentication/LoginController $this->registerOriginalRequestForRedirect($request); - return new Response(303, ['Location' => '/neos/two-factor-login']); + return new Response(303, ['Location' => self::SECOND_FACTOR_LOGIN_URI]); } if ( @@ -151,7 +153,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface !$this->secondFactorRepository->isEnabledForAccount($account) ) { // WHY: We use the request URI as part of state. This prevents the middleware to enter a redirect loop. - $isSettingUp2FA = str_ends_with($request->getUri()->getPath(), 'neos/setup-second-factor'); + $isSettingUp2FA = str_ends_with($request->getUri()->getPath(), self::SECOND_FACTOR_SETUP_URI); if ($isSettingUp2FA) { return $next->handle($request); } @@ -165,7 +167,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface // See Sandstorm/NeosTwoFactorAuthentication/LoginController $this->registerOriginalRequestForRedirect($request); - return new Response(303, ['Location' => '/neos/setup-second-factor']); + return new Response(303, ['Location' => self::SECOND_FACTOR_SETUP_URI]); } throw new AuthenticationRequiredException("You have to be logged in with second factor!"); diff --git a/Configuration/Routes.yaml b/Configuration/Routes.yaml index cd99f99..c7682a7 100644 --- a/Configuration/Routes.yaml +++ b/Configuration/Routes.yaml @@ -1,5 +1,5 @@ - name: 'Sandstorm Two Factor Authentication' - uriPattern: 'neos/two-factor-login' + uriPattern: 'neos/second-factor-login' httpMethods: ['GET'] defaults: '@package': 'Sandstorm.NeosTwoFactorAuthentication' @@ -9,17 +9,17 @@ appendExceedingArguments: true - name: 'Sandstorm Two Factor Authentication - Validation' - uriPattern: 'neos/two-factor-login' + uriPattern: 'neos/second-factor-login' httpMethods: ['POST'] defaults: '@package': 'Sandstorm.NeosTwoFactorAuthentication' '@controller': 'Login' - '@action': 'checkOtp' + '@action': 'checkSecondFactor' '@format': 'html' appendExceedingArguments: true - name: 'Sandstorm Two Factor Authentication - Setup' - uriPattern: 'neos/setup-second-factor' + uriPattern: 'neos/second-factor-setup' defaults: '@package': 'Sandstorm.NeosTwoFactorAuthentication' '@controller': 'Login' @@ -29,7 +29,7 @@ appendExceedingArguments: true - name: 'Sandstorm Two Factor Authentication - Create 2FA' - uriPattern: 'neos/setup-second-factor' + uriPattern: 'neos/second-factor-setup' defaults: '@package': 'Sandstorm.NeosTwoFactorAuthentication' '@controller': 'Login'