Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Remove everything related to the deprecated authentication manager#41613

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,8 +117,7 @@ public function createNewToken(PersistentTokenInterface $token)
$sql = 'INSERT INTO rememberme_token (class, username, series, value, lastUsed) VALUES (:class, :username, :series, :value, :lastUsed)';
$paramValues = [
'class' => $token->getClass(),
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
'username' => method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(),
'username' => $token->getUserIdentifier(),
'series' => $token->getSeries(),
'value' => $token->getTokenValue(),
'lastUsed' => $token->getLastUsed(),
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,16 +46,6 @@ public function __construct(ManagerRegistry $registry, string $classOrAlias, str
$this->property = $property;
}

/**
* {@inheritdoc}
*/
public function loadUserByUsername(string $username): UserInterface
{
trigger_deprecation('symfony/doctrine-bridge', '5.3', 'Method "%s()" is deprecated, use loadUserByIdentifier() instead.', __METHOD__);

return $this->loadUserByIdentifier($username);
}

public function loadUserByIdentifier(string $identifier): UserInterface
{
$repository = $this->getRepository();
Expand All@@ -66,14 +56,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_debug_type($repository)));
}

// @deprecated since Symfony 5.3, change to $repository->loadUserByIdentifier() in 6.0
if (method_exists($repository, 'loadUserByIdentifier')) {
$user = $repository->loadUserByIdentifier($identifier);
} else {
trigger_deprecation('symfony/doctrine-bridge', '5.3', 'Not implementing method "loadUserByIdentifier()" in user loader "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($repository));

$user = $repository->loadUserByUsername($identifier);
}
$user = $repository->loadUserByIdentifier($identifier);
}

if (null === $user) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,15 +22,14 @@
*
* @see UserInterface
*
* @method UserInterface|null loadUserByIdentifier(string $identifier) loads the user for the given user identifier (e.g. username or email).
* This method must return null if the user is not found.
*
* @author Michal Trojanowski <michal@kmt-studio.pl>
*/
interface UserLoaderInterface
{
/**
* @deprecated since Symfony 5.3, use loadUserByIdentifier() instead
* Loads the user for the given user identifier (e.g. username or email).
*
* This method must return null if the user is not found.
*/
public functionloadUserByUsername(string $username): ?UserInterface;
public functionloadUserByIdentifier(string $identifier): ?UserInterface;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,12 +46,7 @@ public function __invoke(array $record): array
'roles' => $token->getRoleNames(),
];

// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
if (method_exists($token, 'getUserIdentifier')) {
$record['extra'][$this->getKey()]['username'] = $record['extra'][$this->getKey()]['user_identifier'] = $token->getUserIdentifier();
} else {
$record['extra'][$this->getKey()]['username'] = $token->getUsername();
}
$record['extra'][$this->getKey()]['user_identifier'] = $token->getUserIdentifier();
}

return $record;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,6 @@
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\User;

/**
* Tests the SwitchUserTokenProcessor.
Expand All@@ -28,13 +27,8 @@ class SwitchUserTokenProcessorTest extends TestCase
{
public function testProcessor()
{
if (class_exists(InMemoryUser::class)) {
$originalToken = new UsernamePasswordToken(new InMemoryUser('original_user', 'password', ['ROLE_SUPER_ADMIN']), 'provider', ['ROLE_SUPER_ADMIN']);
$switchUserToken = new SwitchUserToken(new InMemoryUser('user', 'passsword', ['ROLE_USER']), 'provider', ['ROLE_USER'], $originalToken);
} else {
$originalToken = new UsernamePasswordToken(new User('original_user', 'password', ['ROLE_SUPER_ADMIN']), null, 'provider', ['ROLE_SUPER_ADMIN']);
$switchUserToken = new SwitchUserToken(new User('user', 'passsword', ['ROLE_USER']), null, 'provider', ['ROLE_USER'], $originalToken);
}
$originalToken = new UsernamePasswordToken(new InMemoryUser('original_user', 'password', ['ROLE_SUPER_ADMIN']), 'provider', ['ROLE_SUPER_ADMIN']);
$switchUserToken = new SwitchUserToken(new InMemoryUser('user', 'passsword', ['ROLE_USER']), 'provider', ['ROLE_USER'], $originalToken);
$tokenStorage = $this->createMock(TokenStorageInterface::class);
$tokenStorage->method('getToken')->willReturn($switchUserToken);

Expand All@@ -46,12 +40,9 @@ public function testProcessor()
'impersonator_token' => [
'authenticated' => true,
'roles' => ['ROLE_SUPER_ADMIN'],
'username' => 'original_user',
'user_identifier' => 'original_user',
],
];
if (method_exists($originalToken, 'getUserIdentifier')) {
$expected['impersonator_token']['user_identifier'] = 'original_user';
}

$this->assertEquals($expected, $record['extra']);
}
Expand Down
5 changes: 3 additions & 2 deletionssrc/Symfony/Bridge/Monolog/composer.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,15 +24,16 @@
"require-dev": {
"symfony/console": "^5.4|^6.0",
"symfony/http-client": "^5.4|^6.0",
"symfony/security-core": "^5.4|^6.0",
"symfony/security-core": "^6.0",
"symfony/var-dumper": "^5.4|^6.0",
"symfony/mailer": "^5.4|^6.0",
"symfony/mime": "^5.4|^6.0",
"symfony/messenger": "^5.4|^6.0"
},
"conflict": {
"symfony/console": "<5.4",
"symfony/http-foundation": "<5.4"
"symfony/http-foundation": "<5.4",
"symfony/security-core": "<6.0"
},
"suggest": {
"symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.",
Expand Down
5 changes: 1 addition & 4 deletionssrc/Symfony/Bridge/Twig/AppVariable.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,10 +78,7 @@ public function getUser(): ?object
return null;
}

$user = $token->getUser();

// @deprecated since 5.4, $user will always be a UserInterface instance
return \is_object($user) ? $user : null;
return $token->getUser();
}

/**
Expand Down
7 changes: 0 additions & 7 deletionssrc/Symfony/Bridge/Twig/Tests/AppVariableTest.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,13 +95,6 @@ public function testGetUser()
$this->assertEquals($user, $this->appVariable->getUser());
}

public function testGetUserWithUsernameAsTokenUser()
{
$this->setTokenStorage($user = 'username');

$this->assertNull($this->appVariable->getUser());
}

public function testGetTokenWithNoToken()
{
$tokenStorage = $this->createMock(TokenStorageInterface::class);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -409,13 +409,7 @@ protected function getUser(): ?object
return null;
}

// @deprecated since 5.4, $user will always be a UserInterface instance
if (!\is_object($user = $token->getUser())) {
// e.g. anonymous authentication
return null;
}

return $user;
return $token->getUser();
}

/**
Expand Down
2 changes: 1 addition & 1 deletionsrc/Symfony/Bundle/FrameworkBundle/KernelBrowser.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ public function loginUser(object $user, string $firewallContext = 'main'): self
}

$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
//@deprecated since Symfony 5.4
//required for compatibilty with Symfony 5.4
if (method_exists($token, 'isAuthenticated')) {
$token->setAuthenticated(true, false);
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,7 +39,6 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
Expand DownExpand Up@@ -146,19 +145,6 @@ public function testGetUser()
$this->assertSame($controller->getUser(), $user);
}

/**
* @group legacy
*/
public function testGetUserAnonymousUserConvertedToNull()
{
$token = new AnonymousToken('default', 'anon.');

$controller = $this->createController();
$controller->setContainer($this->getContainerWithTokenStorage($token));

$this->assertNull($controller->getUser());
}

public function testGetUserWithEmptyTokenStorage()
{
$controller = $this->createController();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,23 +35,17 @@ final class DebugFirewallCommand extends Command
private $contexts;
private $eventDispatchers;
private $authenticators;
private $authenticatorManagerEnabled;

/**
* @param string[] $firewallNames
* @param AuthenticatorInterface[][] $authenticators
*/
public function __construct(array $firewallNames, ContainerInterface $contexts, ContainerInterface $eventDispatchers, array $authenticators, bool $authenticatorManagerEnabled)
public function __construct(array $firewallNames, ContainerInterface $contexts, ContainerInterface $eventDispatchers, array $authenticators)
{
if (!$authenticatorManagerEnabled) {
trigger_deprecation('symfony/security-bundle', '5.4', 'Setting the $authenticatorManagerEnabled argument of "%s" to "false" is deprecated, use the new authenticator system instead.', __METHOD__);
}

$this->firewallNames = $firewallNames;
$this->contexts = $contexts;
$this->eventDispatchers = $eventDispatchers;
$this->authenticators = $authenticators;
$this->authenticatorManagerEnabled = $authenticatorManagerEnabled;

parent::__construct();
}
Expand DownExpand Up@@ -119,9 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->displayEventListeners($name, $context, $io);
}

