Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Google Authenticator integration #1446

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Command/TwoStepVerificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* NEXT_MAJOR: stop extending ContainerAwareCommand.
* NEXT_MAJOR: Remove this command.
*
* @deprecated since sonata-project/user-bundle 4.x, it will be removed on 5.0.
*/
class TwoStepVerificationCommand extends ContainerAwareCommand
{
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getConfigTreeBuilder()
->end()
->end()
->arrayNode('google_authenticator')
->setDeprecated('The "%node%" option is deprecated.')
->addDefaultsIfNotSet()
->children()
->scalarNode('server')->cannotBeEmpty()->end()
Expand Down
15 changes: 13 additions & 2 deletions src/DependencyInjection/SonataUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ public function load(array $configs, ContainerBuilder $container): void

$loader->load('form.xml');

// NEXT_MAJOR: Remove this condition.
if (class_exists('Google\Authenticator\GoogleAuthenticator')) {
@trigger_error(
'The \'Google\Authenticator\' namespace is deprecated in sonata-project/GoogleAuthenticator since version 2.1 and will be removed in 3.0.',
\E_USER_DEPRECATED
);
}

// NEXT_MAJOR: Remove this condition and all the configuration related to this.
if (class_exists('Google\Authenticator\GoogleAuthenticator') ||
class_exists('Sonata\GoogleAuthenticator\GoogleAuthenticator')) {
$loader->load('google_authenticator.xml');
Expand Down Expand Up @@ -157,6 +159,8 @@ public function fixImpersonating(array $config)
}

/**
* NEXT_MAJOR: Remove this method.
*
* @param array $config
*
* @throws \RuntimeException
Expand All @@ -176,11 +180,18 @@ public function configureGoogleAuthenticator($config, ContainerBuilder $containe
return;
}

if (!class_exists('Google\Authenticator\GoogleAuthenticator')
&& !class_exists('Sonata\GoogleAuthenticator\GoogleAuthenticator')) {
if (
!class_exists('Google\Authenticator\GoogleAuthenticator')
&& !class_exists('Sonata\GoogleAuthenticator\GoogleAuthenticator')
) {
throw new \RuntimeException('Please add "sonata-project/google-authenticator" package');
}

@trigger_error(
'The Google Authenticator integration is deprecated since sonata-project/user-bundle 4.x and will be removed in 5.0.',
\E_USER_DEPRECATED
);

$container->setParameter('sonata.user.google.authenticator.forced_for_role', $config['google_authenticator']['forced_for_role']);

// NEXT_MAJOR: Remove this checks and only set the `trusted_ip_list`.
Expand Down
5 changes: 5 additions & 0 deletions src/GoogleAuthenticator/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

/**
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/user-bundle 4.x, it will be removed on 5.0.
*/
class Helper
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/GoogleAuthenticator/InteractiveLoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;

/**
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/user-bundle 4.x, it will be removed on 5.0.
*/
class InteractiveLoginListener
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/GoogleAuthenticator/RequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Twig\Environment;

/**
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/user-bundle 4.x, it will be removed on 5.0.
*/
class RequestListener
{
/**
Expand Down