move 2factor activation in parameters
This commit is contained in:
parent
0d6a7929e1
commit
18cf594f8a
@ -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
|
||||
|
@ -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: >
|
||||
|
@ -100,6 +100,7 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{% if twofactor_auth %}
|
||||
<fieldset class="w500p inline">
|
||||
<div class="row">
|
||||
{{ form_label(form.user.twoFactorAuthentication) }}
|
||||
@ -107,6 +108,7 @@
|
||||
{{ form_widget(form.user.twoFactorAuthentication) }}
|
||||
</div>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
|
||||
{{ form_rest(form.user) }}
|
||||
</form>
|
||||
|
@ -132,6 +132,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if twofactor_auth %}
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
{{ form_widget(form.user.twoFactorAuthentication) }}
|
||||
@ -139,6 +140,7 @@
|
||||
{{ 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">
|
||||
|
@ -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());
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUsername('admin');
|
||||
$user->setTwoFactorAuthentication(true);
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
// restore user
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUsername('admin');
|
||||
$user->setTwoFactorAuthentication(false);
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user