diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 03db7390e..db318dddf 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -254,10 +254,14 @@ class ConfigController extends AbstractController
/**
* Disable 2FA using email.
*
- * @Route("/config/otp/email/disable", name="disable_otp_email")
+ * @Route("/config/otp/email/disable", name="disable_otp_email", methods={"POST"})
*/
- public function disableOtpEmailAction()
+ public function disableOtpEmailAction(Request $request)
{
+ if (!$this->isCsrfTokenValid('otp', $request->request->get('token'))) {
+ throw $this->createAccessDeniedException('Bad CSRF token.');
+ }
+
$user = $this->getUser();
$user->setEmailTwoFactor(false);
@@ -274,10 +278,14 @@ class ConfigController extends AbstractController
/**
* Enable 2FA using email.
*
- * @Route("/config/otp/email", name="config_otp_email")
+ * @Route("/config/otp/email", name="config_otp_email", methods={"POST"})
*/
- public function otpEmailAction()
+ public function otpEmailAction(Request $request)
{
+ if (!$this->isCsrfTokenValid('otp', $request->request->get('token'))) {
+ throw $this->createAccessDeniedException('Bad CSRF token.');
+ }
+
$user = $this->getUser();
$user->setGoogleAuthenticatorSecret(null);
@@ -297,10 +305,14 @@ class ConfigController extends AbstractController
/**
* Disable 2FA using OTP app.
*
- * @Route("/config/otp/app/disable", name="disable_otp_app")
+ * @Route("/config/otp/app/disable", name="disable_otp_app", methods={"POST"})
*/
- public function disableOtpAppAction()
+ public function disableOtpAppAction(Request $request)
{
+ if (!$this->isCsrfTokenValid('otp', $request->request->get('token'))) {
+ throw $this->createAccessDeniedException('Bad CSRF token.');
+ }
+
$user = $this->getUser();
$user->setGoogleAuthenticatorSecret('');
@@ -319,10 +331,14 @@ class ConfigController extends AbstractController
/**
* Enable 2FA using OTP app, user will need to confirm the generated code from the app.
*
- * @Route("/config/otp/app", name="config_otp_app")
+ * @Route("/config/otp/app", name="config_otp_app", methods={"POST"})
*/
- public function otpAppAction(GoogleAuthenticatorInterface $googleAuthenticator)
+ public function otpAppAction(Request $request, GoogleAuthenticatorInterface $googleAuthenticator)
{
+ if (!$this->isCsrfTokenValid('otp', $request->request->get('token'))) {
+ throw $this->createAccessDeniedException('Bad CSRF token.');
+ }
+
$user = $this->getUser();
$secret = $googleAuthenticator->generateSecret();
@@ -372,10 +388,14 @@ class ConfigController extends AbstractController
/**
* Validate OTP code.
*
- * @Route("/config/otp/app/check", name="config_otp_app_check")
+ * @Route("/config/otp/app/check", name="config_otp_app_check", methods={"POST"})
*/
public function otpAppCheckAction(Request $request, GoogleAuthenticatorInterface $googleAuthenticator)
{
+ if (!$this->isCsrfTokenValid('otp', $request->request->get('token'))) {
+ throw $this->createAccessDeniedException('Bad CSRF token.');
+ }
+
$isValid = $googleAuthenticator->checkCode(
$this->getUser(),
$request->get('_auth_code')
diff --git a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
index c8544e428..cd5148db6 100644
--- a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
@@ -23,15 +23,6 @@ class UserInformationType extends AbstractType
->add('email', EmailType::class, [
'label' => 'config.form_user.email_label',
])
- ->add('emailTwoFactor', CheckboxType::class, [
- 'required' => false,
- 'label' => 'config.form_user.emailTwoFactor_label',
- ])
- ->add('googleTwoFactor', CheckboxType::class, [
- 'required' => false,
- 'label' => 'config.form_user.googleTwoFactor_label',
- 'mapped' => false,
- ])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
])
diff --git a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig
index c0d57c067..4d65e82ed 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig
@@ -209,6 +209,10 @@
{{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
+ {{ form_widget(form.user._token) }}
+
+ {{ form_end(form.user) }}
+