The start of something beautiful
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Symfony\Component\HttpKernel\Attribute\ValueResolver;
|
||||
use Symfony\Component\Security\Http\Controller\UserValueResolver;
|
||||
|
||||
/**
|
||||
* Indicates that a controller argument should receive the current logged user.
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_PARAMETER)]
|
||||
class CurrentUser extends ValueResolver
|
||||
{
|
||||
/**
|
||||
* @param bool $disabled Whether this value resolver is disabled, which allows to enable a value resolver globally while disabling it in specific cases
|
||||
* @param string $resolver The class name of the resolver to use
|
||||
*/
|
||||
public function __construct(bool $disabled = false, string $resolver = UserValueResolver::class)
|
||||
{
|
||||
parent::__construct($resolver, $disabled);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)]
|
||||
final class IsCsrfTokenValid
|
||||
{
|
||||
public function __construct(
|
||||
/**
|
||||
* Sets the id, or an Expression evaluated to the id, used when generating the token.
|
||||
*/
|
||||
public string|Expression $id,
|
||||
|
||||
/**
|
||||
* Sets the key of the request that contains the actual token value that should be validated.
|
||||
*/
|
||||
public ?string $tokenKey = '_token',
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
/**
|
||||
* Checks if user has permission to access to some resource using security roles and voters.
|
||||
*
|
||||
* @see https://symfony.com/doc/current/security.html#roles
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knpuniversity.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)]
|
||||
final class IsGranted
|
||||
{
|
||||
/**
|
||||
* @param string|Expression $attribute The attribute that will be checked against a given authentication token and optional subject
|
||||
* @param array|string|Expression|null $subject An optional subject - e.g. the current object being voted on
|
||||
* @param string|null $message A custom message when access is not granted
|
||||
* @param int|null $statusCode If set, will throw HttpKernel's HttpException with the given $statusCode; if null, Security\Core's AccessDeniedException will be used
|
||||
* @param int|null $exceptionCode If set, will add the exception code to thrown exception
|
||||
*/
|
||||
public function __construct(
|
||||
public string|Expression $attribute,
|
||||
public array|string|Expression|null $subject = null,
|
||||
public ?string $message = null,
|
||||
public ?int $statusCode = null,
|
||||
public ?int $exceptionCode = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user