mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-17 17:08:37 +00:00
move 2factor activation in parameters
This commit is contained in:
parent
0d6a7929e1
commit
18cf594f8a
5 changed files with 41 additions and 28 deletions
|
@ -45,6 +45,7 @@ twig:
|
||||||
export_mobi: %export_mobi%
|
export_mobi: %export_mobi%
|
||||||
export_pdf: %export_pdf%
|
export_pdf: %export_pdf%
|
||||||
version: %app.version%
|
version: %app.version%
|
||||||
|
twofactor_auth: %twofactor_auth%
|
||||||
warning_message: %warning_message%
|
warning_message: %warning_message%
|
||||||
paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb"
|
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"
|
flattr_url: "https://flattr.com/thing/1265480"
|
||||||
|
@ -179,7 +180,7 @@ scheb_two_factor:
|
||||||
cookie_lifetime: 2592000
|
cookie_lifetime: 2592000
|
||||||
|
|
||||||
email:
|
email:
|
||||||
enabled: true
|
enabled: %twofactor_auth%
|
||||||
sender_email: no-reply@wallabag.org
|
sender_email: %twofactor_sender%
|
||||||
digits: 6
|
digits: 6
|
||||||
template: WallabagUserBundle:Authentication:form.html.twig
|
template: WallabagUserBundle:Authentication:form.html.twig
|
||||||
|
|
|
@ -29,6 +29,8 @@ parameters:
|
||||||
|
|
||||||
# wallabag misc
|
# wallabag misc
|
||||||
app.version: 2.0.0-alpha
|
app.version: 2.0.0-alpha
|
||||||
|
twofactor_auth: true
|
||||||
|
twofactor_sender: no-reply@wallabag.org
|
||||||
|
|
||||||
# message to display at the bottom of the page
|
# message to display at the bottom of the page
|
||||||
warning_message: >
|
warning_message: >
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
{% if twofactor_auth %}
|
||||||
<fieldset class="w500p inline">
|
<fieldset class="w500p inline">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ form_label(form.user.twoFactorAuthentication) }}
|
{{ form_label(form.user.twoFactorAuthentication) }}
|
||||||
|
@ -107,6 +108,7 @@
|
||||||
{{ form_widget(form.user.twoFactorAuthentication) }}
|
{{ form_widget(form.user.twoFactorAuthentication) }}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form_rest(form.user) }}
|
{{ form_rest(form.user) }}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -132,6 +132,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if twofactor_auth %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
{{ form_widget(form.user.twoFactorAuthentication) }}
|
{{ form_widget(form.user.twoFactorAuthentication) }}
|
||||||
|
@ -139,6 +140,7 @@
|
||||||
{{ form_errors(form.user.twoFactorAuthentication) }}
|
{{ form_errors(form.user.twoFactorAuthentication) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="hidden">{{ form_rest(form.user) }}</div>
|
<div class="hidden">{{ form_rest(form.user) }}</div>
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="action">
|
<button class="btn waves-effect waves-light" type="submit" name="action">
|
||||||
|
|
|
@ -19,40 +19,46 @@ class SecurityControllerTest extends WallabagCoreTestCase
|
||||||
public function testLoginWith2Factor()
|
public function testLoginWith2Factor()
|
||||||
{
|
{
|
||||||
$client = $this->getClient();
|
$client = $this->getClient();
|
||||||
$client->followRedirects();
|
|
||||||
|
|
||||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
if ($client->getContainer()->getParameter('twofactor_auth')) {
|
||||||
$user = $em
|
$client->followRedirects();
|
||||||
->getRepository('WallabagUserBundle:User')
|
|
||||||
->findOneByUsername('admin');
|
|
||||||
$user->setTwoFactorAuthentication(true);
|
|
||||||
$em->persist($user);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
$this->logInAs('admin');
|
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
$client->request('GET', '/config');
|
$user = $em
|
||||||
$this->assertContains('trusted computer', $client->getResponse()->getContent());
|
->getRepository('WallabagUserBundle:User')
|
||||||
|
->findOneByUsername('admin');
|
||||||
|
$user->setTwoFactorAuthentication(true);
|
||||||
|
$em->persist($user);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
// restore user
|
$this->logInAs('admin');
|
||||||
$user = $em
|
$client->request('GET', '/config');
|
||||||
->getRepository('WallabagUserBundle:User')
|
$this->assertContains('trusted computer', $client->getResponse()->getContent());
|
||||||
->findOneByUsername('admin');
|
|
||||||
$user->setTwoFactorAuthentication(false);
|
// restore user
|
||||||
$em->persist($user);
|
$user = $em
|
||||||
$em->flush();
|
->getRepository('WallabagUserBundle:User')
|
||||||
|
->findOneByUsername('admin');
|
||||||
|
$user->setTwoFactorAuthentication(false);
|
||||||
|
$em->persist($user);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTrustedComputer()
|
public function testTrustedComputer()
|
||||||
{
|
{
|
||||||
$client = $this->getClient();
|
$client = $this->getClient();
|
||||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
|
||||||
$user = $em
|
|
||||||
->getRepository('WallabagUserBundle:User')
|
|
||||||
->findOneByUsername('admin');
|
|
||||||
|
|
||||||
$date = new \DateTime();
|
if ($client->getContainer()->getParameter('twofactor_auth')) {
|
||||||
$user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
|
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
$this->assertTrue($user->isTrustedComputer('ABCDEF'));
|
$user = $em
|
||||||
$this->assertFalse($user->isTrustedComputer('FEDCBA'));
|
->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…
Add table
Add a link
Reference in a new issue