Skip to content

Commit 3c241fc

Browse files
committed
Remove support for edge case where username is empty
1 parent 2e1294d commit 3c241fc

File tree

3 files changed

+1
-26
lines changed

3 files changed

+1
-26
lines changed

src/Converter/UserConverter.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,8 @@
1010

1111
final class UserConverter implements UserConverterInterface
1212
{
13-
public const DEFAULT_ANONYMOUS_USER_IDENTIFIER = 'anonymous';
14-
15-
/** @var non-empty-string */
16-
private string $anonymousUserIdentifier;
17-
18-
/**
19-
* @param non-empty-string $anonymousUserIdentifier
20-
*/
21-
public function __construct(string $anonymousUserIdentifier = self::DEFAULT_ANONYMOUS_USER_IDENTIFIER)
22-
{
23-
$this->anonymousUserIdentifier = $anonymousUserIdentifier;
24-
}
25-
2613
/**
14+
* @psalm-suppress ArgumentTypeCoercion
2715
* @psalm-suppress DeprecatedMethod
2816
* @psalm-suppress UndefinedInterfaceMethod
2917
*/
@@ -32,9 +20,6 @@ public function toLeague(UserInterface $user): UserEntityInterface
3220
$userEntity = new User();
3321

3422
$identifier = method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername();
35-
if ('' === $identifier) {
36-
$identifier = $this->anonymousUserIdentifier;
37-
}
3823

3924
$userEntity->setIdentifier($identifier);
4025

src/DependencyInjection/Configuration.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace League\Bundle\OAuth2ServerBundle\DependencyInjection;
66

77
use Defuse\Crypto\Key;
8-
use League\Bundle\OAuth2ServerBundle\Converter\UserConverter;
98
use League\Bundle\OAuth2ServerBundle\Model\AbstractClient;
109
use League\Bundle\OAuth2ServerBundle\Model\Client;
1110
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
@@ -32,11 +31,6 @@ public function getConfigTreeBuilder(): TreeBuilder
3231
->defaultValue('ROLE_OAUTH2_')
3332
->cannotBeEmpty()
3433
->end()
35-
->scalarNode('anonymous_user_identifier')
36-
->info('Set a default user identifier for anonymous users')
37-
->defaultValue(UserConverter::DEFAULT_ANONYMOUS_USER_IDENTIFIER)
38-
->cannotBeEmpty()
39-
->end()
4034
->end();
4135

4236
return $treeBuilder;

src/DependencyInjection/LeagueOAuth2ServerExtension.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use League\Bundle\OAuth2ServerBundle\AuthorizationServer\GrantTypeInterface;
99
use League\Bundle\OAuth2ServerBundle\Command\CreateClientCommand;
1010
use League\Bundle\OAuth2ServerBundle\Command\GenerateKeyPairCommand;
11-
use League\Bundle\OAuth2ServerBundle\Converter\UserConverter;
1211
use League\Bundle\OAuth2ServerBundle\DBAL\Type\Grant as GrantType;
1312
use League\Bundle\OAuth2ServerBundle\DBAL\Type\RedirectUri as RedirectUriType;
1413
use League\Bundle\OAuth2ServerBundle\DBAL\Type\Scope as ScopeType;
@@ -69,9 +68,6 @@ public function load(array $configs, ContainerBuilder $container)
6968
$container->findDefinition(OAuth2Authenticator::class)
7069
->setArgument(3, $config['role_prefix']);
7170

72-
$container->findDefinition(UserConverter::class)
73-
->setArgument(0, $config['anonymous_user_identifier']);
74-
7571
$container->registerForAutoconfiguration(GrantTypeInterface::class)
7672
->addTag('league.oauth2_server.authorization_server.grant');
7773

0 commit comments

Comments
 (0)