Skip to content

Commit e38f578

Browse files
mbouchaalambouchaalaokanteerdnaxelaweb
authored
* 2fa support to ibexa 4.0 (#88)
* 2Fa support for ibexa 4.0 --------- Co-authored-by: mbouchaala <bouchaalamehrez@gmail.com> Co-authored-by: Ousmane KANTE <ousmane.kante@almaviacx.com> Co-authored-by: Florian ALEXANDRE <f.alexandre@novactive.com>
1 parent 207d9a5 commit e38f578

25 files changed

+94
-86
lines changed

components/2FABundle/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ security:
5757
...
5858
firewalls:
5959
...
60-
ezpublish_front:
60+
ibexa_front:
6161
pattern: ^/
6262
user_checker: eZ\Publish\Core\MVC\Symfony\Security\UserChecker
6363
anonymous: ~
64-
ezpublish_rest_session: ~
64+
ibexa_rest_session: ~
6565
form_login:
6666
require_previous_session: false
6767
csrf_token_generator: security.csrf.token_manager
@@ -104,15 +104,15 @@ scheb_two_factor:
104104
issuer: EzIssuer # Issuer name used in QR code
105105
digits: 6 # Number of digits in authentication code
106106
window: 1 # How many codes before/after the current one would be accepted as valid
107-
template: "@ezdesign/2fa/auth.html.twig" # Template for the 2FA login page
107+
template: "@ibexadesign/2fa/auth.html.twig" # Template for the 2FA login page
108108

109109
# TOTP Authenticator config
110110
totp:
111111
enabled: true # If TOTP authentication should be enabled, default false
112112
server_name: Server Name # Server name used in QR code
113113
issuer: TOTP Issuer # Issuer name used in QR code
114114
window: 1 # How many codes before/after the current one would be accepted as valid
115-
template: "@ezdesign/2fa/auth.html.twig" # Template used to render the authentication form
115+
template: "@ibexadesign/2fa/auth.html.twig" # Template used to render the authentication form
116116

117117
# Trusted device feature
118118
trusted_device:
@@ -133,7 +133,7 @@ scheb_two_factor:
133133
sender_email: me@example.com # Sender email address
134134
sender_name: John Doe # Sender name
135135
digits: 6 # Number of digits in authentication code
136-
template: "@ezdesign/2fa/auth.html.twig" # Template used to render the authentication form
136+
template: "@ibexadesign/2fa/auth.html.twig" # Template used to render the authentication form
137137

138138
# The security token classes, which trigger two-factor authentication.
139139
# By default the bundle only reacts to Symfony's username+password authentication. If you want to enable
@@ -211,4 +211,4 @@ php ezplatform/bin/console nova:2fa:remove-secret-key user_login
211211

212212
```
213213

214-
> **Note to keep in mind**: If you have the 2FA already set up for the user and you're going to reset it by following the corresponding link on the 2FA Setup page don't change the method for the current Siteaccess before that! Because in this case the secret key will be supposed to be removed for the new method not for the old one and hence the reset won't work!
214+
> **Note to keep in mind**: If you have the 2FA already set up for the user and you're going to reset it by following the corresponding link on the 2FA Setup page don't change the method for the current Siteaccess before that! Because in this case the secret key will be supposed to be removed for the new method not for the old one and hence the reset won't work!

components/2FABundle/bundle/Command/Remove2FAForUserCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Novactive\Bundle\eZ2FABundle\Command;
1414

15-
use eZ\Publish\Core\MVC\Symfony\Security\User;
15+
use Ibexa\Core\MVC\Symfony\Security\User;
1616
use Novactive\Bundle\eZ2FABundle\Core\UserRepository;
1717
use Symfony\Component\Console\Command\Command;
1818
use Symfony\Component\Console\Input\InputArgument;

components/2FABundle/bundle/Controller/TwoFactorAuthController.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
namespace Novactive\Bundle\eZ2FABundle\Controller;
1414

15-
use eZ\Publish\API\Repository\PermissionResolver;
16-
use eZ\Publish\API\Repository\UserService;
17-
use eZ\Publish\Core\MVC\Symfony\Security\User;
18-
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller;
15+
use Ibexa\Contracts\AdminUi\Controller\Controller;
16+
use Ibexa\Contracts\Core\Repository\PermissionResolver;
17+
use Ibexa\Contracts\Core\Repository\UserService;
18+
use Ibexa\Core\MVC\Symfony\Routing\Generator\UrlAliasGenerator;
19+
use Ibexa\Core\MVC\Symfony\Security\User;
1920
use Novactive\Bundle\eZ2FABundle\Core\QRCodeGenerator;
2021
use Novactive\Bundle\eZ2FABundle\Core\SiteAccessAwareAuthenticatorResolver;
2122
use Novactive\Bundle\eZ2FABundle\Form\Type\TwoFactorAuthType;
@@ -49,7 +50,7 @@ public function setupAction(
4950

5051
if ($saAuthenticatorResolver->checkIfUserSecretOrEmailExists($user)) {
5152
return $this->render(
52-
'@ezdesign/2fa/setup.html.twig',
53+
'@ibexadesign/2fa/setup.html.twig',
5354
[
5455
'reset' => true,
5556
'method' => $saAuthenticatorResolver->getMethod(),
@@ -78,7 +79,7 @@ public function setupAction(
7879

7980
if (!isset($methodForm) && null === $saAuthenticatorResolver->getMethod()) {
8081
return $this->render(
81-
'@ezdesign/2fa/setup.html.twig',
82+
'@ibexadesign/2fa/setup.html.twig',
8283
[
8384
'form' => null,
8485
'forced' => $saAuthenticatorResolver->isForceSetup(),
@@ -96,7 +97,7 @@ public function setupAction(
9697
!($methodForm->isSubmitted() && $methodForm->isValid())
9798
) {
9899
return $this->render(
99-
'@ezdesign/2fa/setup.html.twig',
100+
'@ibexadesign/2fa/setup.html.twig',
100101
[
101102
'form' => $methodForm->createView(),
102103
'forced' => $saAuthenticatorResolver->isForceSetup(),
@@ -109,7 +110,7 @@ public function setupAction(
109110
$saAuthenticatorResolver->setEmailAuthentication($user);
110111

111112
return $this->render(
112-
'@ezdesign/2fa/setup.html.twig',
113+
'@ibexadesign/2fa/setup.html.twig',
113114
[
114115
'success' => true,
115116
'method' => 'email',
@@ -124,7 +125,7 @@ public function setupAction(
124125
$result = $saAuthenticatorResolver->validateCodeAndUpdateUser($user, $qrCodeForm->getData());
125126
if ($result['valid']) {
126127
return $this->render(
127-
'@ezdesign/2fa/setup.html.twig',
128+
'@ibexadesign/2fa/setup.html.twig',
128129
[
129130
'success' => true,
130131
'method' => $saAuthenticatorResolver->getMethod(),
@@ -145,7 +146,7 @@ public function setupAction(
145146
}
146147

147148
return $this->render(
148-
'@ezdesign/2fa/setup.html.twig',
149+
'@ibexadesign/2fa/setup.html.twig',
149150
[
150151
'qrCode' => $QRCodeGenerator->createFromUser($user),
151152
'form' => $qrCodeForm->createView(),
@@ -180,7 +181,10 @@ public function resetAction(
180181

181182
if (isset($contentId, $locationId)) {
182183
return new RedirectResponse(
183-
$router->generate('_ez_content_view', ['contentId' => $contentId, 'locationId' => $locationId]).
184+
$router->generate(
185+
UrlAliasGenerator::INTERNAL_CONTENT_VIEW_ROUTE,
186+
['contentId' => $contentId, 'locationId' => $locationId]
187+
).
184188
'#ez-tab-location-view-reset-for-user#tab'
185189
);
186190
}

components/2FABundle/bundle/Core/BackupCodeManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Novactive\Bundle\eZ2FABundle\Core;
1616

17-
use eZ\Publish\Core\MVC\Symfony\Security\User;
17+
use Ibexa\Core\MVC\Symfony\Security\User;
1818
use Novactive\Bundle\eZ2FABundle\Entity\BackupCodeInterface;
1919
use Scheb\TwoFactorBundle\Security\TwoFactor\Backup\BackupCodeManagerInterface;
2020

components/2FABundle/bundle/Core/SiteAccessAwareAuthenticatorResolver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
namespace Novactive\Bundle\eZ2FABundle\Core;
1616

17-
use eZ\Publish\Core\MVC\ConfigResolverInterface;
18-
use eZ\Publish\Core\MVC\Symfony\Security\User;
19-
use eZ\Publish\Core\MVC\Symfony\SiteAccess;
20-
use eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
17+
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
18+
use Ibexa\Core\MVC\Symfony\Security\User;
19+
use Ibexa\Core\MVC\Symfony\SiteAccess;
20+
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
2121
use Novactive\Bundle\eZ2FABundle\DependencyInjection\Configuration;
2222
use Novactive\Bundle\eZ2FABundle\Entity\AuthenticatorInterface;
2323
use Novactive\Bundle\eZ2FABundle\Entity\BackupCodeInterface;
@@ -28,7 +28,7 @@
2828
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticator;
2929
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Totp\TotpAuthenticator;
3030

31-
final class SiteAccessAwareAuthenticatorResolver implements SiteAccessAware
31+
class SiteAccessAwareAuthenticatorResolver implements SiteAccessAware
3232
{
3333
/**
3434
* @var SiteAccess|null

components/2FABundle/bundle/Core/SiteAccessAwareQueryExecutor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use Doctrine\DBAL\Connection;
1818
use Doctrine\Persistence\ManagerRegistry as Registry;
19-
use eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider;
19+
use Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider;
2020

2121
final class SiteAccessAwareQueryExecutor
2222
{

components/2FABundle/bundle/Core/Tab/TwoFAManagement.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
namespace Novactive\Bundle\eZ2FABundle\Core\Tab;
1616

17-
use eZ\Publish\API\Repository\PermissionResolver;
18-
use eZ\Publish\API\Repository\UserService;
19-
use eZ\Publish\API\Repository\Values\Content\Content;
20-
use eZ\Publish\Core\MVC\Symfony\Security\User;
21-
use eZ\Publish\Core\Repository\Values\ContentType\ContentType;
22-
use EzSystems\EzPlatformAdminUi\Tab\AbstractTab;
23-
use EzSystems\EzPlatformAdminUi\Tab\ConditionalTabInterface;
24-
use EzSystems\EzPlatformAdminUi\Tab\OrderedTabInterface;
17+
use Ibexa\Contracts\AdminUi\Tab\AbstractTab;
18+
use Ibexa\Contracts\AdminUi\Tab\ConditionalTabInterface;
19+
use Ibexa\Contracts\AdminUi\Tab\OrderedTabInterface;
20+
use Ibexa\Contracts\Core\Repository\PermissionResolver;
21+
use Ibexa\Contracts\Core\Repository\UserService;
22+
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
23+
use Ibexa\Core\MVC\Symfony\Security\User;
24+
use Ibexa\Core\Repository\Values\ContentType\ContentType;
2525
use Novactive\Bundle\eZ2FABundle\Core\SiteAccessAwareAuthenticatorResolver;
2626
use Symfony\Contracts\Translation\TranslatorInterface;
2727
use Twig\Environment;
@@ -89,7 +89,7 @@ public function renderView(array $parameters): string
8989
$user = new User($this->userService->loadUser($content->id));
9090

9191
return $this->twig->render(
92-
'@ezdesign/2fa/tabs/reset_for_user.html.twig',
92+
'@ibexadesign/2fa/tabs/reset_for_user.html.twig',
9393
[
9494
'user' => $user,
9595
'isSetup' => $this->saAuthenticatorResolver->checkIfUserSecretOrEmailExists($user),

components/2FABundle/bundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Novactive\Bundle\eZ2FABundle\DependencyInjection;
1616

17-
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Configuration as SAConfiguration;
17+
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\Configuration as SAConfiguration;
1818
use Scheb\TwoFactorBundle\Model\Totp\TotpConfiguration;
1919
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
2020

components/2FABundle/bundle/DependencyInjection/NovaeZ2FAExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Novactive\Bundle\eZ2FABundle\DependencyInjection;
1616

17-
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
17+
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
1818
use Symfony\Component\Config\FileLocator;
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
2020
use Symfony\Component\DependencyInjection\Loader;

components/2FABundle/bundle/DependencyInjection/Security/PolicyProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Novactive\Bundle\eZ2FABundle\DependencyInjection\Security;
1616

17-
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider;
17+
use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider;
1818

1919
class PolicyProvider extends YamlPolicyProvider
2020
{

0 commit comments

Comments
 (0)