mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
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
This commit is contained in:
parent
acd4412080
commit
a6b242a1fd
36 changed files with 554 additions and 178 deletions
|
@ -26,7 +26,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
|
|||
$this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]);
|
||||
}
|
||||
|
||||
public function testLoginWith2Factor()
|
||||
public function testLoginWith2FactorEmail()
|
||||
{
|
||||
$client = $this->getClient();
|
||||
|
||||
|
@ -42,7 +42,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
|
|||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUsername('admin');
|
||||
$user->setTwoFactorAuthentication(true);
|
||||
$user->setEmailTwoFactor(true);
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
|
@ -54,12 +54,12 @@ class SecurityControllerTest extends WallabagCoreTestCase
|
|||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUsername('admin');
|
||||
$user->setTwoFactorAuthentication(false);
|
||||
$user->setEmailTwoFactor(false);
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
public function testTrustedComputer()
|
||||
public function testLoginWith2FactorGoogle()
|
||||
{
|
||||
$client = $this->getClient();
|
||||
|
||||
|
@ -69,15 +69,27 @@ class SecurityControllerTest extends WallabagCoreTestCase
|
|||
return;
|
||||
}
|
||||
|
||||
$client->followRedirects();
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUsername('admin');
|
||||
$user->setGoogleAuthenticatorSecret('26LDIHYGHNELOQEM');
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
$date = new \DateTime();
|
||||
$user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
|
||||
$this->assertTrue($user->isTrustedComputer('ABCDEF'));
|
||||
$this->assertFalse($user->isTrustedComputer('FEDCBA'));
|
||||
$this->logInAsUsingHttp('admin');
|
||||
$crawler = $client->request('GET', '/config');
|
||||
$this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
|
||||
|
||||
// restore user
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUsername('admin');
|
||||
$user->setGoogleAuthenticatorSecret(null);
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
public function testEnabledRegistration()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue