diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-12-02 12:43:05 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-01-23 13:28:02 +0100 |
commit | a6b242a1fd6f8900d80354361449f1bf62506ef9 (patch) | |
tree | f69d87208d0ebbdb8517529582280b174af74a16 /src/Wallabag/CoreBundle/Controller | |
parent | acd4412080dfb73ecaa7f9983728d1d55bc27ea4 (diff) | |
download | wallabag-a6b242a1fd6f8900d80354361449f1bf62506ef9.tar.gz wallabag-a6b242a1fd6f8900d80354361449f1bf62506ef9.tar.zst wallabag-a6b242a1fd6f8900d80354361449f1bf62506ef9.zip |
Enable OTP 2FA
- Update SchebTwoFactorBundle to version 3
- Enable Google 2fa on the bundle
- Disallow ability to use both email and google as 2fa
- Update Ocramius Proxy Manager to handle typed function & attributes (from PHP 7)
- use `$this->addFlash` shortcut instead of `$this->get('session')->getFlashBag()->add`
- update admin to be able to create/reset the 2fa
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index be6feb7c..5bbe1c74 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -46,7 +46,7 @@ class ConfigController extends Controller | |||
46 | $activeTheme = $this->get('liip_theme.active_theme'); | 46 | $activeTheme = $this->get('liip_theme.active_theme'); |
47 | $activeTheme->setName($config->getTheme()); | 47 | $activeTheme->setName($config->getTheme()); |
48 | 48 | ||
49 | $this->get('session')->getFlashBag()->add( | 49 | $this->addFlash( |
50 | 'notice', | 50 | 'notice', |
51 | 'flashes.config.notice.config_saved' | 51 | 'flashes.config.notice.config_saved' |
52 | ); | 52 | ); |
@@ -68,7 +68,7 @@ class ConfigController extends Controller | |||
68 | $userManager->updateUser($user, true); | 68 | $userManager->updateUser($user, true); |
69 | } | 69 | } |
70 | 70 | ||
71 | $this->get('session')->getFlashBag()->add('notice', $message); | 71 | $this->addFlash('notice', $message); |
72 | 72 | ||
73 | return $this->redirect($this->generateUrl('config') . '#set4'); | 73 | return $this->redirect($this->generateUrl('config') . '#set4'); |
74 | } | 74 | } |
@@ -80,10 +80,29 @@ class ConfigController extends Controller | |||
80 | ]); | 80 | ]); |
81 | $userForm->handleRequest($request); | 81 | $userForm->handleRequest($request); |
82 | 82 | ||
83 | // `googleTwoFactor` isn't a field within the User entity, we need to define it's value in a different way | ||
84 | if (true === $user->isGoogleAuthenticatorEnabled() && false === $userForm->isSubmitted()) { | ||
85 | $userForm->get('googleTwoFactor')->setData(true); | ||
86 | } | ||
87 | |||
83 | if ($userForm->isSubmitted() && $userForm->isValid()) { | 88 | if ($userForm->isSubmitted() && $userForm->isValid()) { |
89 | // handle creation / reset of the OTP secret if checkbox changed from the previous state | ||
90 | if (true === $userForm->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) { | ||
91 | $secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret(); | ||
92 | |||
93 | $user->setGoogleAuthenticatorSecret($secret); | ||
94 | $user->setEmailTwoFactor(false); | ||
95 | |||
96 | $qrCode = $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user); | ||
97 | |||
98 | $this->addFlash('OTPSecret', ['code' => $secret, 'qrCode' => $qrCode]); | ||
99 | } elseif (false === $userForm->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) { | ||
100 | $user->setGoogleAuthenticatorSecret(null); | ||
101 | } | ||
102 | |||
84 | $userManager->updateUser($user, true); | 103 | $userManager->updateUser($user, true); |
85 | 104 | ||
86 | $this->get('session')->getFlashBag()->add( | 105 | $this->addFlash( |
87 | 'notice', | 106 | 'notice', |
88 | 'flashes.config.notice.user_updated' | 107 | 'flashes.config.notice.user_updated' |
89 | ); | 108 | ); |
@@ -99,7 +118,7 @@ class ConfigController extends Controller | |||
99 | $em->persist($config); | 118 | $em->persist($config); |
100 | $em->flush(); | 119 | $em->flush(); |
101 | 120 | ||
102 | $this->get('session')->getFlashBag()->add( | 121 | $this->addFlash( |
103 | 'notice', | 122 | 'notice', |
104 | 'flashes.config.notice.rss_updated' | 123 | 'flashes.config.notice.rss_updated' |
105 | ); | 124 | ); |
@@ -131,7 +150,7 @@ class ConfigController extends Controller | |||
131 | $em->persist($taggingRule); | 150 | $em->persist($taggingRule); |
132 | $em->flush(); | 151 | $em->flush(); |
133 | 152 | ||
134 | $this->get('session')->getFlashBag()->add( | 153 | $this->addFlash( |
135 | 'notice', | 154 | 'notice', |
136 | 'flashes.config.notice.tagging_rules_updated' | 155 | 'flashes.config.notice.tagging_rules_updated' |
137 | ); | 156 | ); |
@@ -178,7 +197,7 @@ class ConfigController extends Controller | |||
178 | return new JsonResponse(['token' => $config->getRssToken()]); | 197 | return new JsonResponse(['token' => $config->getRssToken()]); |
179 | } | 198 | } |
180 | 199 | ||
181 | $this->get('session')->getFlashBag()->add( | 200 | $this->addFlash( |
182 | 'notice', | 201 | 'notice', |
183 | 'flashes.config.notice.rss_token_updated' | 202 | 'flashes.config.notice.rss_token_updated' |
184 | ); | 203 | ); |
@@ -203,7 +222,7 @@ class ConfigController extends Controller | |||
203 | $em->remove($rule); | 222 | $em->remove($rule); |
204 | $em->flush(); | 223 | $em->flush(); |
205 | 224 | ||
206 | $this->get('session')->getFlashBag()->add( | 225 | $this->addFlash( |
207 | 'notice', | 226 | 'notice', |
208 | 'flashes.config.notice.tagging_rules_deleted' | 227 | 'flashes.config.notice.tagging_rules_deleted' |
209 | ); | 228 | ); |
@@ -269,7 +288,7 @@ class ConfigController extends Controller | |||
269 | break; | 288 | break; |
270 | } | 289 | } |
271 | 290 | ||
272 | $this->get('session')->getFlashBag()->add( | 291 | $this->addFlash( |
273 | 'notice', | 292 | 'notice', |
274 | 'flashes.config.notice.' . $type . '_reset' | 293 | 'flashes.config.notice.' . $type . '_reset' |
275 | ); | 294 | ); |