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\Http\Authentication;
use Symfony\Component\Ht... | M. Schmitt <schmittjoh@gmail.com>
*/
interface AuthenticationSuccessHandlerInterface
{
/**
* Usually called by AuthenticatorInterface::onAuthenticationSuccess() implementations.
*/
public function onAuthenticationSuccess(Request $reques | ess handler.
*
* If you want to customize the success handling process, instead of
* overwriting the respective listener globally, you can set a custom success
* handler which implements this interface.
*
* @author Johannes | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php",
"language": "php",
"file_size": 1038,
"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\Http\Authentication;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFo... | onError(bool $clearSession = true): ?AuthenticationException
{
$request = $this->getRequest();
$authenticationException = null;
if ($request->attributes->has(SecurityRequestAttributes::AUTHENTICATION_ERROR)) {
$auth | om Request.
*
* @author Boris Vujicic <boris.vujicic@gmail.com>
*/
class AuthenticationUtils
{
public function __construct(
private RequestStack $requestStack,
) {
}
public function getLastAuthenticati | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php",
"language": "php",
"file_size": 2320,
"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\Http;
use Symfony\Component\HttpFoundation\Request;
use ... | s)
* @param string|null $channel The channel to enforce (http, https, or null)
*/
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], ?string $channel = null): void
{
$this->map[] = [$requestMat | tencier <fabien@symfony.com>
*/
class AccessMap implements AccessMapInterface
{
private array $map = [];
/**
* @param array $attributes An array of attributes to pass to the access decision manager (like role | {
"filepath": "src/Symfony/Component/Security/Http/AccessMap.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;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Compo... | lements FirewallMapInterface
{
/**
* @var list<array{RequestMatcherInterface, list<FirewallListenerInterface>, ExceptionListener|null, LogoutListener|null}>
*/
private array $map = [];
/**
* @param list<FirewallListenerInterface | \Component\Security\Http\Firewall\LogoutListener;
/**
* FirewallMap allows configuration of different firewalls for specific parts
* of the website.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class FirewallMap imp | {
"filepath": "src/Symfony/Component/Security/Http/FirewallMap.php",
"language": "php",
"file_size": 1652,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Sym... | directions must match, scheme included
* @param $secureDomainRegexp A regexp the target of HTTP redirections must match when the scheme is "https"
*
* @throws \InvalidArgumentException
*/
public function __construct(
private | ulates the logic needed to create sub-requests, redirect the user, and match URLs.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class HttpUtils
{
/**
* @param $domainRegexp A regexp the target of HTTP re | {
"filepath": "src/Symfony/Component/Security/Http/HttpUtils.php",
"language": "php",
"file_size": 8123,
"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\Workflow\Metadata;
use Symfony\Component\Workflow\Trans... | = $subject) {
return $this->getWorkflowMetadata()[$key] ?? null;
}
$metadataBag = \is_string($subject) ? $this->getPlaceMetadata($subject) : $this->getTransitionMetadata($subject);
return $metadataBag[$key] ?? null;
| if (null == | {
"filepath": "src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.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\Workflow\Metadata;
use Symfony\Component\Workflow\Transitio... |
*
* This is a proxy method.
*
* @param string|Transition|null $subject Use null to get workflow metadata
* Use a string (the place name) to get place metadata
* | on getWorkflowMetadata(): array;
public function getPlaceMetadata(string $place): array;
public function getTransitionMetadata(Transition $transition): array;
/**
* Returns the metadata for a specific subject. | {
"filepath": "src/Symfony/Component/Workflow/Metadata/MetadataStoreInterface.php",
"language": "php",
"file_size": 1174,
"cut_index": 518,
"middle_length": 229
} |
tadataStoreInterface;
use Symfony\Component\Workflow\Transition;
/**
* PlantUmlDumper dumps a workflow as a PlantUML file.
*
* You can convert the generated puml file with the plantuml.jar utility (http://plantuml.com/):
*
* php bin/console workflow:dump pull_request travis --dump-format=puml | java -jar plantuml... | c const DEFAULT_OPTIONS = [
'skinparams' => [
'titleBorderRoundCorner' => 15,
'titleBorderThickness' => 2,
'state' => [
'BackgroundColor'.self::INITIAL => '#87b741',
'BackgroundCol | ARKED = '<<marked>>';
public const STATEMACHINE_TRANSITION = 'arrow';
public const WORKFLOW_TRANSITION = 'square';
public const TRANSITION_TYPES = [self::STATEMACHINE_TRANSITION, self::WORKFLOW_TRANSITION];
publi | {
"filepath": "src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php",
"language": "php",
"file_size": 9215,
"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\Workflow\Dumper;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Marking;
class StateMachineGraphvizDumper extends GraphvizDumpe... | a'] ?? false;
$places = $this->findPlaces($definition, $withMetadata, $marking);
$edges = $this->findEdges($definition);
$options = array_replace_recursive(self::$defaultOptions, $options);
$label = $this->formatLabel($de | for nodes (places)
* * edge: The default options for edges
*/
public function dump(Definition $definition, ?Marking $marking = null, array $options = []): string
{
$withMetadata = $options['with-metadat | {
"filepath": "src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php",
"language": "php",
"file_size": 3150,
"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\Workflow\DependencyInjection;
use Symfony\Component\DependencyInj... | cess(ContainerBuilder $container): void
{
foreach ($container->findTaggedServiceIds('workflow') as $id => $attributes) {
$container->register("debug.{$id}", TraceableWorkflow::class)
->setDecoratedService($id)
| ceableWorkflow;
/**
* Adds all configured security voters to the access decision manager.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class WorkflowDebugPass implements CompilerPassInterface
{
public function pro | {
"filepath": "src/Symfony/Component/Workflow/DependencyInjection/WorkflowDebugPass.php",
"language": "php",
"file_size": 1382,
"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 Symfony\Component\Security\Csrf;
/**
* A CSRF token.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class CsrfToken
{
private... | function getId(): string
{
return $this->id;
}
/**
* Returns the value of the CSRF token.
*/
public function getValue(): string
{
return $this->value;
}
/**
* Returns the value of the CSRF token | Returns the ID of the CSRF token.
*/
public | {
"filepath": "src/Symfony/Component/Security/Csrf/CsrfToken.php",
"language": "php",
"file_size": 984,
"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\Csrf;
/**
* Manages CSRF tokens.
*
* @author Bernhard Schussek <bs... | or the ID
*/
public function getToken(string $tokenId): CsrfToken;
/**
* Generates a new token value for the given ID.
*
* This method will generate a new token for the given token ID, independent
* of whether a token valu |
* generated. Otherwise the existing token is returned (with the same value,
* not the same instance).
*
* @param string $tokenId The token ID. You may choose an arbitrary value
* f | {
"filepath": "src/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.php",
"language": "php",
"file_size": 1738,
"cut_index": 537,
"middle_length": 229
} |
se Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
/**
* This CSRF token manager uses a combination of cookie and headers to validate non-persistent tokens.
*
* This manager is designed to be stateless and compati... | ss configuring your reverse proxy to send the X-Forwarded-* / Forwarded headers
* if you're behind one.
*
* The check relying on the double-submit requires a JavaScript snippet on the client side,
* responsible for generating a cryptographically-secure | e request;
* - a special token was double-submitted in the request payload and as a cookie and/or a header.
*
* The check using the Origin/Referer headers relies on the app being able to know its own target
* origin. Don't mi | {
"filepath": "src/Symfony/Component/Security/Csrf/SameOriginCsrfTokenManager.php",
"language": "php",
"file_size": 12073,
"cut_index": 921,
"middle_length": 229
} |
>
*/
class CsrfTokenManagerTest extends TestCase
{
public function testGetNonExistingTokenEmptyNamespace()
{
$generator = $this->createMock(TokenGeneratorInterface::class);
$storage = $this->createMock(TokenStorageInterface::class);
$this->assertGetNonExistingToken('', $this->getEmptyN... | nction testGetNonExistingTokenCustomNamespace()
{
$generator = $this->createMock(TokenGeneratorInterface::class);
$storage = $this->createMock(TokenStorageInterface::class);
$this->assertGetNonExistingToken('aNamespace-', $this | ace::class);
$storage = $this->createMock(TokenStorageInterface::class);
$this->assertGetNonExistingToken('https-', $this->getHttpsNamespaceMocks($generator, $storage), $storage, $generator);
}
public fu | {
"filepath": "src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php",
"language": "php",
"file_size": 27495,
"cut_index": 1331,
"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\Csrf\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfo... | ginCsrfListener('csrf-token');
}
public function testOnKernelResponseClearsCookies()
{
$request = new Request([], [], ['csrf-token' => 2], ['csrf-token_test' => 'csrf-token']);
$response = new Response();
$eventMainRequ | eOriginCsrfListener;
class SameOriginCsrfListenerTest extends TestCase
{
private SameOriginCsrfListener $sameOriginCsrfListener;
protected function setUp(): void
{
$this->sameOriginCsrfListener = new SameOri | {
"filepath": "src/Symfony/Component/Security/Csrf/Tests/SameOriginCsrfListenerTest.php",
"language": "php",
"file_size": 3160,
"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\Csrf\Tests\TokenGenerator;
use PHPUnit\Framework\Attributes\DataProvi... | setUpBeforeClass(): void
{
self::$bytes = base64_decode('aMf+Tct/RLn2WQ==');
}
protected function setUp(): void
{
$this->generator = new UriSafeTokenGenerator(self::ENTROPY);
}
public function testGenerateToken()
| eratorTest extends TestCase
{
private const ENTROPY = 1000;
/**
* A non alphanumeric byte string.
*/
private static string $bytes;
private UriSafeTokenGenerator $generator;
public static function | {
"filepath": "src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php",
"language": "php",
"file_size": 1887,
"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\Csrf\Tests\TokenStorage;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Reques... | ACE = 'foobar';
private Session $session;
private SessionTokenStorage $storage;
protected function setUp(): void
{
$this->session = new Session(new MockArraySessionStorage());
$request = new Request();
$request->se | otFoundException;
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class SessionTokenStorageTest extends TestCase
{
private const SESSION_NAMESP | {
"filepath": "src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php",
"language": "php",
"file_size": 4902,
"cut_index": 614,
"middle_length": 229
} |
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;
use Symfony\Component\HttpFoundation\Request;
/**
* AccessM... | eturns security attributes and required channel for the supplied request.
*
* @return array{0: array|null, 1: string|null} A tuple of security attributes and the required channel
*/
public function getPatterns(Request $request): array;
} |
*/
interface AccessMapInterface
{
/**
* R | {
"filepath": "src/Symfony/Component/Security/Http/AccessMapInterface.php",
"language": "php",
"file_size": 844,
"cut_index": 535,
"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\Http;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKern... | cation
* (a Basic authentication for the /api, and a web based authentication for
* everything else for instance).
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Firewall implements EventSubscriberInterface
{
/**
* @var \SplObject |
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
/**
* Firewall uses a FirewallMap to register security listeners for the given
* request.
*
* It allows for different security strategies within the same appli | {
"filepath": "src/Symfony/Component/Security/Http/Firewall.php",
"language": "php",
"file_size": 3906,
"cut_index": 614,
"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\Workflow\Debug;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Marking;
use Symfony\C... | unction __construct(
private readonly WorkflowInterface $workflow,
private readonly Stopwatch $stopwatch,
protected readonly ?\Closure $disabled = null,
) {
}
public function getMarking(object $subject, array $context = | TransitionBlockerList;
use Symfony\Component\Workflow\WorkflowInterface;
/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class TraceableWorkflow implements WorkflowInterface
{
private array $calls = [];
public f | {
"filepath": "src/Symfony/Component/Workflow/Debug/TraceableWorkflow.php",
"language": "php",
"file_size": 4025,
"cut_index": 614,
"middle_length": 229
} |
a graphviz file.
*
* You can convert the generated dot file with the dot utility (https://graphviz.org/):
*
* dot -Tpng workflow.dot > workflow.png
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class GraphvizDumper implements DumperInterface
{
// All ... | ];
/**
* Dumps the workflow as a graphviz graph.
*
* Available options:
*
* * graph: The default options for the whole graph
* * node: The default options for nodes (places + transitions)
* * edge: The default op | l', 'color' => '#333333', 'fillcolor' => 'lightblue', 'fixedsize' => 'false', 'width' => '1'],
'edge' => ['fontsize' => '9', 'fontname' => 'Arial', 'color' => '#333333', 'arrowhead' => 'normal', 'arrowsize' => '0.5'],
| {
"filepath": "src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php",
"language": "php",
"file_size": 13499,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Workflow\Dumper;
use Symfony\Component\Workflow\Arc;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
use Symfony\Component\Workflow\Marking;
class MermaidDumper implements DumperInterface
{
... | LEFT,
self::DIRECTION_LEFT_TO_RIGHT,
];
public const TRANSITION_TYPE_STATEMACHINE = 'statemachine';
public const TRANSITION_TYPE_WORKFLOW = 'workflow';
private const VALID_TRANSITION_TYPES = [
self::TRANSITION_TYPE_STATEMA | ublic const DIRECTION_LEFT_TO_RIGHT = 'LR';
private const VALID_DIRECTIONS = [
self::DIRECTION_TOP_TO_BOTTOM,
self::DIRECTION_TOP_DOWN,
self::DIRECTION_BOTTOM_TO_TOP,
self::DIRECTION_RIGHT_TO_ | {
"filepath": "src/Symfony/Component/Workflow/Dumper/MermaidDumper.php",
"language": "php",
"file_size": 8890,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Csrf;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;
use Symfony\Component\Security\Csrf\TokenGe... | ate TokenGeneratorInterface $generator;
private TokenStorageInterface $storage;
private \Closure|string $namespace;
/**
* @param $namespace
* * null: generates a namespace using $_SERVER['HTTPS']
* | lt implementation of {@link CsrfTokenManagerInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class CsrfTokenManager implements CsrfTokenManagerInterface
{
priv | {
"filepath": "src/Symfony/Component/Security/Csrf/CsrfTokenManager.php",
"language": "php",
"file_size": 5198,
"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\Csrf;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Respon... | $cookieName)) {
throw new \InvalidArgumentException('The cookie name contains invalid characters.');
}
}
public function onKernelResponse(ResponseEvent $event): void
{
if (!$event->isMainRequest()) {
re | rivate readonly string $cookieName = 'csrf-token',
) {
if (!$cookieName) {
throw new \InvalidArgumentException('The cookie name cannot be empty.');
}
if (!preg_match('/^[-a-zA-Z0-9_]+$/D', | {
"filepath": "src/Symfony/Component/Security/Csrf/SameOriginCsrfListener.php",
"language": "php",
"file_size": 2328,
"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\Csrf\Tests\TokenStorage;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Att... | SPACE = 'foobar';
private NativeSessionTokenStorage $storage;
protected function setUp(): void
{
$_SESSION = [];
$this->storage = new NativeSessionTokenStorage(self::SESSION_NAMESPACE);
}
public function testStoreTok | veSessionTokenStorage;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
#[PreserveGlobalState(false)]
#[RunTestsInSeparateProcesses]
class NativeSessionTokenStorageTest extends TestCase
{
private const SESSION_NAME | {
"filepath": "src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php",
"language": "php",
"file_size": 4018,
"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\Csrf\TokenStorage;
use Symfony\Component\Security\Csrf\Exception\TokenNotFoundException;
/**
... | *
* @param string $namespace The namespace under which the token is stored in the session
*/
public function __construct(
private string $namespace = self::SESSION_NAMESPACE,
) {
}
public function getToken(string $tok | /**
* The namespace used to store values in the session.
*/
public const SESSION_NAMESPACE = '_csrf';
private bool $sessionStarted = false;
/**
* Initializes the storage with a session namespace.
| {
"filepath": "src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php",
"language": "php",
"file_size": 2626,
"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\Http;
use Symfony\Component\HttpFoundation\Request;
use ... | stener to use
* for the given request.
*
* If there are no authentication listeners, the first inner array must be
* empty.
*
* If there is no exception listener, the second element of the outer array
* must be null.
|
/**
* This interface must be implemented by firewall maps.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface FirewallMapInterface
{
/**
* Returns the authentication listeners, and the exception li | {
"filepath": "src/Symfony/Component/Security/Http/FirewallMapInterface.php",
"language": "php",
"file_size": 1285,
"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\Workflow\DependencyInjection;
use Symfony\Component\DependencyInj... | {
if (!$container->hasParameter('workflow.has_guard_listeners')) {
return;
}
$container->getParameterBag()->remove('workflow.has_guard_listeners');
$servicesNeeded = [
'security.token_storage',
| Flothmann <christian.flothmann@sensiolabs.de>
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class WorkflowGuardListenerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
| {
"filepath": "src/Symfony/Component/Workflow/DependencyInjection/WorkflowGuardListenerPass.php",
"language": "php",
"file_size": 1426,
"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\Csrf\TokenGenerator;
/**
* Generates CSRF tokens.... | entException('Entropy should be greater than 7.');
}
}
public function generateToken(): string
{
// Generate an URI safe base64 encoded string that does not contain "+",
// "/" or "=" which need to be URL encoded and ma | * @param int $entropy The amount of entropy collected for each token (in bits)
*/
public function __construct(
private int $entropy = 256,
) {
if ($entropy <= 7) {
throw new \InvalidArgum | {
"filepath": "src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php",
"language": "php",
"file_size": 1180,
"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\Workflow\Metadata;
use Symfony\Component\Workflow\Transition;
/*... | ?\SplObjectStorage $transitionsMetadata = null,
) {
$this->transitionsMetadata = $transitionsMetadata ?? new \SplObjectStorage();
}
public function getWorkflowMetadata(): array
{
return $this->workflowMetadata;
} | sMetadata;
/**
* @param \SplObjectStorage<Transition, array>|null $transitionsMetadata
*/
public function __construct(
private array $workflowMetadata = [],
private array $placesMetadata = [],
| {
"filepath": "src/Symfony/Component/Workflow/Metadata/InMemoryMetadataStore.php",
"language": "php",
"file_size": 1285,
"cut_index": 524,
"middle_length": 229
} |
utes\TestWith;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\... | ArgumentException::class);
new SameOriginCsrfTokenManager(new RequestStack(), new NullLogger(), null, [], SameOriginCsrfTokenManager::CHECK_NO_HEADER, '');
}
public function testInvalidCookieNameCharacters()
{
$this->expectExce | ty\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\SameOriginCsrfTokenManager;
class SameOriginCsrfTokenManagerTest extends TestCase
{
public function testInvalidCookieName()
{
$this->expectException(\Invalid | {
"filepath": "src/Symfony/Component/Security/Csrf/Tests/SameOriginCsrfTokenManagerTest.php",
"language": "php",
"file_size": 13583,
"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 Symfony\Component\Workflow\DependencyInjection;
use Symfony\Component\Config\Resour... | foreach ($attributes as $attribute) {
foreach ($attribute['definition_validators'] ?? [] as $validatorClass) {
$container->addResource(new FileResource($container->getReflectionClass($validatorClass)->getFileN | yrixx.info>
*/
class WorkflowValidatorPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
foreach ($container->findTaggedServiceIds('workflow') as $attributes) {
| {
"filepath": "src/Symfony/Component/Workflow/DependencyInjection/WorkflowValidatorPass.php",
"language": "php",
"file_size": 1387,
"cut_index": 524,
"middle_length": 229
} |
Response;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component... | ent\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
use Symfony\Component\Security\Http | se Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Compon | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php",
"language": "php",
"file_size": 14198,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFact... | onent\Security\Http\Event\LoginSuccessEvent;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*
* @final
*/
class PasswordMigratingListener implements EventSubscriberInterface
{
public function __construct(
private PasswordHasherFactoryInt | ent\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Comp | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/PasswordMigratingListener.php",
"language": "php",
"file_size": 3101,
"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\Http\EventListener;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSub... |
/**
* The RememberMe *listener* creates and deletes remember-me cookies.
*
* Upon login success or failure and support for remember me
* in the firewall and authenticator, this listener will create
* a remember-me cookie.
* Upon login failure, all r | Http\Event\LoginSuccessEvent;
use Symfony\Component\Security\Http\Event\LogoutEvent;
use Symfony\Component\Security\Http\Event\TokenDeauthenticatedEvent;
use Symfony\Component\Security\Http\RememberMe\RememberMeHandlerInterface;
| {
"filepath": "src/Symfony/Component/Security/Http/EventListener/RememberMeListener.php",
"language": "php",
"file_size": 2733,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security... | ion onLogout(LogoutEvent $event): void
{
if ($event->getRequest()->hasSession()) {
$event->getRequest()->getSession()->invalidate();
}
}
public static function getSubscribedEvents(): array
{
return [
| plements EventSubscriberInterface
{
public funct | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/SessionLogoutListener.php",
"language": "php",
"file_size": 952,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscr... | @author Wouter de Jong <wouter@wouterj.nl>
*/
class SessionStrategyListener implements EventSubscriberInterface
{
public function __construct(
private SessionAuthenticationStrategyInterface $sessionAuthenticationStrategy,
) {
}
p | on\SessionAuthenticationStrategyInterface;
/**
* Migrates/invalidates the session after successful login.
*
* This should be registered as subscriber to any "stateful" firewalls.
*
* @see SessionAuthenticationStrategy
*
* | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/SessionStrategyListener.php",
"language": "php",
"file_size": 1813,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscr... |
*/
class UserCheckerListener implements EventSubscriberInterface
{
public function __construct(
private UserCheckerInterface $userChecker,
) {
}
public function preCheckCredentials(CheckPassportEvent $event): void
{
$ | rInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PreAuthenticatedUserBadge;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*
* @final | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/UserCheckerListener.php",
"language": "php",
"file_size": 1794,
"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\EventListener;
use Symfony\Component\Security... | iderInterface $userProvider,
) {
}
public function checkPassport(CheckPassportEvent $event): void
{
$passport = $event->getPassport();
if (!$passport->hasBadge(UserBadge::class)) {
return;
}
/** | he user provider as user loader, if no user load
* has been explicitly set.
*
* @author Wouter de Jong <wouter@wouterj.nl>
*
* @final
*/
class UserProviderListener
{
public function __construct(
private UserProv | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/UserProviderListener.php",
"language": "php",
"file_size": 1251,
"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\Http\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Htt... | AccessMap();
$map->add($requestMatcher1, ['ROLE_ADMIN'], 'http');
$map->add($requestMatcher2, ['ROLE_USER'], 'https');
$this->assertSame([['ROLE_USER'], 'https'], $map->getPatterns($request));
}
public function testReturn | stReturnsFirstMatchedPattern()
{
$request = new Request();
$requestMatcher1 = $this->getRequestMatcher($request, false);
$requestMatcher2 = $this->getRequestMatcher($request, true);
$map = new | {
"filepath": "src/Symfony/Component/Security/Http/Tests/AccessMapTest.php",
"language": "php",
"file_size": 1646,
"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\Http\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcherInter... |
->method('matches')
->with($this->equalTo($request))
->willReturn(false)
;
$map->add($notMatchingMatcher, [static function () {}]);
$matchingMatcher = $this->createMock(RequestMatcherInterface: | eners()
{
$map = new FirewallMap();
$request = new Request();
$notMatchingMatcher = $this->createMock(RequestMatcherInterface::class);
$notMatchingMatcher
->expects($this->once()) | {
"filepath": "src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php",
"language": "php",
"file_size": 3610,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use... | rnelRequestRegistersExceptionListener()
{
$dispatcher = new EventDispatcher();
$listener = $this->createMock(ExceptionListener::class);
$listener
->expects($this->once())
->method('register')
| ttp\Firewall\ExceptionListener;
use Symfony\Component\Security\Http\Firewall\FirewallListenerInterface;
use Symfony\Component\Security\Http\FirewallMapInterface;
class FirewallTest extends TestCase
{
public function testOnKe | {
"filepath": "src/Symfony/Component/Security/Http/Tests/FirewallTest.php",
"language": "php",
"file_size": 5187,
"cut_index": 716,
"middle_length": 229
} |
outing\Matcher\RequestMatcherInterface;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Http\Security... | function testCreateRedirectResponseWithAbsoluteUrl()
{
$utils = new HttpUtils($this->getUrlGenerator());
$response = $utils->createRedirectResponse($this->getRequest(), 'http://symfony.com/');
$this->assertTrue($response->isRe | ponse = $utils->createRedirectResponse($this->getRequest(), '/foobar');
$this->assertTrue($response->isRedirect('http://localhost/foobar'));
$this->assertEquals(302, $response->getStatusCode());
}
public | {
"filepath": "src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php",
"language": "php",
"file_size": 18217,
"cut_index": 1331,
"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\Http\Tests\Util;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Session\S... | $obj->doSetTargetPath($session, 'firewall_name', '/foo');
}
public function testGetTargetPath()
{
$obj = new TestClassWithTargetPathTrait();
$session = $this->createMock(SessionInterface::class);
$session->expect | assWithTargetPathTrait();
$session = $this->createMock(SessionInterface::class);
$session->expects($this->once())
->method('set')
->with('_security.firewall_name.target_path', '/foo');
| {
"filepath": "src/Symfony/Component/Security/Http/Tests/Util/TargetPathTraitTest.php",
"language": "php",
"file_size": 2241,
"cut_index": 563,
"middle_length": 229
} |
ion\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
use Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface;
use Sy... | ony\Component\Security\Http\RememberMe\RememberMeDetails;
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
class PersistentRememberMeHandlerTest extends TestCase
{
private TokenProviderInterface $tokenProvider;
private InMemoryUser | tion\CookieTheftException;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
use Symfony\Component\Security\Http\RememberMe\PersistentRememberMeHandler;
use Symf | {
"filepath": "src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentRememberMeHandlerTest.php",
"language": "php",
"file_size": 13635,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Tests\RememberMe;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Http\RememberMe\RememberMeDe... | ;
$this->assertSame('series1:token_value', $rememberMeDetails->getValue());
}
public function testFromRawCookieChildClassWithNewConstructorSignature()
{
$rememberMeDetails = RememberMeDetailsChild::fromRawCookie(self::getRememb | e());
$this->assertSame(RememberMeDetails::class, $rememberMeDetails::class);
$this->assertSame('wouter', $rememberMeDetails->getUserIdentifier());
$this->assertSame(360, $rememberMeDetails->getExpires()) | {
"filepath": "src/Symfony/Component/Security/Http/Tests/RememberMe/RememberMeDetailsTest.php",
"language": "php",
"file_size": 6757,
"cut_index": 716,
"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\Http\Tests\RememberMe;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
... | esponse()
{
$cookie = new Cookie('rememberme', null, 0, '/', null, false, true, false, null);
$request = $this->getRequest([
ResponseListener::COOKIE_ATTR_NAME => $cookie,
]);
$response = $this->getResponse | tpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
class ResponseListenerTest extends TestCase
{
public function testRememberMeCookieIsSentWithR | {
"filepath": "src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php",
"language": "php",
"file_size": 3261,
"cut_index": 614,
"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\Http\Tests\RememberMe;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Cookie;
use Sy... | urity\Http\RememberMe\RememberMeDetails;
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
use Symfony\Component\Security\Http\RememberMe\SignatureRememberMeHandler;
class SignatureRememberMeHandlerTest extends TestCase
{
private Signat | thenticationException;
use Symfony\Component\Security\Core\Signature\SignatureHasher;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
use Symfony\Component\Sec | {
"filepath": "src/Symfony/Component/Security/Http/Tests/RememberMe/SignatureRememberMeHandlerTest.php",
"language": "php",
"file_size": 4394,
"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\Http\Tests\Fixtures;
use Symfony\Component\Security\Core... | {
return $this->username;
}
public function getRoles(): array
{
return $this->roles;
}
public function getPassword(): ?string
{
return $this->password ?? null;
}
#[\Deprecated]
public function | lic function __construct(
private string $username,
private array $roles,
private ?string $password,
private ?bool $hashPassword,
) {
}
public function getUserIdentifier(): string
| {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/CustomUser.php",
"language": "php",
"file_size": 1423,
"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\Http\Tests\Fixtures;
use Symfony\Component\HttpFoundatio... | ;
/**
* @author Alexandre Daubois <alex.daubois@gmail.com>
*/
class DummyAuthenticator implements AuthenticatorInterface
{
public function supports(Request $request): ?bool
{
return null;
}
public function authenticate(Request $ | xception;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/DummyAuthenticator.php",
"language": "php",
"file_size": 1440,
"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\Tests\Fixtures;
use Symfony\Component\ExpressionLanguage\Express... | "foo_" ~ args.slug'))]
public function withInvalidExpressionId(string $id)
{
}
#[IsCsrfTokenValid('foo', tokenKey: 'my_token_key')]
public function withCustomTokenKey()
{
}
#[IsCsrfTokenValid('foo', tokenKey: 'invalid_toke | foo')]
public function withDefaultTokenKey()
{
}
#[IsCsrfTokenValid(new Expression('"foo_" ~ args.id'))]
public function withCustomExpressionId(string $id)
{
}
#[IsCsrfTokenValid(new Expression(' | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/IsCsrfTokenValidAttributeMethodsController.php",
"language": "php",
"file_size": 1954,
"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\Http\Tests\Fixtures;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component... | g1Name', 'arg2Name'])]
public function withSubjectArray($arg1Name, $arg2Name)
{
}
#[IsGranted(attribute: 'ROLE_ADMIN', subject: 'non_existent')]
public function withMissingSubject()
{
}
#[IsGranted(attribute: 'ROLE_ADMIN', | ')]
public function admin()
{
}
#[IsGranted(attribute: 'ROLE_ADMIN', subject: 'arg2Name')]
public function withSubject($arg1Name, $arg2Name)
{
}
#[IsGranted(attribute: 'ROLE_ADMIN', subject: ['ar | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsController.php",
"language": "php",
"file_size": 2662,
"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\Http\Tests\Fixtures;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Compo... | ;
}, subject: 'arg2Name')]
public function withSubject($arg1Name, $arg2Name)
{
}
#[IsGranted(static function (IsGrantedContext $context) {
return $context->isGranted('ROLE_ADMIN');
}, subject: ['arg1Name', 'arg2Name'])]
| Context $context) {
return $context->isGranted('ROLE_ADMIN');
})]
public function admin()
{
}
#[IsGranted(static function (IsGrantedContext $context) {
return $context->isGranted('ROLE_ADMIN') | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsWithClosureController.php",
"language": "php",
"file_size": 2745,
"cut_index": 563,
"middle_length": 229
} |
he 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\Tests\Fixtures;
use Doctrine\Persistence\Proxy;
use Symfony\Component\Secu... | sInitialized(): bool
{
return $this->initialized;
}
public function getRoles(): array
{
return ['ROLE_USER'];
}
public function eraseCredentials(): void
{
}
public function getUserIdentifier(): string
| ->initialized = true;
}
public function __i | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/LazyDoctrinePersistenceUser.php",
"language": "php",
"file_size": 892,
"cut_index": 547,
"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\Http\Tests\Fixtures;
use Symfony\Component\Secu... | return $this;
}
public function resetLazyObject(): bool
{
$this->initialized = false;
return true;
}
public function getRoles(): array
{
return ['ROLE_USER'];
}
public function eraseCredentials(): | alse;
public function isLazyObjectInitialized(bool $partial = false): bool
{
return $this->initialized;
}
public function initializeLazyObject(): object
{
$this->initialized = true;
| {
"filepath": "src/Symfony/Component/Security/Http/Tests/Fixtures/LazyVarExporterUser.php",
"language": "php",
"file_size": 1104,
"cut_index": 515,
"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\Http\Tests\Logout;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack... | ge $tokenStorage;
private LogoutUrlGenerator $generator;
protected function setUp(): void
{
$requestStack = new RequestStack();
$requestStack->push(new Request());
$this->tokenStorage = new TokenStorage();
$thi | Core\User\InMemoryUser;
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
/**
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
class LogoutUrlGeneratorTest extends TestCase
{
private TokenStora | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php",
"language": "php",
"file_size": 4110,
"cut_index": 614,
"middle_length": 229
} |
vent\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Securi... | dException;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Http\AccessMapInterface;
use Symfony\Component\Security\Http\Event\LazyResponseEvent;
use Symfony\Component\Sec | cessDecision;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\Exception\AccessDenie | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php",
"language": "php",
"file_size": 10898,
"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\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\R... | $request = Request::create('http://symfony.com');
$accessMap = new AccessMap();
$accessMap->add(new SchemeRequestMatcher('https'), [], 'http');
$listener = new ChannelListener($accessMap);
$this->assertFalse($listener | Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Http\Firewall\ChannelListener;
class ChannelListenerTest extends TestCase
{
public function testHandleWithNotSecuredRequestAndHttpChannel()
{
| {
"filepath": "src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php",
"language": "php",
"file_size": 3324,
"cut_index": 614,
"middle_length": 229
} |
omponent\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authenticat... | amePasswordToken;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\U | ackingTokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\Usern | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php",
"language": "php",
"file_size": 26518,
"cut_index": 1331,
"middle_length": 229
} |
cher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Au... | ion;
use Symfony\Component\Security\Core\Exception\LogoutException;
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\Secu | rage;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AuthenticationExcept | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php",
"language": "php",
"file_size": 9713,
"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 Symfony\Component\Security\Http\EventListener;
use Symfony\Component\EventDispatche... | er.
* Can be '*' or a subset of 'cache', 'cookies', 'storage', 'clientHints', 'executionContexts', 'prefetchCache', 'prerenderCache'.
*/
public function __construct(private readonly array $cookieValue)
{
} | .com>
*
* @final
*/
class ClearSiteDataLogoutListener implements EventSubscriberInterface
{
private const HEADER_NAME = 'Clear-Site-Data';
/**
* @param string[] $cookieValue The value for the Clear-Site-Data head | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/ClearSiteDataLogoutListener.php",
"language": "php",
"file_size": 1453,
"cut_index": 524,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
... | onent\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Http\Event\LogoutEvent;
use Symfony\Component\Security\Http\Firewall\LogoutListener;
use Symfony\Component\Security\Http\HttpUtils; | nent\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\LogoutException;
use Symfony\Comp | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php",
"language": "php",
"file_size": 6784,
"cut_index": 716,
"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\Http\Authentication;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use... | er the behavior
* while keeping the default behavior.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Alexander <iam.asm89@gmail.com>
*/
class DefaultAuthenticationFailureHandler implem | ecurity\Http\ParameterBagUtils;
use Symfony\Component\Security\Http\SecurityRequestAttributes;
/**
* Class with the default authentication failure handling logic.
*
* Can be optionally be extended from by the developer to alt | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php",
"language": "php",
"file_size": 3524,
"cut_index": 614,
"middle_length": 229
} |
nstraint\Constraint;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Comp... | ymfony\Component\Security\Http\LoginLink\Exception\ExpiredLoginLinkException;
use Symfony\Component\Security\Http\LoginLink\Exception\InvalidLoginLinkException;
use Symfony\Component\Security\Http\LoginLink\LoginLinkHandler;
class LoginLinkHandlerTest ext | \Core\Signature\ExpiredSignatureStorage;
use Symfony\Component\Security\Core\Signature\SignatureHasher;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use S | {
"filepath": "src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php",
"language": "php",
"file_size": 14242,
"cut_index": 921,
"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\Http\Tests\Session;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Reques... | $this->createMock(Request::class);
$request->expects($this->never())->method('getSession');
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE);
$strategy->onAuthentication($request, new NullToken()); | TokenStorageInterface;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
class SessionAuthenticationStrategyTest extends TestCase
{
public function testSessionIsNotChanged()
{
$request = | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php",
"language": "php",
"file_size": 3027,
"cut_index": 563,
"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\AccessToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authenticator... | ure...).
*
* @author Florent Morselli <florent.morselli@spomky-labs.com>
*/
interface AccessTokenHandlerInterface
{
/**
* @throws AuthenticationException
*/
public function getUserBadgeFrom(#[\SensitiveParameter] string $accessToken): | en (e.g. revocation, expiration time, digital signat | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/AccessTokenHandlerInterface.php",
"language": "php",
"file_size": 927,
"cut_index": 606,
"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\Http\AccessToken;
use Symfony\Component\HttpFoundation\R... | html/rfc6750#section-2.2
*/
final class FormEncodedBodyExtractor implements AccessTokenExtractorInterface
{
public function __construct(
private readonly string $parameter = 'access_token',
) {
}
public function extractAccessToken | n application contexts
* where participating browsers do not have access to the "Authorization" request header field.
*
* @author Florent Morselli <florent.morselli@spomky-labs.com>
*
* @see https://datatracker.ietf.org/doc/ | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/FormEncodedBodyExtractor.php",
"language": "php",
"file_size": 1358,
"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\Http\AccessToken;
use Symfony\Component\HttpFoundation\R... | @see https://datatracker.ietf.org/doc/html/rfc6750#section-2.3
*/
final class QueryAccessTokenExtractor implements AccessTokenExtractorInterface
{
public const PARAMETER = 'access_token';
public function __construct(
private readonly str | RL containing the access token will be logged,
* it SHOULD NOT be used unless it is impossible to transport the access token in the
* request header field.
*
* @author Florent Morselli <florent.morselli@spomky-labs.com>
*
* | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/QueryAccessTokenExtractor.php",
"language": "php",
"file_size": 1259,
"cut_index": 524,
"middle_length": 229
} |
anager;
use Jose\Component\Core\JWKSet;
use Jose\Component\Encryption\JWEDecrypter;
use Jose\Component\Encryption\JWETokenSupport;
use Jose\Component\Encryption\Serializer\CompactSerializer as JweCompactSerializer;
use Jose\Component\Encryption\Serializer\JWESerializerManager;
use Jose\Component\Signature\JWSTokenSuppo... | rInterface;
use Symfony\Component\Security\Http\AccessToken\Oidc\Exception\InvalidSignatureException;
use Symfony\Component\Security\Http\AccessToken\Oidc\Exception\MissingClaimException;
use Symfony\Component\Security\Http\Authenticator\FallbackUserLoader | se Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Clock\Clock;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Http\AccessToken\AccessTokenHandle | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/Oidc/OidcTokenHandler.php",
"language": "php",
"file_size": 14383,
"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\Http\AccessToken\Cas;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundat... | tact@nicolasattard.fr>
*/
final class Cas2Handler implements AccessTokenHandlerInterface
{
public function __construct(
private readonly RequestStack $requestStack,
private readonly string $validationUrl,
private readonly strin | rity\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Contracts\HttpClient\HttpClientInterface;
/**
* @see https://apereo.github.io/cas/6.6.x/protocol/CAS-Protocol-V2-Specification.html
*
* @author Nicolas Attard <con | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/Cas/Cas2Handler.php",
"language": "php",
"file_size": 3321,
"cut_index": 614,
"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\Http\AccessToken\OAuth2;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component... | rver and the Introspection Endpoint.
*
* @see https://tools.ietf.org/html/rfc7662
*
* @internal
*/
final class Oauth2TokenHandler implements AccessTokenHandlerInterface
{
public function __construct(
private readonly HttpClientInterface $c | Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use function Symfony\Component\String\u;
/**
* The token handler validates the token on the authorization se | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/OAuth2/Oauth2TokenHandler.php",
"language": "php",
"file_size": 3753,
"cut_index": 614,
"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\Http\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Comp... | #[AsCommand(name: 'security:oidc:generate-token', description: 'Generate an OIDC token for a given user')]
final class OidcTokenGenerateCommand extends Command
{
/** @var array<string, OidcTokenGenerator> */
private array $generators = [];
/** | use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Security\Http\AccessToken\Oidc\OidcTokenGenerator;
| {
"filepath": "src/Symfony/Component/Security/Http/Command/OidcTokenGenerateCommand.php",
"language": "php",
"file_size": 4682,
"cut_index": 614,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFact... |
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
/**
* This listeners uses the interfaces of authenticators to
* determine how to check credentials | curity\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CustomCredentials; | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/CheckCredentialsListener.php",
"language": "php",
"file_size": 3518,
"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\Http\EventListener;
use Symfony\Component\EventDispatche... | /
public function __construct(
private array $cookies,
) {
}
public function onLogout(LogoutEvent $event): void
{
if (!$response = $event->getResponse()) {
return;
}
foreach ($this->cookies | ittjoh@gmail.com>
*
* @final
*/
class CookieClearingLogoutListener implements EventSubscriberInterface
{
/**
* @param array $cookies An array of cookies (keys are names, values contain path and domain) to unset
* | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/CookieClearingLogoutListener.php",
"language": "php",
"file_size": 1421,
"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\EventListener;
use Symfony\Component\EventDispatcher\EventSubscr... | otectionListener implements EventSubscriberInterface
{
public function __construct(
private CsrfTokenManagerInterface $csrfTokenManager,
) {
}
public function checkPassport(CheckPassportEvent $event): void
{
$passport = | face;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*
* @final
*/
class CsrfPr | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/CsrfProtectionListener.php",
"language": "php",
"file_size": 1730,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfo... | ecision;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\RuntimeException;
use Symfony\Component\Security\Ht | y\Component\HttpKernel\EventListener\ControllerAttributesListener;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authorization\AccessD | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php",
"language": "php",
"file_size": 4895,
"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\Http\EventListener;
use Symfony\Component\EventDis... | private HttpUtils $httpUtils,
private string $targetUrl = '/',
) {
}
public function onLogout(LogoutEvent $event): void
{
if (null !== $event->getResponse()) {
return;
}
$event->setRespo | configured path.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Alexander <iam.asm89@gmail.com>
*
* @final
*/
class DefaultLogoutListener implements EventSubscriberInterface
{
public function __construct(
| {
"filepath": "src/Symfony/Component/Security/Http/EventListener/DefaultLogoutListener.php",
"language": "php",
"file_size": 1247,
"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\Http\Authentication;
use Symfony\Component\HttpFou... |
private AuthenticationFailureHandlerInterface $handler,
array $options,
) {
if (method_exists($handler, 'setOptions')) {
$this->handler->setOptions($options);
}
}
public function onAuthenticationFai |
class CustomAuthenticationFailureHandler implements AuthenticationFailureHandlerInterface
{
/**
* @param array $options Options for processing a successful authentication attempt
*/
public function __construct( | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/CustomAuthenticationFailureHandler.php",
"language": "php",
"file_size": 1164,
"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\Http\Authentication;
use Symfony\Component\HttpFoundatio... | private AuthenticationSuccessHandlerInterface $handler,
array $options,
string $firewallName,
) {
if (method_exists($handler, 'setOptions')) {
$this->handler->setOptions($options);
}
if (method_ | ss CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
{
/**
* @param array $options Options for processing a successful authentication attempt
*/
public function __construct(
| {
"filepath": "src/Symfony/Component/Security/Http/Authentication/CustomAuthenticationSuccessHandler.php",
"language": "php",
"file_size": 1309,
"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\Http\Authentication;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use... | ander <iam.asm89@gmail.com>
*/
class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
{
use TargetPathTrait;
protected array $options;
protected ?string $firewallName = null;
protected array $defaultOpt | t\Security\Http\Util\TargetPathTrait;
/**
* Class with the default authentication success handling logic.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Alex | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php",
"language": "php",
"file_size": 3876,
"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\Http\AccessToken;
use Symfony\Component\HttpF... | }
public function extractAccessToken(Request $request): ?string
{
foreach ($this->accessTokenExtractors as $extractor) {
if ($accessToken = $extractor->extractAccessToken($request)) {
return $accessToken;
| mplements AccessTokenExtractorInterface
{
/**
* @param AccessTokenExtractorInterface[] $accessTokenExtractors
*/
public function __construct(
private readonly iterable $accessTokenExtractors,
) {
| {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/ChainAccessTokenExtractor.php",
"language": "php",
"file_size": 1047,
"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\Http\AccessToken\Oidc;
use Jose\Component\Core\Algorithm;
use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\JWKSet;
use Jose\Compo... | y string $claim = 'sub',
private readonly ClockInterface $clock = new Clock(),
) {
}
public function generate(string $userIdentifier, ?string $algorithmAlias = null, ?string $issuer = null, ?int $ttl = null, ?\DateTimeImmutable $notBef | nction __construct(
private readonly AlgorithmManager $algorithmManager,
private readonly JWKSet $jwkset,
private readonly string $audience,
private readonly array $issuers,
private readonl | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/Oidc/OidcTokenGenerator.php",
"language": "php",
"file_size": 3980,
"cut_index": 614,
"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\Http\AccessToken\Oidc;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\S... | he token on the OIDC server and retrieves the user identifier.
*/
final class OidcUserInfoTokenHandler implements AccessTokenHandlerInterface
{
use OidcTrait;
private ?CacheInterface $discoveryCache = null;
private ?string $oidcConfigurationC | llbackUserLoader;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
/**
* The token handler validates t | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/Oidc/OidcUserInfoTokenHandler.php",
"language": "php",
"file_size": 3746,
"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\Http\EventListener;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSub... | key under your firewall is configured
* C) The "remember me" functionality is activated. This is usually
* done by having a _remember_me checkbox in your form, but
* can be configured by the "always_remember_me" and "remember_me_parameter"
* | Http\ParameterBagUtils;
/**
* Checks if all conditions are met for remember me.
*
* The conditions that must be met for this listener to enable remember me:
* A) This badge is present in the Passport
* B) The remember_me | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/CheckRememberMeConditionsListener.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\Http\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel... | UserInterface}.
*
* @author Iltar van der Berg <kjarli@gmail.com>
*/
final class UserValueResolver implements ValueResolverInterface
{
public function __construct(
private TokenStorageInterface $tokenStorage,
) {
}
public funct | ;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
/**
* Supports the argument type of {@see | {
"filepath": "src/Symfony/Component/Security/Http/Controller/UserValueResolver.php",
"language": "php",
"file_size": 2647,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RateLimiter\PeekableReque... | nt\LoginFailureEvent;
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
use Symfony\Component\Security\Http\SecurityRequestAttributes;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*/
final class LoginThrottlingListener implements EventSub | eption\TooManyLoginAttemptsAuthenticationException;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
use Symfony\Component\Security\Http\Eve | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/LoginThrottlingListener.php",
"language": "php",
"file_size": 3304,
"cut_index": 614,
"middle_length": 229
} |
rface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundExc... | ents;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class SwitchUserListenerTest extends TestCase
{
private TokenStorage $tokenStorage;
private InMemoryUserProvider $userProvider;
private UserCheckerInterface $userChecker;
| Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
use Symfony\Component\Security\Http\SecurityEv | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php",
"language": "php",
"file_size": 20898,
"cut_index": 1331,
"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\Http\Impersonate;
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
use Symfony\Component... | .com>
*/
class ImpersonateUrlGenerator
{
public function __construct(
private RequestStack $requestStack,
private FirewallMap $firewallMap,
private TokenStorageInterface $tokenStorage,
) {
}
public function generat | use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
/**
* Provides generator functions for the impersonation urls.
*
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
* @author Damien Fayet <damienf1521@gmail | {
"filepath": "src/Symfony/Component/Security/Http/Impersonate/ImpersonateUrlGenerator.php",
"language": "php",
"file_size": 2809,
"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\Http\AccessToken\Oidc;
use Symfony\Component\Security\Core\User\OidcU... | ny/string".');
}
foreach ($claims as $claim => $value) {
unset($claims[$claim]);
if ('' === $value || null === $value) {
continue;
}
$claims[u($claim)->camel()->toString()] = |
if (!\function_exists('Symfony\Component\String\u')) {
throw new \LogicException('You cannot use the "OidcUserInfoTokenHandler" since the String component is not installed. Try running "composer require symfo | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/Oidc/OidcTrait.php",
"language": "php",
"file_size": 1732,
"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\EventListener;
use Symfony\Component\EventDis... | ion __construct(
private ClearableTokenStorageInterface $csrfTokenStorage,
) {
}
public function onLogout(LogoutEvent $event): void
{
if ($this->csrfTokenStorage instanceof SessionTokenStorage && !$event->getRequest()->hasP | fony\Component\Security\Http\Event\LogoutEvent;
/**
* @author Christian Flothmann <christian.flothmann@sensiolabs.de>
*
* @final
*/
class CsrfTokenClearingLogoutListener implements EventSubscriberInterface
{
public funct | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/CsrfTokenClearingLogoutListener.php",
"language": "php",
"file_size": 1247,
"cut_index": 518,
"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\Http\Authentication;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
... | if authentication should be attempted on this request.
*
* @see FirewallListenerInterface::supports()
*/
public function supports(Request $request): ?bool;
/**
* Tries to authenticate the request and returns a response - if an | catorManagerInterface
{
/**
* Called to see | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/AuthenticatorManagerInterface.php",
"language": "php",
"file_size": 995,
"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\Http\Authentication;
use Symfony\Component\HttpFou... | y login a user and return a
* Response *if any* for success.
*
* @param BadgeInterface[] $badges Optionally, pass some Passport badges to use for the manual login
* @param array<string, mixed> $attributes Optionally, pass some P | ;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*/
interface UserAuthenticatorInterface
{
/**
* Convenience method to programmaticall | {
"filepath": "src/Symfony/Component/Security/Http/Authentication/UserAuthenticatorInterface.php",
"language": "php",
"file_size": 1231,
"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\Http\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sy... | tin Myakshin <molodchick@gmail.com>
*/
final class SecurityTokenValueResolver implements ValueResolverInterface
{
public function __construct(private readonly TokenStorageInterface $tokenStorage)
{
}
/**
* @return TokenInterface[]
| omponent\HttpKernel\Exception\HttpException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
* @author Konstan | {
"filepath": "src/Symfony/Component/Security/Http/Controller/SecurityTokenValueResolver.php",
"language": "php",
"file_size": 1594,
"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\Http\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
u... | onent\Security\Http\Attribute\IsCsrfTokenValid;
/**
* Handles the IsCsrfTokenValid attribute on controllers.
*/
final class IsCsrfTokenValidAttributeListener implements EventSubscriberInterface
{
public function __construct(
private readonly | nent\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Comp | {
"filepath": "src/Symfony/Component/Security/Http/EventListener/IsCsrfTokenValidAttributeListener.php",
"language": "php",
"file_size": 3817,
"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\Http\AccessToken;
use Symfony\Component\HttpFoundation\R... | te readonly string $tokenType = 'Bearer',
) {
$this->regex = \sprintf(
'/^%s([a-zA-Z0-9\-_\+~\/\.]+=*)$/',
'' === $this->tokenType ? '' : preg_quote($this->tokenType).'\s+'
);
}
public function extractAc |
*/
final class HeaderAccessTokenExtractor implements AccessTokenExtractorInterface
{
private string $regex;
public function __construct(
private readonly string $headerParameter = 'Authorization',
priva | {
"filepath": "src/Symfony/Component/Security/Http/AccessToken/HeaderAccessTokenExtractor.php",
"language": "php",
"file_size": 1355,
"cut_index": 524,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Tests\Authenticator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Secu... | \Security\Http\Authenticator\FallbackUserLoader;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
class AccessTokenAuthenticatorTest extends TestCase
{
private InMemoryUserProvider $userProvider;
protected function setU | \Security\Http\AccessToken\AccessTokenHandlerInterface;
use Symfony\Component\Security\Http\AccessToken\HeaderAccessTokenExtractor;
use Symfony\Component\Security\Http\Authenticator\AccessTokenAuthenticator;
use Symfony\Component | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Authenticator/AccessTokenAuthenticatorTest.php",
"language": "php",
"file_size": 6864,
"cut_index": 716,
"middle_length": 229
} |
rage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Exception\LockedException;
use S... | erface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; | use Symfony\Component\Security\Http\Authentication\ExposeSecurityLevel;
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInt | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticatorManagerTest.php",
"language": "php",
"file_size": 21462,
"cut_index": 1331,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Tests\Authentication;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\... | nt\Security\Http\HttpUtils;
class DefaultAuthenticationSuccessHandlerTest extends TestCase
{
#[DataProvider('getRequestRedirections')]
public function testRequestRedirections(Request $request, $options, $redirectedUrl)
{
$urlGenerator | ny\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;
use Symfony\Compone | {
"filepath": "src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php",
"language": "php",
"file_size": 7661,
"cut_index": 716,
"middle_length": 229
} |
Symfony\Component\HttpClient\Response\JsonMockResponse;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\User\OidcUser;
use Symfony\Component\Security\Http\AccessToken\Oidc\OidcTokenHandler;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserB... | xp' => $time + 3600,
'iss' => 'https://www.example.com',
'aud' => self::AUDIENCE,
'sub' => 'e21bf182-1538-406e-8ccb-e25a17aba39f',
'email' => 'foo@example.com',
];
$token = self::buildJWS(json | der('getClaims')]
public function testGetsUserIdentifierFromSignedToken(string $claim, string $expected)
{
$time = time();
$claims = [
'iat' => $time,
'nbf' => $time,
'e | {
"filepath": "src/Symfony/Component/Security/Http/Tests/AccessToken/Oidc/OidcTokenHandlerTest.php",
"language": "php",
"file_size": 22658,
"cut_index": 1331,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Security\Http\Tests\AccessToken\Cas;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Sy... | Hosts(['.*']);
}
protected function tearDown(): void
{
Request::setTrustedHosts([]);
}
public function testWithValidTicket()
{
$response = new MockResponse(<<<BODY
<cas:serviceResponse xmlns:cas='ht | \Http\AccessToken\Cas\Cas2Handler;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
final class Cas2HandlerTest extends TestCase
{
protected function setUp(): void
{
Request::setTrusted | {
"filepath": "src/Symfony/Component/Security/Http/Tests/AccessToken/Cas/Cas2HandlerTest.php",
"language": "php",
"file_size": 7244,
"cut_index": 716,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.