prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* InsufficientAuthenticat... | er <fabien@symfony.com>
* @author Alexander <iam.asm89@gmail.com>
*/
class InsufficientAuthenticationException extends AuthenticationException
{
public function getMessageKey(): string
{
return 'Not privileged to request the resource.';
| Fabien Potenci | {
"filepath": "src/Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php",
"language": "php",
"file_size": 791,
"cut_index": 514,
"middle_length": 14
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* This exception is thrown if there... | int) $this->threshold,
];
}
public function getMessageKey(): string
{
return 'Too many failed login attempts, please try again '.($this->threshold ? 'in %minutes% minute'.($this->threshold > 1 ? 's' : '').'.' : 'later.');
} |
{
public function __construct(
private ?int $threshold = null,
) {
}
public function getMessageData(): array
{
return [
'%minutes%' => $this->threshold,
'%count%' => ( | {
"filepath": "src/Symfony/Component/Security/Core/Exception/TooManyLoginAttemptsAuthenticationException.php",
"language": "php",
"file_size": 1283,
"cut_index": 524,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* UserNotFoundException is thrown i... | ddress).
*/
public function getUserIdentifier(): ?string
{
return $this->identifier;
}
/**
* Set the user identifier (e.g. username or email address).
*/
public function setUserIdentifier(string $identifier): voi | ticationException
{
private ?string $identifier = null;
public function getMessageKey(): string
{
return 'Username could not be found.';
}
/**
* Get the user identifier (e.g. username or email a | {
"filepath": "src/Symfony/Component/Security/Core/Exception/UserNotFoundException.php",
"language": "php",
"file_size": 1498,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication\RememberMe;
use Psr\Cache\CacheItemPoolInterface;
/**
* @author Jordi Bog... | * but you may use a lower value.
*/
public function __construct(
private CacheItemPoolInterface $cache,
private int $outdatedTokenTtl = 60,
private string $cacheKeyPrefix = 'rememberme-stale | alid. Defaults
* to 60, which matches how often the PersistentRememberMeHandler will at
* most refresh tokens. Increasing to more than that is not recommended,
| {
"filepath": "src/Symfony/Component/Security/Core/Authentication/RememberMe/CacheTokenVerifier.php",
"language": "php",
"file_size": 2240,
"cut_index": 563,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication\RememberMe;
/**
* Interf... | me the token was last used.
*
* Each call SHOULD return a new distinct DateTime instance.
*/
public function getLastUsed(): \DateTime;
/**
* Returns the identifier used to authenticate (e.g. their email address or username).
| tentTokenInterface
{
/**
* Returns the series.
*/
public function getSeries(): string;
/**
* Returns the token value.
*/
public function getTokenValue(): string;
/**
* Returns the ti | {
"filepath": "src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php",
"language": "php",
"file_size": 1055,
"cut_index": 513,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication\Token;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* ... | ` and deauthenticating
* when they diverge.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
abstract class AbstractToken implements TokenInterface
{
private ?UserInterface $user = null;
| ent role assignment. This is why `setUser()` only
* updates the user reference and leaves the role names untouched. `ContextListener` is the component
* responsible for comparing the stored role names against `$user->getRoles() | {
"filepath": "src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php",
"language": "php",
"file_size": 4376,
"cut_index": 614,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication\Token;
use Symfony\Component\Securit... | parent::__construct($user->getRoles());
if (!$firewallName) {
throw new InvalidArgumentException('$firewallName must not be empty.');
}
$this->setUser($user);
}
public function getFirewallName(): string
| @gmail.com>
*/
class RememberMeToken extends AbstractToken
{
/**
* @throws \InvalidArgumentException
*/
public function __construct(
UserInterface $user,
private string $firewallName,
) {
| {
"filepath": "src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php",
"language": "php",
"file_size": 1344,
"cut_index": 524,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Http\Authenticator\Passport\Credentials;
use Symfony\Component\Securi... | erInterface): bool $customCredentialsChecker If the callable does not return `true`, a
* BadCredentialsException is thrown. You may
* | de Jong <wouter@wouterj.nl>
*
* @final
*/
class CustomCredentials implements CredentialsInterface
{
private \Closure $customCredentialsChecker;
private bool $resolved = false;
/**
* @param callable(mixed, Us | {
"filepath": "src/Symfony/Component/Security/Http/Authenticator/Passport/Credentials/CustomCredentials.php",
"language": "php",
"file_size": 1762,
"cut_index": 537,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Http\Authenticator\Passport\Credentials;
use Symfony\Com... | ensitiveParameter] string $password)
{
$this->password = $password;
}
public function getPassword(): string
{
if (null === $this->password) {
throw new LogicException('The credentials are erased as another liste | uthor Wouter de Jong <wouter@wouterj.nl>
*
* @final
*/
class PasswordCredentials implements CredentialsInterface
{
private ?string $password = null;
private bool $resolved = false;
public function __construct(#[\S | {
"filepath": "src/Symfony/Component/Security/Http/Authenticator/Passport/Credentials/PasswordCredentials.php",
"language": "php",
"file_size": 1338,
"cut_index": 524,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
use Symfony\Component\Security\Cor... | UserInterface
{
return $this->user;
}
public function setUser(UserInterface $user): void
{
$this->user = $user;
}
public function __serialize(): array
{
return [$this->user, parent::__serialize()];
| * @author Alexander <iam.asm89@gmail.com>
*/
abstract class AccountStatusException extends AuthenticationException
{
private ?UserInterface $user = null;
/**
* Get the user.
*/
public function getUser(): ? | {
"filepath": "src/Symfony/Component/Security/Core/Exception/AccountStatusException.php",
"language": "php",
"file_size": 1161,
"cut_index": 518,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* An authentication exception where you can cont... | ivate array $messageData = [];
public function __construct(string $message = '', array $messageData = [], int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->setSafeMessage($messa | ions and passing their message directly to this class.
*
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class CustomUserMessageAuthenticationException extends AuthenticationException
{
private string $messageKey;
pr | {
"filepath": "src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php",
"language": "php",
"file_size": 1937,
"cut_index": 537,
"middle_length": 229
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication;
use Symfony\Component\Secu... | return $token && $token->getUser();
}
public function isRememberMe(?TokenInterface $token = null): bool
{
return $token && $token instanceof RememberMeToken;
}
public function isFullFledged(?TokenInterface $token = null): | .
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class AuthenticationTrustResolver implements AuthenticationTrustResolverInterface
{
public function isAuthenticated(?TokenInterface $token = null): bool
{
| {
"filepath": "src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php",
"language": "php",
"file_size": 1099,
"cut_index": 515,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication\RememberMe;
/**
* @author Johannes M. Schmitt <s... | InvalidArgumentException('$userIdentifier must not be empty.');
}
if (!$series) {
throw new \InvalidArgumentException('$series must not be empty.');
}
if (!$tokenValue) {
throw new \InvalidArgumentExc | rivate string $userIdentifier,
private string $series,
#[\SensitiveParameter] private string $tokenValue,
\DateTimeInterface $lastUsed,
) {
if ('' === $userIdentifier) {
throw new \ | {
"filepath": "src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php",
"language": "php",
"file_size": 1556,
"cut_index": 537,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Http\Authenticator\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
use Symfony\Component\Securi... | ends Passport
{
/**
* @param BadgeInterface[] $badges
*/
public function __construct(UserBadge $userBadge, array $badges = [])
{
$this->addBadge($userBadge);
foreach ($badges as $badge) {
$this->addBadge($b | ter@wouterj.nl>
*/
class SelfValidatingPassport ext | {
"filepath": "src/Symfony/Component/Security/Http/Authenticator/Passport/SelfValidatingPassport.php",
"language": "php",
"file_size": 939,
"cut_index": 606,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Authenticator;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Comp... | ore\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterf | ity\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\C | {
"filepath": "src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php",
"language": "php",
"file_size": 7262,
"cut_index": 716,
"middle_length": 229
} |
php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* AuthenticationExpiredEx... | r Ryan Weaver <ryan@knpuniversity.com>
*/
class AuthenticationExpiredException extends AccountStatusException
{
public function getMessageKey(): string
{
return 'Authentication expired because your account information has changed.';
}
| s the token to become un-authenticated.
*
* @autho | {
"filepath": "src/Symfony/Component/Security/Core/Exception/AuthenticationExpiredException.php",
"language": "php",
"file_size": 824,
"cut_index": 514,
"middle_length": 52
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authentication;
use Symfony\Component\Secu... | whether the passed token implementation is authenticated
* using remember-me capabilities.
*/
public function isRememberMe(?TokenInterface $token = null): bool;
/**
* Resolves whether the passed token implementation is fully authen | e AuthenticationTrustResolverInterface
{
/**
* Resolves whether the passed token implementation is authenticated.
*/
public function isAuthenticated(?TokenInterface $token = null): bool;
/**
* Resolves | {
"filepath": "src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolverInterface.php",
"language": "php",
"file_size": 1091,
"cut_index": 515,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Role;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class RoleHierarchy impleme... | le) {
$reachableRoles[$role] = $role;
if (!isset($this->map[$role])) {
continue;
}
foreach ($this->map[$role] as $r) {
$reachableRoles[$r] = $r;
}
}
| ction __construct(
private array $hierarchy,
) {
$this->buildRoleMap();
}
public function getReachableRoleNames(array $roles): array
{
$reachableRoles = [];
foreach ($roles as $ro | {
"filepath": "src/Symfony/Component/Security/Core/Role/RoleHierarchy.php",
"language": "php",
"file_size": 2553,
"cut_index": 563,
"middle_length": 229
} |
ackage.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* This exception is thrown when no session is available.
*
* Possibl... | m>
* @author Alexander <iam.asm89@gmail.com>
*/
class SessionUnavailableException extends AuthenticationException
{
public function getMessageKey(): string
{
return 'No session available, it either timed out or cookies are not enabled.';
|
* @author Johannes M. Schmitt <schmittjoh@gmail.co | {
"filepath": "src/Symfony/Component/Security/Core/Exception/SessionUnavailableException.php",
"language": "php",
"file_size": 875,
"cut_index": 559,
"middle_length": 52
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\RememberMe;
use PHPUnit\Framework\TestCase;... | 'series1@special:chars=/', 'value', new \DateTimeImmutable());
$this->assertTrue($verifier->verifyToken($token, 'value'));
}
public function testVerifyFailsInvalidToken()
{
$verifier = new CacheTokenVerifier(new ArrayAdapter()) | Me\PersistentToken;
class CacheTokenVerifierTest extends TestCase
{
public function testVerifyCurrentToken()
{
$verifier = new CacheTokenVerifier(new ArrayAdapter());
$token = new PersistentToken('user', | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/CacheTokenVerifierTest.php",
"language": "php",
"file_size": 1733,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\RememberMe;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Sec... | DateTimeImmutable());
$provider->createNewToken($token);
$this->assertSame($provider->loadTokenBySeries('foo'), $token);
}
public function testLoadTokenBySeriesThrowsNotFoundException()
{
$this->expectException(TokenNo | tFoundException;
class InMemoryTokenProviderTest extends TestCase
{
public function testCreateNewToken()
{
$provider = new InMemoryTokenProvider();
$token = new PersistentToken('foo', 'foo', 'foo', new \ | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php",
"language": "php",
"file_size": 2021,
"cut_index": 563,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Validator\Constraints;
use Symfony\Component\Valida... | string $message = 'This value should be the user\'s current password.';
public string $service = 'security.validator.user_password';
#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?string $ser | ord extends Constraint
{
public const INVALID_PASSWORD_ERROR = '2d2a8bb4-ddc8-45e4-9b0f-8670d3a3e290';
protected const ERROR_NAMES = [
self::INVALID_PASSWORD_ERROR => 'INVALID_PASSWORD_ERROR',
];
public | {
"filepath": "src/Symfony/Component/Security/Core/Validator/Constraints/UserPassword.php",
"language": "php",
"file_size": 1333,
"cut_index": 524,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Authorization\Strategy;
use Symfony\Component\Security\Core\Authorization\Strategy\UnanimousStrategy;
use Symfony\Component\Security\Core\Tes... | lf::getVoters(1, 0, 0), true];
yield [$strategy, self::getVoters(1, 0, 1), true];
yield [$strategy, self::getVoters(1, 1, 0), false];
yield [$strategy, self::getVoters(0, 0, 2), false];
$strategy = new UnanimousStrategy(tr | w UnanimousStrategy();
yield [$strategy, se | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/UnanimousStrategyTest.php",
"language": "php",
"file_size": 963,
"cut_index": 582,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
use Symfony\Component\Security\Core\Authentication\Token\... | e\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
use Symfony\Component\Security\Core\User\InMemoryUser;
class AuthenticatedVoterTest extends TestCase
{
#[DataProvider('getVoteTests')]
pu | y\Core\Authentication\Token\RememberMeToken;
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Cor | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php",
"language": "php",
"file_size": 5623,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\Attributes\RequiresMethod;
use PHPUnit\Fr... | ore\User\InMemoryUser;
use Symfony\Component\Security\Http\Attribute\IsGrantedContext;
#[RequiresMethod(IsGrantedContext::class, 'isGranted')]
class ClosureVoterTest extends TestCase
{
private ClosureVoter $voter;
protected function setUp(): void | rity\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\ClosureVoter;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\C | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ClosureVoterTest.php",
"language": "php",
"file_size": 2560,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ExpressionLan... | ecurity\Core\Authorization\Voter\ExpressionVoter;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
class ExpressionVoterTest extends TestCase
{
#[DataProvider('getVoteTests')]
public function testVoteWithTokenThatReturnsRole | omponent\Security\Core\Authentication\Token\NullToken;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
use Symfony\Component\S | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php",
"language": "php",
"file_size": 3291,
"cut_index": 614,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\Attributes\Data... | RoleHierarchyVoter(new RoleHierarchy(['ROLE_FOO' => ['ROLE_FOOBAR']]));
$this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes));
}
public static function getVoteTests()
{
return arr | e\Role\RoleHierarchy;
class RoleHierarchyVoterTest extends RoleVoterTest
{
#[DataProvider('getVoteTests')]
public function testVoteUsingTokenThatReturnsRoleNames($roles, $attributes, $expected)
{
$voter = new | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php",
"language": "php",
"file_size": 1616,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Fram... | {
#[DataProvider('getVoteTests')]
public function testVoteUsingTokenThatReturnsRoleNames($roles, $attributes, $expected)
{
$voter = new RoleVoter();
$this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles) | curity\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
class RoleVoterTest extends TestCase
| {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php",
"language": "php",
"file_size": 2885,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfo... | ass()
{
$voter = $this->createStub(VoterInterface::class);
$sut = new TraceableVoter($voter, $this->createStub(EventDispatcherInterface::class));
$this->assertSame($voter, $sut->getDecoratedVoter());
}
public function | n\Voter\VoterInterface;
use Symfony\Component\Security\Core\Event\VoteEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class TraceableVoterTest extends TestCase
{
public function testGetDecoratedVoterCl | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/TraceableVoterTest.php",
"language": "php",
"file_size": 3559,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterfa... | $voter = new VoterTest_Voter();
$integerVoter = new IntegerVoterTest_Voter();
return [
[$voter, ['EDIT'], VoterInterface::ACCESS_GRANTED, new \stdClass(), 'ACCESS_GRANTED if attribute and class are supported and attribute gr | terface;
class VoterTest extends TestCase
{
protected TokenInterface $token;
protected function setUp(): void
{
$this->token = new NullToken();
}
public static function getTests(): array
{
| {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php",
"language": "php",
"file_size": 6445,
"cut_index": 716,
"middle_length": 229
} |
p
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Signature;
use PHPUnit\Framework\Test... | yAdapter();
$storage = new ExpiredSignatureStorage($cache, 600);
$this->assertSame(0, $storage->countUsages('hash+more'));
$storage->incrementUsages('hash+more');
$this->assertSame(1, $storage->countUsages('hash+more'));
| function testUsage()
{
$cache = new Arra | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Signature/ExpiredSignatureStorageTest.php",
"language": "php",
"file_size": 830,
"cut_index": 516,
"middle_length": 52
} |
rity\Core\Signature\Exception\ExpiredSignatureException;
use Symfony\Component\Security\Core\Signature\Exception\InvalidSignatureException;
use Symfony\Component\Security\Core\Signature\SignatureHasher;
use Symfony\Component\Security\Core\User\UserInterface;
class SignatureHasherTest extends TestCase
{
public func... | natureHashValid()
{
$user = new TestSignatureUser('john', 'my-password');
$hasher = new SignatureHasher(PropertyAccess::createPropertyAccessor(), ['password'], 'secret');
$expires = time() + 3600;
$hash = $hasher->compu | , 'secret');
$expires = time() + 3600;
$hash = $hasher->computeSignatureHash($user, $expires);
$this->assertIsString($hash);
$this->assertNotEmpty($hash);
}
public function testVerifySig | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Signature/SignatureHasherTest.php",
"language": "php",
"file_size": 12027,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Dumper\MermaidDirection;
use Symfony\Component\Security\Cor... | ();
$output = $dumper->dump($roleHierarchy);
$this->assertStringContainsString('graph TB', $output);
$this->assertStringContainsString('ROLE_ADMIN', $output);
$this->assertStringContainsString('ROLE_USER', $output);
| hy = [
'ROLE_ADMIN' => ['ROLE_USER'],
'ROLE_SUPER_ADMIN' => ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'],
];
$roleHierarchy = new RoleHierarchy($hierarchy);
$dumper = new MermaidDumper | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Dumper/MermaidDumperTest.php",
"language": "php",
"file_size": 4820,
"cut_index": 614,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Event;
use Symfony\Component\Security\Core\Au... | private array $reasons = [],
) {
}
public function getVoter(): VoterInterface
{
return $this->voter;
}
public function getSubject(): mixed
{
return $this->subject;
}
public function getAttributes(): | *
* @internal
*/
final class VoteEvent extends Event
{
public function __construct(
private VoterInterface $voter,
private mixed $subject,
private array $attributes,
private int $vote,
| {
"filepath": "src/Symfony/Component/Security/Core/Event/VoteEvent.php",
"language": "php",
"file_size": 1217,
"cut_index": 518,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\Security\Core\... | public ?string $strategy = null;
public bool $isGranted;
/**
* @var Vote[]
*/
public array $votes = [];
public function getMessage(): string
{
$message = $this->isGranted ? 'Access Granted.' : 'Access Denied.';
| nymaillard93b@gmail.com>
* @author Roman JOLY <eltharin18@outlook.fr>
* @author Nicolas Grekas <p@tchwork.com>
*/
class AccessDecision
{
/**
* @var class-string<AccessDecisionStrategyInterface>|string|null
*/
| {
"filepath": "src/Symfony/Component/Security/Core/Authorization/AccessDecision.php",
"language": "php",
"file_size": 1454,
"cut_index": 524,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Strategy\AccessDecisionStrategyInterface;
use Symfony\Component\Security\Core\Authorization\Strategy\Affi... | ss for all access decision managers
* that use decision voters.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class AccessDecisionManager implements AccessDecisionManagerInterface
{
private const VALID_VOTES = [
VoterInterface: | Security\Core\Authorization\Voter\Vote;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
/**
* AccessDecisionManager is the base cla | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php",
"language": "php",
"file_size": 6066,
"cut_index": 716,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\Sec... | $object The object to secure
* @param AccessDecision|null $accessDecision Should be used to explain the decision
*/
public function decide(TokenInterface $token, array $attributes, mixed $object = null, ?AccessDecision $a | cisionManagerInterface
{
/**
* Decides whether the access is possible or not.
*
* @param array $attributes An array of attributes associated with the method being invoked
* @param mixed | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/AccessDecisionManagerInterface.php",
"language": "php",
"file_size": 1029,
"cut_index": 513,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
use... | s);
/**
* AuthorizationChecker is the main authorization point of the Security component.
*
* It gives access to the token representing the current user authentication.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt | ion\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;
// Help opcache.preload discover always-needed symbols
class_exists(AbstractToken::class);
class_exists(OfflineTokenInterface::clas | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php",
"language": "php",
"file_size": 2615,
"cut_index": 563,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
/**
* The AuthorizationCheckerInterface.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.... | ribute to vote on (can be of any type; strings, Expression and Closure instances are supported by the core)
* @param AccessDecision|null $accessDecision Should be used to explain the decision
*/
public function isGranted(mixed $attribute, mix | ram mixed $attribute A single att | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/AuthorizationCheckerInterface.php",
"language": "php",
"file_size": 959,
"cut_index": 582,
"middle_length": 52
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Psr\Cache\CacheItemPoolInterface... | ressionLanguageProvider::class);
/**
* Adds some function to the default ExpressionLanguage.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @see ExpressionLanguageProvider
*/
class ExpressionLanguage extends Ba | lass requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
} else {
// Help opcache.preload discover always-needed symbols
class_exists(Exp | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/ExpressionLanguage.php",
"language": "php",
"file_size": 1492,
"cut_index": 524,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\ExpressionLanguage\Expressi... | checker->isGranted("IS_AUTHENTICATED")', static fn (array $variables) => $variables['auth_checker']->isGranted('IS_AUTHENTICATED')),
new ExpressionFunction('is_fully_authenticated', static fn () => '$token && $auth_checker->isGranted("IS_AUTHE | */
class ExpressionLanguageProvider implements ExpressionFunctionProviderInterface
{
public function getFunctions(): array
{
return [
new ExpressionFunction('is_authenticated', static fn () => '$auth_ | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/ExpressionLanguageProvider.php",
"language": "php",
"file_size": 1704,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Vot... | ;
private array $decisionLog = []; // All decision logs
private array $currentLog = []; // Logs being filled in
private array $accessDecisionStack = [];
public function __construct(
private AccessDecisionManagerInterface $manager, | er.eguiluz@gmail.com>
*
* @internal
*/
class TraceableAccessDecisionManager implements AccessDecisionManagerInterface
{
private ?string $strategy = null;
/** @var array<VoterInterface> */
private array $voters = [] | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php",
"language": "php",
"file_size": 3204,
"cut_index": 614,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization;
use Symfony\Component\Sec... | ance of Expression are supported by the core)
* @param AccessDecision|null $accessDecision Should be used to explain the decision
*/
public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecisio | ace
{
/**
* Checks if the attribute is granted against the user and optionally supplied subject.
*
* @param mixed $attribute A single attribute to vote on (can be of any type, string and inst | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/UserAuthorizationCheckerInterface.php",
"language": "php",
"file_size": 1033,
"cut_index": 513,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Strategy;
use Symfony\Component\Security\Core\Auth... | ss AffirmativeStrategy implements AccessDecisionStrategyInterface, \Stringable
{
public function __construct(
private bool $allowIfAllAbstainDecisions = false,
) {
}
public function decide(\Traversable $results, ?AccessDecision $ac | ned from voting, the decision will be based on the
* allowIfAllAbstainDecisions property value (defaults to false).
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Alexander M. Turek <me@derrabus.de>
*/
final cla | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Strategy/AffirmativeStrategy.php",
"language": "php",
"file_size": 1535,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Strategy;
use Symfony\Component\Security\Core\Authorization\AccessDecision;
... | ualGrantedDeniedDecisions property value
* (defaults to true).
*
* If all voters abstained from voting, the decision will be based on the
* allowIfAllAbstainDecisions property value (defaults to false).
*
* @author Fabien Potencier <fabien@symfony.co | noring abstains) rather than unanimous
* agreement (ignoring abstains). If you require unanimity, see
* UnanimousBased.
*
* If there were an equal number of grant and deny votes, the decision will
* be based on the allowIfEq | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Strategy/ConsensusStrategy.php",
"language": "php",
"file_size": 2119,
"cut_index": 563,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Strategy;
use Symfony\Component\Security\Core\Auth... | n@symfony.com>
* @author Alexander M. Turek <me@derrabus.de>
*/
final class PriorityStrategy implements AccessDecisionStrategyInterface, \Stringable
{
public function __construct(
private bool $allowIfAllAbstainDecisions = false,
) {
| ty of voters can be used to overrule a decision.
*
* If all voters abstained from voting, the decision will be based on the
* allowIfAllAbstainDecisions property value (defaults to false).
*
* @author Fabien Potencier <fabie | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Strategy/PriorityStrategy.php",
"language": "php",
"file_size": 1528,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Strategy;
use Symfony\Component\Security\Core\Auth... | lass UnanimousStrategy implements AccessDecisionStrategyInterface, \Stringable
{
public function __construct(
private bool $allowIfAllAbstainDecisions = false,
) {
}
public function decide(\Traversable $results, ?AccessDecision $ac | ained from voting, the decision will be based on the
* allowIfAllAbstainDecisions property value (defaults to false).
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Alexander M. Turek <me@derrabus.de>
*/
final c | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Strategy/UnanimousStrategy.php",
"language": "php",
"file_size": 1561,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\... | t is most restrictive to least restrictive checking.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class AuthenticatedVoter implements CacheableVoterInterface
{
public const IS_AUTHENTICAT | ce;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
/**
* AuthenticatedVoter votes if an attribute like IS_AUTHENTICATED_FULLY,
* IS_AUTHENTICATED_REMEMBERED, IS_AUTHENTICATED is present.
*
* This lis | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/AuthenticatedVoter.php",
"language": "php",
"file_size": 4597,
"cut_index": 614,
"middle_length": 229
} |
ackage.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
/**
* Let voters expose the attributes and types they care about... | s VoterInterface
{
public function supportsAttribute(string $attribute): bool;
/**
* @param string $subjectType The type of the subject inferred by `get_class` or `get_debug_type`
*/
public function supportsType(string $subjectType): | se.com>
*/
interface CacheableVoterInterface extend | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/CacheableVoterInterface.php",
"language": "php",
"file_size": 879,
"cut_index": 559,
"middle_length": 52
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterfa... | eVoter implements CacheableVoterInterface
{
public function __construct(
private AuthorizationCheckerInterface $authorizationChecker,
) {
}
public function supportsAttribute(string $attribute): bool
{
return false;
| antedContext;
/**
* This voter allows using a closure as the attribute being voted on.
*
* @see IsGranted doc for the complete closure signature.
*
* @author Alexandre Daubois <alex.daubois@gmail.com>
*/
final class Closur | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/ClosureVoter.php",
"language": "php",
"file_size": 2168,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component... | ession.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ExpressionVoter implements CacheableVoterInterface
{
public function __construct(
private ExpressionLanguage $expressionLanguage,
private ?AuthenticationTrustResolver | uthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
/**
* ExpressionVoter votes based on the evaluation of an expr | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php",
"language": "php",
"file_size": 3414,
"cut_index": 614,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Com... | nds RoleVoter
{
public function __construct(
private RoleHierarchyInterface $roleHierarchy,
string $prefix = 'ROLE_',
) {
parent::__construct($prefix);
}
protected function extractRoles(TokenInterface $token): array | abien@symfony.com>
*/
class RoleHierarchyVoter exte | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php",
"language": "php",
"file_size": 989,
"cut_index": 582,
"middle_length": 52
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\Security\Core\Authent... | result = VoterInterface::ACCESS_ABSTAIN;
$roles = $this->extractRoles($token);
$missingRoles = [];
foreach ($attributes as $attribute) {
if (!\is_string($attribute) || !str_starts_with($attribute, $this->prefix)) {
| oterInterface
{
public function __construct(
private string $prefix = 'ROLE_',
) {
}
public function vote(TokenInterface $token, mixed $subject, array $attributes, ?Vote $vote = null): int
{
$ | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php",
"language": "php",
"file_size": 1963,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\Security\Core\Authent... | private EventDispatcherInterface $eventDispatcher,
) {
}
public function vote(TokenInterface $token, mixed $subject, array $attributes, ?Vote $vote = null): int
{
$result = $this->voter->vote($token, $subject, $attributes, $vote | t events.
*
* @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
*
* @internal
*/
class TraceableVoter implements CacheableVoterInterface
{
public function __construct(
private VoterInterface $voter,
| {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/TraceableVoter.php",
"language": "php",
"file_size": 1689,
"cut_index": 537,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authenticatio... | er, 'fookey');
$this->assertEquals('fookey', $token->getFirewallName());
$this->assertEquals(['ROLE_FOO'], $token->getRoleNames());
$this->assertSame($user, $token->getUser());
}
protected function getUser($roles = ['ROLE_ | >getUser();
$token = new RememberMeToken($us | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php",
"language": "php",
"file_size": 972,
"cut_index": 582,
"middle_length": 52
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit\Fr... | s());
$this->assertEquals('key', $token->getFirewallName());
}
public function testToString()
{
$token = new UsernamePasswordToken(new InMemoryUser('foo', '', ['A', 'B']), 'foo', ['A', 'B']);
$this->assertEquals('Userna | s TestCase
{
public function testConstructor()
{
$token = new UsernamePasswordToken(new InMemoryUser('foo', 'bar', ['ROLE_FOO']), 'key', ['ROLE_FOO']);
$this->assertEquals(['ROLE_FOO'], $token->getRoleName | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php",
"language": "php",
"file_size": 1070,
"cut_index": 515,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token\Fixtures;
use Symf... | }
public function getUserIdentifier(): string
{
return $this->username;
}
public function getRoles(): array
{
return $this->roles;
}
public function getPassword(): ?string
{
return null;
}
}
| es,
) {
| {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/Fixtures/CustomUser.php",
"language": "php",
"file_size": 788,
"cut_index": 518,
"middle_length": 14
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\User\Chain... | ->method('checkPreAuth')
->with($user);
$checker2 = $this->createMock(UserCheckerInterface::class);
$checker2->expects($this->once())
->method('checkPreAuth')
->with($user);
$checker3 = $th | ic function testForwardsPreAuthToAllUserCheckers()
{
$user = new InMemoryUser('John', 'password');
$checker1 = $this->createMock(UserCheckerInterface::class);
$checker1->expects($this->once())
| {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/ChainUserCheckerTest.php",
"language": "php",
"file_size": 2041,
"cut_index": 563,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
u... | , 'password')));
}
public function testCheckPostAuthPass()
{
$checker = new InMemoryUserChecker();
$this->assertNull($checker->checkPostAuth(new InMemoryUser('John', 'password')));
}
public function testCheckPreAuthDis | moryUserCheckerTest extends TestCase
{
public function testCheckPostAuthNotAdvancedUserInterface()
{
$checker = new InMemoryUserChecker();
$this->assertNull($checker->checkPostAuth(new InMemoryUser('John' | {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/InMemoryUserCheckerTest.php",
"language": "php",
"file_size": 1183,
"cut_index": 518,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;... |
$this->assertEquals([], $user->getRoles());
$user = new InMemoryUser('fabien', 'superpass', ['ROLE_ADMIN']);
$this->assertEquals(['ROLE_ADMIN'], $user->getRoles());
}
public function testGetPassword()
{
$user | ception()
{
$this->expectException(\InvalidArgumentException::class);
new InMemoryUser('', 'superpass');
}
public function testGetRoles()
{
$user = new InMemoryUser('fabien', 'superpass'); | {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/InMemoryUserTest.php",
"language": "php",
"file_size": 2959,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\User\OidcUser;
class OidcUserTest extends TestCase
{
public function testCannotCreateUserWithoutSubProperty()
{
$this->expectException(\InvalidArg... | hn',
'DOE',
'Fitzgerald',
'Johnny',
'john.doe',
'https://www.example.com/john-doe',
'https://www.example.com/pics/john-doe.jpg',
'https://www.example.com',
'joh | ngPositionalParameters()
{
$this->assertEquals(new OidcUser(
'john.doe',
['ROLE_USER', 'ROLE_ADMIN'],
'e21bf182-1538-406e-8ccb-e25a17aba39f',
'John DOE',
'Jo | {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/OidcUserTest.php",
"language": "php",
"file_size": 5805,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Validator\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Fr... | straint->validatedBy());
}
#[DataProvider('provideServiceValidatedConstraints')]
public function testValidatedByService(UserPassword $constraint)
{
self::assertSame('my_service', $constraint->validatedBy());
}
public stati | AttributeLoader;
class UserPasswordTest extends TestCase
{
public function testValidatedByStandardValidator()
{
$constraint = new UserPassword();
self::assertSame('security.validator.user_password', $con | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordTest.php",
"language": "php",
"file_size": 2365,
"cut_index": 563,
"middle_length": 229
} |
ation\Token\NullToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecision;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
use Symfony\Component\Security\Core\Authorization\Strategy\AccessDecisionStrategyInte... | s->getExpectedVoter(VoterInterface::ACCESS_DENIED),
$this->getExpectedVoter(VoterInterface::ACCESS_GRANTED),
$this->getUnexpectedVoter(),
];
$strategy = new class implements AccessDecisionStrategyInterface {
| extends TestCase
{
public function provideBadVoterResults(): array
{
return [
[3],
[true],
];
}
public function testVoterCalls()
{
$voters = [
$thi | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php",
"language": "php",
"file_size": 9348,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authe... | Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter;
use Symfony\Component\Security\Core\User\InMemo | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php",
"language": "php",
"file_size": 3089,
"cut_index": 614,
"middle_length": 229
} |
ty\Core\Authentication\Token\NullToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Tr... | ct, array $voterVotes, bool $result)
{
$token = new NullToken();
$admMock = $this->createMock(AccessDecisionManagerInterface::class);
$adm = new TraceableAccessDecisionManager($admMock);
$admMock
->expects( | ent\Security\Core\Tests\Fixtures\DummyVoter;
class TraceableAccessDecisionManagerTest extends TestCase
{
#[DataProvider('provideObjectsAndLogs')]
public function testDecideLog(array $expectedLog, array $attributes, $obje | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php",
"language": "php",
"file_size": 11413,
"cut_index": 921,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Authorization\Strategy;
use Symfony\Component\Security\Core\Authorization\Strategy\... | lf::getVoters(2, 1, 0), true];
yield [$strategy, self::getVoters(0, 0, 1), false];
yield [$strategy, self::getVoters(2, 2, 0), true];
yield [$strategy, self::getVoters(2, 2, 1), true];
$strategy = new ConsensusStrategy(tru | videStrategyTests(): iterable
{
$strategy = new ConsensusStrategy();
yield [$strategy, self::getVoters(1, 0, 0), true];
yield [$strategy, self::getVoters(1, 2, 0), false];
yield [$strategy, se | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ConsensusStrategyTest.php",
"language": "php",
"file_size": 1260,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Exception;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authe... | }
public function __unserialize(array $data): void
{
[$this->childMember, $parentData] = $data;
parent::__unserialize($parentData);
}
}
class CustomUserMessageAuthenticationExceptionTest extends TestCase
{
public functi | ldCustomUserMessageAuthenticationException extends CustomUserMessageAuthenticationException
{
public $childMember;
public function __serialize(): array
{
return [$this->childMember, parent::__serialize()];
| {
"filepath": "src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php",
"language": "php",
"file_size": 2798,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
use Sym... | is->assertFalse($resolver->isRememberMe(null));
$this->assertFalse($resolver->isRememberMe(new FakeCustomToken()));
$this->assertTrue($resolver->isRememberMe(new RealCustomRememberMeToken()));
$this->assertTrue($resolver->isRemember | r;
use Symfony\Component\Security\Core\User\UserInterface;
class AuthenticationTrustResolverTest extends TestCase
{
public function testIsRememberMe()
{
$resolver = new AuthenticationTrustResolver();
$th | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php",
"language": "php",
"file_size": 4090,
"cut_index": 614,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\RememberMe;
use PHPUnit\... | s('fooseries', $token->getSeries());
$this->assertEquals('footokenvalue', $token->getTokenValue());
$this->assertEquals($lastUsed, $token->getLastUsed());
}
public function testDateTime()
{
$lastUsed = new \DateTime();
| $lastUsed = new \DateTimeImmutable();
$token = new PersistentToken('fooname', 'fooseries', 'footokenvalue', $lastUsed);
$this->assertEquals('fooname', $token->getUserIdentifier());
$this->assertEqual | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/PersistentTokenTest.php",
"language": "php",
"file_size": 1165,
"cut_index": 518,
"middle_length": 229
} |
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit... | ames());
$this->assertEquals('key', $token->getFirewallName());
}
public function testGetUser()
{
$token = new PreAuthenticatedToken($user = new InMemoryUser('foo', 'bar'), 'key');
$this->assertEquals($user, $token->get | ends TestCase
{
public function testConstructor()
{
$token = new PreAuthenticatedToken(new InMemoryUser('foo', 'bar', ['ROLE_FOO']), 'key', ['ROLE_FOO']);
$this->assertEquals(['ROLE_FOO'], $token->getRoleN | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/PreAuthenticatedTokenTest.php",
"language": "php",
"file_size": 1014,
"cut_index": 512,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Sym... | ']), 'provider-key', ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH']);
$token = new SwitchUserToken(new InMemoryUser('admin', 'bar', ['ROLE_USER']), 'provider-key', ['ROLE_USER'], $originalToken, 'https://symfony.com/blog');
$unserializedToken = | \User\InMemoryUser;
class SwitchUserTokenTest extends TestCase
{
public function testSerialize()
{
$originalToken = new UsernamePasswordToken(new InMemoryUser('user', 'foo', ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/SwitchUserTokenTest.php",
"language": "php",
"file_size": 3817,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token\Storage;
use PHPUnit\Framework\TestCase;
use Psr\Container\Cont... | ion\Token\Storage\UsageTrackingTokenStorage;
use Symfony\Contracts\Service\ServiceLocatorTrait;
class UsageTrackingTokenStorageTest extends TestCase
{
public function testGetSetToken()
{
$tokenStorage = new TokenStorage();
$session | nt\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authenticat | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php",
"language": "php",
"file_size": 2557,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Exception\... | quals(['ROLE_USER'], $user->getRoles());
$this->assertFalse($user->isEnabled());
}
public function testRefresh()
{
$user = new InMemoryUser('fabien', 'bar');
$provider = $this->createProvider();
$refreshedUser | public function testConstructor()
{
$provider = $this->createProvider();
$user = $provider->loadUserByIdentifier('fabien');
$this->assertEquals('foo', $user->getPassword());
$this->assertE | {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php",
"language": "php",
"file_size": 2357,
"cut_index": 563,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Resources;
use PHPUnit\Framework\Attributes\DataProvider;
... | unt(0, $errors, \sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
}
#[DataProvider('provideTranslationFiles')]
public function testTranslationFileIsValidWithoutEntityLoader($filePath)
| tion testTranslationFileIsValid($filePath)
{
$document = new \DOMDocument();
$document->loadXML(file_get_contents($filePath));
$errors = XliffUtils::validateSchema($document);
$this->assertCo | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php",
"language": "php",
"file_size": 1908,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authorization;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCa... | ty\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Security\Core\User\InMemoryUser;
class AuthorizationCheckerTest extends TestCase
{
private MockObject&AccessDecisionManagerInterface $accessDecisionManager;
private AuthorizationChe | entication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Securi | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php",
"language": "php",
"file_size": 4286,
"cut_index": 614,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Authorization\Strategy;
use Symfony\Component\Security\Core\Authorization\Strategy\... | ABSTAIN),
self::getVoter(VoterInterface::ACCESS_GRANTED),
self::getVoter(VoterInterface::ACCESS_DENIED),
self::getVoter(VoterInterface::ACCESS_DENIED),
], true];
yield [$strategy, [
self::get | xtends AccessDecisionStrategyTestCase
{
public static function provideStrategyTests(): iterable
{
$strategy = new PriorityStrategy();
yield [$strategy, [
self::getVoter(VoterInterface::ACCESS_ | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/PriorityStrategyTest.php",
"language": "php",
"file_size": 1424,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Role;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
class RoleHierarchyTest extends TestCase... | eNames(['ROLE_FOO']));
$this->assertEqualsCanonicalizing(['ROLE_ADMIN' => 'ROLE_ADMIN', 'ROLE_USER' => 'ROLE_USER'], $role->getReachableRoleNames(['ROLE_ADMIN']));
$this->assertEqualsCanonicalizing(['ROLE_FOO' => 'ROLE_FOO', 'ROLE_ADMIN' => | OO'],
]);
$this->assertEqualsCanonicalizing(['ROLE_USER' => 'ROLE_USER'], $role->getReachableRoleNames(['ROLE_USER']));
$this->assertEqualsCanonicalizing(['ROLE_FOO' => 'ROLE_FOO'], $role->getReachableRol | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Role/RoleHierarchyTest.php",
"language": "php",
"file_size": 3139,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Validator\Constraints;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryIn... | tion;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
class UserPasswordValidator extends ConstraintValidator
{
public function __construct(
private TokenStorageInterface $tokenStorage,
private PasswordHasherFactoryI | Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\ConstraintDefinitionExcep | {
"filepath": "src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php",
"language": "php",
"file_size": 2490,
"cut_index": 563,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token\Storage;
use ... | n());
$token = new UsernamePasswordToken(new InMemoryUser('username', 'password'), 'provider');
$tokenStorage->setToken($token);
$this->assertSame($token, $tokenStorage->getToken());
$tokenStorage->setToken(null);
$t | ymfony\Component\Security\Core\User\InMemoryUser;
class TokenStorageTest extends TestCase
{
public function testGetSetToken()
{
$tokenStorage = new TokenStorage();
$this->assertNull($tokenStorage->getToke | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php",
"language": "php",
"file_size": 1050,
"cut_index": 513,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
use Symfony\Componen... | {
$this->assertEquals(new OAuth2User(
scope: 'read write dolphin',
username: 'jdoe',
exp: 1419356238,
iat: 1419350238,
sub: 'Z5O3upPC88QrAjx00dis',
aud: 'https://protected.exam | ption::class);
$this->expectExceptionMessage('The claim "sub" or "username" must be provided.');
new OAuth2User();
}
public function testCreateFullUserWithAdditionalClaimsUsingPositionalParameters()
| {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/OAuth2UserTest.php",
"language": "php",
"file_size": 1629,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Validator\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
use Symfony\Component\PasswordHasher\PasswordHasherInterface;
use Symfony\Component\Securit... | ption\ConstraintDefinitionException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class UserPasswordValidatorTestCase extends ConstraintValidatorTestCase
{
privat | Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exce | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTestCase.php",
"language": "php",
"file_size": 5642,
"cut_index": 716,
"middle_length": 229
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Exception;
use PHPUnit\Framework\Tes... | e');
$this->assertEquals(['{{ username }}' => 'username', '{{ user_identifier }}' => 'username'], $exception->getMessageData());
}
public function testUserIdentifierIsNotSetByDefault()
{
$exception = new UserNotFoundException() | n = new UserNotFoundException('Username could not be found.');
$this->assertEquals(['{{ username }}' => null, '{{ user_identifier }}' => null], $exception->getMessageData());
$exception->setUserIdentifier('usernam | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Exception/UserNotFoundExceptionTest.php",
"language": "php",
"file_size": 1071,
"cut_index": 515,
"middle_length": 229
} |
Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\AttributesBasedUserProviderInterface;
use Symfony\Component\Security\Core\User\ChainUserProvider;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
use Sy... | once())
->method('loadUserByIdentifier')
->with($this->equalTo('foo'))
->willThrowException(new UserNotFoundException('not found'))
;
$provider2 = $this->createMock(InMemoryUserProvider::class);
| Interface;
class ChainUserProviderTest extends TestCase
{
public function testLoadUserByIdentifier()
{
$provider1 = $this->createMock(InMemoryUserProvider::class);
$provider1
->expects($this-> | {
"filepath": "src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php",
"language": "php",
"file_size": 10371,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Cor... | , $token->getUserIdentifier());
}
public static function provideUsers()
{
yield [new InMemoryUser('fabien', null), 'fabien'];
}
public function testSerialize()
{
$token = new ConcreteToken(['ROLE_FOO', 'ROLE_BAR']) |
#[DataProvider('provideUsers')]
public function testGetUserIdentifier($user, string $username)
{
$token = new ConcreteToken(['ROLE_FOO']);
$token->setUser($user);
$this->assertEquals($username | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php",
"language": "php",
"file_size": 3814,
"cut_index": 614,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Authorization\Strategy;
use Symfony\Component\Security\Core\Authorization\Strategy\AffirmativeStrategy;
use Symfony\Component\Security\Core\T... | gy, self::getVoters(1, 0, 0), true];
yield [$strategy, self::getVoters(1, 2, 0), true];
yield [$strategy, self::getVoters(0, 1, 0), false];
yield [$strategy, self::getVoters(0, 0, 1), false];
$strategy = new AffirmativeStra | = new AffirmativeStrategy();
yield [$strate | {
"filepath": "src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/AffirmativeStrategyTest.php",
"language": "php",
"file_size": 970,
"cut_index": 582,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Authorization\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
* Voter is an abstract default implementa... | ne of the attributes are supported
$voteResult = self::ACCESS_ABSTAIN;
foreach ($attributes as $attribute) {
try {
if (!$this->supports($attribute, $subject)) {
continue;
}
| ract class Voter implements VoterInterface, CacheableVoterInterface
{
public function vote(TokenInterface $token, mixed $subject, array $attributes, ?Vote $vote = null): int
{
// abstain vote by default in case no | {
"filepath": "src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php",
"language": "php",
"file_size": 3574,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Compressor;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\Process;
/**
* Comp... | PHP_EXTENSION = 'zlib';
private const FILE_EXTENSION = 'gz';
public function __construct(
private readonly ZopfliCompressor $zopfliCompressor = new ZopfliCompressor(),
?string $executable = null,
private ?LoggerInterface $ | mpressorTrait {
compress as private baseCompress;
getUnsupportedReason as private baseGetUnsupportedReason;
}
private const WRAPPER = 'compress.zlib';
private const COMMAND = 'gzip';
private const | {
"filepath": "src/Symfony/Component/AssetMapper/Compressor/GzipCompressor.php",
"language": "php",
"file_size": 2041,
"cut_index": 563,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Compressor;
use Symfony\Component\Process\Proce... | lic function __construct(
?string $executable = null,
) {
$this->executable = $executable;
}
private function compressWithBinary(string $path): void
{
(new Process([$this->executable, '--', $path]))->mustRun();
|
private const WRAPPER = ''; // not supported yet https://github.com/kjdev/php-ext-zopfli/issues/23
private const COMMAND = 'zopfli';
private const PHP_EXTENSION = '';
private const FILE_EXTENSION = 'gz';
pub | {
"filepath": "src/Symfony/Component/AssetMapper/Compressor/ZopfliCompressor.php",
"language": "php",
"file_size": 1182,
"cut_index": 518,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Compressor;
use Symfony\Component\Process\Proce... | able = null,
) {
$this->executable = $executable;
}
/**
* @return resource
*/
private function createStreamContext()
{
return stream_context_create(['zstd' => ['level' => \ZSTD_COMPRESS_LEVEL_MAX]]);
}
| rait;
private const WRAPPER = 'compress.zstd';
private const COMMAND = 'zstd';
private const PHP_EXTENSION = 'zstd';
private const FILE_EXTENSION = 'zst';
public function __construct(
?string $execut | {
"filepath": "src/Symfony/Component/AssetMapper/Compressor/ZstandardCompressor.php",
"language": "php",
"file_size": 1199,
"cut_index": 518,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Path;
use Symfony\Component\AssetMapper\Compressor\CompressorInter... | ess = [],
) {
$this->filesystem = new Filesystem();
}
public function write(string $path, string $contents): void
{
$targetPath = $this->publicDir.'/'.ltrim($path, '/');
$this->filesystem->dumpFile($targetPath, $co | ring[] $extensionsToCompress
*/
public function __construct(
private readonly string $publicDir,
private readonly ?CompressorInterface $compressor = null,
private readonly array $extensionsToCompr | {
"filepath": "src/Symfony/Component/AssetMapper/Path/LocalPublicAssetsFilesystem.php",
"language": "php",
"file_size": 1724,
"cut_index": 537,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Path;
/**
* Writes asset files to their publi... | /**
* Copy a local file to the public location.
*/
public function copy(string $originPath, string $path): void;
/**
* A string representation of the public directory, used for feedback.
*/
public function getDestinationPat | ): void;
| {
"filepath": "src/Symfony/Component/AssetMapper/Path/PublicAssetsFilesystemInterface.php",
"language": "php",
"file_size": 802,
"cut_index": 517,
"middle_length": 14
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Path;
class PublicAssetsPathResolver implements... | always starts and ends with a single slash
$this->publicPrefix = '/'.trim($publicPrefix, '/').'/';
}
public function resolvePublicPath(string $logicalPath): string
{
return $this->publicPrefix.ltrim($logicalPath, '/');
}
}
| public prefix | {
"filepath": "src/Symfony/Component/AssetMapper/Path/PublicAssetsPathResolver.php",
"language": "php",
"file_size": 788,
"cut_index": 518,
"middle_length": 14
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Compiler;
use Symfony\Component\AssetMapper\AssetMapperInterface;
use Symfony\Component\AssetMapper\MappedAsset... | lic const MISSING_IMPORT_WARN = 'warn';
public const MISSING_IMPORT_IGNORE = 'ignore';
public function supports(MappedAsset $asset): bool;
/**
* Applies any changes to the contents of the asset.
*/
public function compile(string | blic const MISSING_IMPORT_STRICT = 'strict';
pub | {
"filepath": "src/Symfony/Component/AssetMapper/Compiler/AssetCompilerInterface.php",
"language": "php",
"file_size": 967,
"cut_index": 582,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Compiler;
use Psr\Log\LoggerInterface;
use Symfony\Component\AssetMapper\AssetMapperInterface;
use Symfony\Component\AssetMapper\Exception\Runt... | {
(?|
(url\()\s*+["']?(?!(?:/|\#|%23|data|http|//))([^"')\s?#]++)(?:[?#][^"')]++)?["']?\s*+(\))
|
(@import\s++)["'](?!(?:/|\#|%23|data|http|//))([^"')\s?#]++)(?:[?#][^"')]++)?["']
)
} | rails/propshaft/blob/main/lib/propshaft/compiler/css_asset_urls.rb
*/
final class CssAssetUrlCompiler implements AssetCompilerInterface
{
// https://regex101.com/r/BOJ3vG/2
public const ASSET_URL_PATTERN = <<<'REGEX'
| {
"filepath": "src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php",
"language": "php",
"file_size": 4220,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\AssetMapper\Compiler;
use Psr\Log\LoggerInterface;
use Symfony\Component\AssetMapper\AssetMapperInterface;
use Symfony\Component\AssetMapper\Compiler\Parser\JavascriptSequenceParser;
use Symfony\Component\AssetMapper\Exception\CircularAssetsException;
use S... | AssetCompilerInterface
{
private const IMPORT_PATTERN = '/
^(?:\/\/.*) # Lines that start with comments
|
(?:
\'(?:[^\'\\\\\n]|\\\\.)*+\' # Strings enclosed in single quotes
| mfony\Component\AssetMapper\MappedAsset;
use Symfony\Component\Filesystem\Path;
/**
* Resolves import paths in JS files.
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
final class JavaScriptImportPathCompiler implements | {
"filepath": "src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php",
"language": "php",
"file_size": 9154,
"cut_index": 716,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Compiler;
use Symfony\Component\AssetMapper\AssetMapperInterface;
... | sourceMappingURL=(.+\.map)}m';
public function supports(MappedAsset $asset): bool
{
return \in_array($asset->publicExtension, ['css', 'js'], true);
}
public function compile(string $content, MappedAsset $asset, AssetMapperInterfac | rom https://github.com/rails/propshaft/blob/main/lib/propshaft/compiler/source_mapping_urls.rb
*/
final class SourceMappingUrlsCompiler implements AssetCompilerInterface
{
private const SOURCE_MAPPING_PATTERN = '{^(//|/\*)# | {
"filepath": "src/Symfony/Component/AssetMapper/Compiler/SourceMappingUrlsCompiler.php",
"language": "php",
"file_size": 1751,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\AssetMapper\Compiler\Parser;
/**
* Parses JavaScript content to identify sequences of strings, comments, etc.
*
* @author Simon André <smn.andre@gmail.com>
*
* @internal
*/
final class JavascriptSequenceParser
{
private const STATE_DEFAULT = 0;
... | '\'', // Single quote
'`', // Backtick
];
public function __construct(
private readonly string $content,
) {
$this->contentEnd = \strlen($content);
$this->pattern ??= '/'.implode('|', array_map(
| ceType = self::STATE_DEFAULT;
private ?int $currentSequenceEnd = null;
private const COMMENT_SEPARATORS = [
'/*', // Multi-line comment
'//', // Single-line comment
'"', // Double quote
| {
"filepath": "src/Symfony/Component/AssetMapper/Compiler/Parser/JavascriptSequenceParser.php",
"language": "php",
"file_size": 5392,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Factory;
use Symfony\Component\AssetMapper\MappedAsset;
use Symfony\Component\Config\ConfigC... | toryInterface
{
public function __construct(
private readonly MappedAssetFactoryInterface $innerFactory,
private readonly string $cacheDir,
private readonly bool $debug,
) {
}
public function createMappedAsset(strin | onent\Config\Resource\ResourceInterface;
use Symfony\Component\Filesystem\Filesystem;
/**
* Decorates the asset factory to load MappedAssets from cache when possible.
*/
class CachedMappedAssetFactory implements MappedAssetFac | {
"filepath": "src/Symfony/Component/AssetMapper/Factory/CachedMappedAssetFactory.php",
"language": "php",
"file_size": 2637,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\Factory;
use Symfony\Component\AssetMapper\AssetMapperCompiler;
use Symfony\Component\AssetMapper\Exception\CircularAssetsException;
use Symfon... | /-([0-9a-zA-Z]{7,128}\.digested)/';
private const PUBLIC_DIGEST_LENGTH = 7;
private array $assetsCache = [];
private array $assetsBeingCreated = [];
public function __construct(
private readonly PublicAssetsPathResolverInterface $ | nt\Filesystem\Filesystem;
/**
* Creates MappedAsset objects by reading their contents & passing it through compilers.
*/
class MappedAssetFactory implements MappedAssetFactoryInterface
{
private const PREDIGESTED_REGEX = ' | {
"filepath": "src/Symfony/Component/AssetMapper/Factory/MappedAssetFactory.php",
"language": "php",
"file_size": 4811,
"cut_index": 614,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper\ImportMap;
use Symfony\Component\HttpClient\DecoratorTrait;
use Sy... | \WeakMap();
$pendingRequests = [];
foreach ($this->pendingRequests as $response => $_) {
if ($response->getInfo('http_code')) {
$this->pendingRequests->offsetUnset($response);
} else {
| orTrait;
private const BATCH_SIZE = 250;
private \WeakMap $pendingRequests;
public function request(string $method, string $url, array $options = []): ResponseInterface
{
$this->pendingRequests ??= new | {
"filepath": "src/Symfony/Component/AssetMapper/ImportMap/BatchHttpClient.php",
"language": "php",
"file_size": 1651,
"cut_index": 537,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.