File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ class TwoFactorAuthenticationService
2525 */
2626 protected $ applicationName ;
2727
28+ /**
29+ * @var string
30+ * @Flow\InjectConfiguration("secretKeyLength")
31+ */
32+ protected $ secretKeyLength ;
33+
2834 public function getPasswordCredentialsSource (Account $ account ): string
2935 {
3036 if ($ this ->hasTwoFactorAuthenticationCredentials ($ account )) {
@@ -89,7 +95,7 @@ public function createActivationQrCode(Account $account): string
8995 $ google2fa = new Google2Fa ();
9096
9197 $ existingCredentials = $ this ->getTwoFactorAuthenticationCredentials ($ account );
92- $ secret = $ existingCredentials ->pendingSecret ?: $ google2fa ->generateSecretKey ();
98+ $ secret = $ existingCredentials ->pendingSecret ?: $ google2fa ->generateSecretKey ($ this -> getSecretKeyLength () );
9399
94100 $ updatedCredentials = new TwoFactorAuthenticationCredentialsSource (
95101 $ existingCredentials ->credentialsSource ,
@@ -139,4 +145,9 @@ protected function hasTwoFactorAuthenticationCredentials(Account $account): bool
139145 && is_array (json_decode ($ credentials , true ))
140146 && (json_last_error () == JSON_ERROR_NONE ) ? true : false ;
141147 }
148+
149+ protected function getSecretKeyLength (): int
150+ {
151+ return $ this ->secretKeyLength * 8 ;
152+ }
142153}
Original file line number Diff line number Diff line change 11Yeebase :
22 TwoFactorAuthentication :
33 # Length of the secret key that is created for the validation of secrets
4- secretKeyLengthInByte : 1
4+ # The length given here is multiplied with 8 as the key must be at least 8 chars and be a power of 2
5+ secretKeyLength : 2
56
67 # The application name that should appear in the authenticator app
78 applicationName : ' default'
@@ -10,4 +11,4 @@ Yeebase:
1011 authenticationEntryPoint :
1112 package : ~
1213 controller : ~
13- action : ' insertSecret'
14+ action : ' insertSecret'
You can’t perform that action at this time.
0 commit comments