if ($this->authenticatorManagerEnabled) {
$this->displayAuthenticators($name, $io);
}
$this->displayAuthenticators($name, $io);

return 0;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,6 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
Expand All@@ -44,22 +43,16 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
private $firewallMap;
private $firewall;
private $hasVarDumper;
private $authenticatorManagerEnabled;

public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null, bool $authenticatorManagerEnabled = false)
public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null)
{
if (!$authenticatorManagerEnabled) {
trigger_deprecation('symfony/security-bundle', '5.4', 'Setting the $authenticatorManagerEnabled argument of "%s" to "false" is deprecated, use the new authenticator system instead.', __METHOD__);
}

$this->tokenStorage = $tokenStorage;
$this->roleHierarchy = $roleHierarchy;
$this->logoutUrlGenerator = $logoutUrlGenerator;
$this->accessDecisionManager = $accessDecisionManager;
$this->firewallMap = $firewallMap;
$this->firewall = $firewall;
$this->hasVarDumper = class_exists(ClassStub::class);
$this->authenticatorManagerEnabled = $authenticatorManagerEnabled;
}

/**
Expand DownExpand Up@@ -104,8 +97,7 @@ public function collect(Request $request, Response $response, \Throwable $except
$impersonatorUser = null;
if ($token instanceof SwitchUserToken) {
$originalToken = $token->getOriginalToken();
// @deprecated since Symfony 5.3, change to $originalToken->getUserIdentifier() in 6.0
$impersonatorUser = method_exists($originalToken, 'getUserIdentifier') ? $originalToken->getUserIdentifier() : $originalToken->getUsername();
$impersonatorUser = $originalToken->getUserIdentifier();
}

if (null !== $this->roleHierarchy) {
Expand All@@ -118,7 +110,7 @@ public function collect(Request $request, Response $response, \Throwable $except

$logoutUrl = null;
try {
if (null !== $this->logoutUrlGenerator && !$token instanceof AnonymousToken) {
if (null !== $this->logoutUrlGenerator) {
$logoutUrl = $this->logoutUrlGenerator->getLogoutPath();
}
} catch (\Exception $e) {
Expand All@@ -134,8 +126,7 @@ public function collect(Request $request, Response $response, \Throwable $except
'token' => $token,
'token_class' => $this->hasVarDumper ? new ClassStub(\get_class($token)) : \get_class($token),
'logout_url' => $logoutUrl,
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
'user' => method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(),
'user' => $token->getUserIdentifier(),
'roles' => $assignedRoles,
'inherited_roles' => array_unique($inheritedRoles),
'supports_role_hierarchy' => null !== $this->roleHierarchy,
Expand DownExpand Up@@ -184,7 +175,6 @@ public function collect(Request $request, Response $response, \Throwable $except
if (null !== $firewallConfig) {
$this->data['firewall'] = [
'name' => $firewallConfig->getName(),
'allows_anonymous' => $this->authenticatorManagerEnabled ? false : $firewallConfig->allowsAnonymous(),
'request_matcher' => $firewallConfig->getRequestMatcher(),
'security_enabled' => $firewallConfig->isSecurityEnabled(),
'stateless' => $firewallConfig->isStateless(),
Expand DownExpand Up@@ -213,8 +203,6 @@ public function collect(Request $request, Response $response, \Throwable $except
if ($this->firewall) {
$this->data['listeners'] = $this->firewall->getWrappedListeners();
}

$this->data['authenticator_manager_enabled'] = $this->authenticatorManagerEnabled;
}

/**
Expand DownExpand Up@@ -362,9 +350,4 @@ public function getName(): string
{
return 'security';
}

public function isAuthenticatorManagerEnabled(): bool
{
return $this->data['authenticator_manager_enabled'];
}
}

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp