]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
move 2factor activation in parameters
authorNicolas Lœuillet <nicolas.loeuillet@smile.fr>
Thu, 15 Oct 2015 11:17:21 +0000 (13:17 +0200)
committerNicolas Lœuillet <nicolas.loeuillet@smile.fr>
Thu, 15 Oct 2015 11:17:21 +0000 (13:17 +0200)
app/config/config.yml
app/config/parameters.yml.dist
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php

index 4a2c02bf9370e1b7d90fe5ccf92ff5b413ffe9da..956fdd07c7d5174983bd566863c9b3f535af3b93 100644 (file)
@@ -45,6 +45,7 @@ twig:
         export_mobi: %export_mobi%
         export_pdf: %export_pdf%
         version: %app.version%
+        twofactor_auth: %twofactor_auth%
         warning_message: %warning_message%
         paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb"
         flattr_url: "https://flattr.com/thing/1265480"
@@ -179,7 +180,7 @@ scheb_two_factor:
         cookie_lifetime: 2592000
 
     email:
-        enabled: true
-        sender_email: no-reply@wallabag.org
+        enabled: %twofactor_auth%
+        sender_email: %twofactor_sender%
         digits: 6
         template: WallabagUserBundle:Authentication:form.html.twig
index c1f6bc1ba883ea6c889b008d0a3e6a023ea9d6e6..52f9bccbca8af43b5c444b85da602cd6cc3c5f3d 100644 (file)
@@ -29,6 +29,8 @@ parameters:
 
     # wallabag misc
     app.version: 2.0.0-alpha
+    twofactor_auth: true
+    twofactor_sender: no-reply@wallabag.org
 
     # message to display at the bottom of the page
     warning_message: >
index cee4f672c8602419420ad576f691efcc6ed9b9c6..abe5dc9ee6a082548f48d7809848847495caeb9b 100644 (file)
             </div>
         </fieldset>
 
+        {% if twofactor_auth %}
         <fieldset class="w500p inline">
             <div class="row">
                 {{ form_label(form.user.twoFactorAuthentication) }}
                 {{ form_widget(form.user.twoFactorAuthentication) }}
             </div>
         </fieldset>
+        {% endif %}
 
         {{ form_rest(form.user) }}
     </form>
index b20c4ea50772cee573497eb76a2727fea2c6208f..ab24d4effad16536bf369f0b24a9f24be2589262 100644 (file)
                                 </div>
                             </div>
 
+                            {% if twofactor_auth %}
                             <div class="row">
                                 <div class="input-field col s12">
                                     {{ form_widget(form.user.twoFactorAuthentication) }}
                                     {{ form_errors(form.user.twoFactorAuthentication) }}
                                 </div>
                             </div>
+                            {% endif %}
 
                             <div class="hidden">{{ form_rest(form.user) }}</div>
                             <button class="btn waves-effect waves-light" type="submit" name="action">
index 3402b3402c73b33569bac7a77987cd4ad8eaf1ed..b9f5d835589676beb6890612a2e39d6ee93e1a06 100644 (file)
@@ -19,40 +19,46 @@ class SecurityControllerTest extends WallabagCoreTestCase
     public function testLoginWith2Factor()
     {
         $client = $this->getClient();
-        $client->followRedirects();
 
-        $em = $client->getContainer()->get('doctrine.orm.entity_manager');
-        $user = $em
-            ->getRepository('WallabagUserBundle:User')
-            ->findOneByUsername('admin');
-        $user->setTwoFactorAuthentication(true);
-        $em->persist($user);
-        $em->flush();
+        if ($client->getContainer()->getParameter('twofactor_auth')) {
+            $client->followRedirects();
 
-        $this->logInAs('admin');
-        $client->request('GET', '/config');
-        $this->assertContains('trusted computer', $client->getResponse()->getContent());
-
-        // restore user
-        $user = $em
-            ->getRepository('WallabagUserBundle:User')
-            ->findOneByUsername('admin');
-        $user->setTwoFactorAuthentication(false);
-        $em->persist($user);
-        $em->flush();
+            $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+            $user = $em
+                ->getRepository('WallabagUserBundle:User')
+                ->findOneByUsername('admin');
+            $user->setTwoFactorAuthentication(true);
+            $em->persist($user);
+            $em->flush();
+
+            $this->logInAs('admin');
+            $client->request('GET', '/config');
+            $this->assertContains('trusted computer', $client->getResponse()->getContent());
+
+            // restore user
+            $user = $em
+                ->getRepository('WallabagUserBundle:User')
+                ->findOneByUsername('admin');
+            $user->setTwoFactorAuthentication(false);
+            $em->persist($user);
+            $em->flush();
+        }
     }
 
     public function testTrustedComputer()
     {
         $client = $this->getClient();
-        $em = $client->getContainer()->get('doctrine.orm.entity_manager');
-        $user = $em
-            ->getRepository('WallabagUserBundle:User')
-            ->findOneByUsername('admin');
-
-        $date = new \DateTime();
-        $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
-        $this->assertTrue($user->isTrustedComputer('ABCDEF'));
-        $this->assertFalse($user->isTrustedComputer('FEDCBA'));
+
+        if ($client->getContainer()->getParameter('twofactor_auth')) {
+            $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+            $user = $em
+                ->getRepository('WallabagUserBundle:User')
+                ->findOneByUsername('admin');
+
+            $date = new \DateTime();
+            $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
+            $this->assertTrue($user->isTrustedComputer('ABCDEF'));
+            $this->assertFalse($user->isTrustedComputer('FEDCBA'));
+        }
     }
 }