Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ci-install:

# misc
clean:
rm -rf var/phpstan var/psalm var/php-cs-fixer.cache
rm -rf var/phpstan var/psalm var/php-cs-fixer.cache src/*/coverage.xml
smoke-test: clean update update-standalone phpunit cs sa
shell:
${qa} /bin/sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Lexik\Bundle\JWTAuthenticationBundle\Security\User\PayloadAwareUserProviderInterface;
use MsgPhp\Domain\Exception\EntityNotFoundException;
use MsgPhp\Domain\Factory\DomainObjectFactory;
use MsgPhp\User\Infrastructure\Security\SecurityUserProvider as BaseSecurityUserProvider;
use MsgPhp\User\Infrastructure\Security\UserIdentityProvider as BaseUserIdentityProvider;
use MsgPhp\User\Repository\UserRepository;
use MsgPhp\User\UserId;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
Expand All @@ -16,10 +16,10 @@
/**
* @author Damien Merchier <damien.merchier@gmail.com>
*/
final class SecurityUserProvider implements PayloadAwareUserProviderInterface
final class UserIdentityProvider implements PayloadAwareUserProviderInterface
{
/**
* @var BaseSecurityUserProvider
* @var BaseUserIdentityProvider
*/
private $provider;

Expand All @@ -33,7 +33,7 @@ final class SecurityUserProvider implements PayloadAwareUserProviderInterface
*/
private $factory;

public function __construct(BaseSecurityUserProvider $provider, UserRepository $repository, DomainObjectFactory $factory)
public function __construct(BaseUserIdentityProvider $provider, UserRepository $repository, DomainObjectFactory $factory)
{
$this->provider = $provider;
$this->repository = $repository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @author Roland Franssen <franssen.roland@gmail.com>
*/
final class SecurityUserProvider implements UserProviderInterface
final class UserIdentityProvider implements UserProviderInterface
{
/**
* @var UserRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use MsgPhp\Domain\Exception\EntityNotFoundException;
use MsgPhp\User\Credential\Credential;
use MsgPhp\User\Infrastructure\Security\SecurityUserProvider;
use MsgPhp\User\Infrastructure\Security\UserIdentity;
use MsgPhp\User\Infrastructure\Security\UserIdentityProvider;
use MsgPhp\User\Repository\UserRepository;
use MsgPhp\User\Role\RoleProvider;
use MsgPhp\User\ScalarUserId;
Expand All @@ -18,12 +18,12 @@
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;

final class SecurityUserProviderTest extends TestCase
final class UserIdentityProviderTest extends TestCase
{
public function testLoadUserByUsername(): void
{
/** @var UserIdentity $identity */
$identity = (new SecurityUserProvider($this->createRepository($entity = $this->createUser())))->loadUserByUsername('username');
$identity = (new UserIdentityProvider($this->createRepository($entity = $this->createUser())))->loadUserByUsername('username');

self::assertInstanceOf(UserIdentity::class, $identity);
self::assertSame($entity->getId(), $identity->getUserId());
Expand All @@ -37,7 +37,7 @@ public function testLoadUserByUsername(): void
public function testLoadUserByUsernameWithOriginUsername(): void
{
/** @var UserIdentity $identity */
$identity = (new SecurityUserProvider($this->createRepository($entity = $this->createUser())))->loadUserByUsername('origin-username');
$identity = (new UserIdentityProvider($this->createRepository($entity = $this->createUser())))->loadUserByUsername('origin-username');

self::assertInstanceOf(UserIdentity::class, $identity);
self::assertSame($entity->getId(), $identity->getUserId());
Expand All @@ -57,7 +57,7 @@ public function testLoadUserByUsernameWithRoles(): void
;

/** @var UserIdentity $identity */
$identity = (new SecurityUserProvider($this->createRepository($entity = $this->createUser()), $roleProvider))->loadUserByUsername('username');
$identity = (new UserIdentityProvider($this->createRepository($entity = $this->createUser()), $roleProvider))->loadUserByUsername('username');

self::assertInstanceOf(UserIdentity::class, $identity);
self::assertSame($entity->getId(), $identity->getUserId());
Expand All @@ -71,7 +71,7 @@ public function testLoadUserByUsernameWithRoles(): void

public function testLoadUserByUsernameWithUnknownUsername(): void
{
$provider = new SecurityUserProvider($this->createRepository());
$provider = new UserIdentityProvider($this->createRepository());

$this->expectException(UsernameNotFoundException::class);

Expand All @@ -80,7 +80,7 @@ public function testLoadUserByUsernameWithUnknownUsername(): void

public function testRefreshUser(): void
{
$provider = new SecurityUserProvider($this->createRepository($this->createUser()));
$provider = new UserIdentityProvider($this->createRepository($this->createUser()));

/** @var UserIdentity $refreshedIdentity */
$refreshedIdentity = $provider->refreshUser($user = $provider->loadUserByUsername('username'));
Expand All @@ -93,7 +93,7 @@ public function testRefreshUser(): void

public function testRefreshUserWithOriginUsername(): void
{
$provider = new SecurityUserProvider($this->createRepository($this->createUser()));
$provider = new UserIdentityProvider($this->createRepository($this->createUser()));

/** @var UserIdentity $refreshedIdentity */
$refreshedIdentity = $provider->refreshUser($user = $provider->loadUserByUsername('origin-username'));
Expand All @@ -106,7 +106,7 @@ public function testRefreshUserWithOriginUsername(): void

public function testRefreshUserWithUnknownUser(): void
{
$provider = new SecurityUserProvider($this->createRepository());
$provider = new UserIdentityProvider($this->createRepository());

$this->expectException(UsernameNotFoundException::class);

Expand All @@ -115,7 +115,7 @@ public function testRefreshUserWithUnknownUser(): void

public function testRefreshUserWithUnsupportedUser(): void
{
$provider = new SecurityUserProvider($this->createMock(UserRepository::class));
$provider = new UserIdentityProvider($this->createMock(UserRepository::class));

$this->expectException(UnsupportedUserException::class);

Expand All @@ -124,7 +124,7 @@ public function testRefreshUserWithUnsupportedUser(): void

public function testSupportsClass(): void
{
$provider = new SecurityUserProvider($this->createMock(UserRepository::class));
$provider = new UserIdentityProvider($this->createMock(UserRepository::class));

self::assertTrue($provider->supportsClass(UserIdentity::class));
self::assertFalse($provider->supportsClass(UserInterface::class));
Expand All @@ -138,7 +138,7 @@ public function testFromUser(): void
->willReturn(['ROLE_FOO'])
;

$provider = new SecurityUserProvider($this->createMock(UserRepository::class), $roleProvider);
$provider = new UserIdentityProvider($this->createMock(UserRepository::class), $roleProvider);
$identity = $provider->fromUser($user = $this->createUser());

self::assertSame($user->getId(), $identity->getUserId());
Expand All @@ -152,7 +152,7 @@ public function testFromUser(): void

public function testFromUserWithOriginUsername(): void
{
$provider = new SecurityUserProvider($this->createMock(UserRepository::class));
$provider = new UserIdentityProvider($this->createMock(UserRepository::class));
$identity = $provider->fromUser($user = $this->createUser(), 'origin-username');

self::assertSame('origin-username', $identity->getOriginUsername());
Expand Down
4 changes: 2 additions & 2 deletions src/UserBundle/DependencyInjection/Compiler/CleanupPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function process(ContainerBuilder $container): void
ConsoleInfrastructure\Command\DeleteUserRoleCommand::class,
ConsoleInfrastructure\Command\DisableUserCommand::class,
ConsoleInfrastructure\Command\EnableUserCommand::class,
SecurityInfrastructure\Jwt\SecurityUserProvider::class,
SecurityInfrastructure\SecurityUserProvider::class,
SecurityInfrastructure\Jwt\UserIdentityProvider::class,
SecurityInfrastructure\UserIdentityProvider::class,
SecurityInfrastructure\UserParamConverter::class,
SecurityInfrastructure\UserArgumentValueResolver::class,
ValidatorInfrastructure\ExistingUsernameValidator::class,
Expand Down
4 changes: 2 additions & 2 deletions src/UserBundle/Resources/config/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
->arg('$encoder', ref('.msgphp_user.security.password_hashing'))
->alias(PasswordHashing::class, Security\PasswordHashing::class)

->set(Security\SecurityUserProvider::class)
->set(Security\UserIdentityProvider::class)
->set(Security\UserArgumentValueResolver::class)
->tag('controller.argument_value_resolver')
;
Expand All @@ -40,6 +40,6 @@
}

if (interface_exists(PayloadAwareUserProviderInterface::class)) {
$services->set(Security\Jwt\SecurityUserProvider::class);
$services->set(Security\Jwt\UserIdentityProvider::class);
}
};
3 changes: 1 addition & 2 deletions src/UserBundle/Resources/skeleton/security.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
MsgPhp\User\Infrastructure\Security\UserIdentity: <?= $password_algorithm."\n" ?>
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
msgphp_user: { id: MsgPhp\User\Infrastructure\Security\SecurityUserProvider }
msgphp_user: { id: MsgPhp\User\Infrastructure\Security\UserIdentityProvider }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
Expand Down