api/symfony/Component/Validator/Constraints/NotCompromisedPasswordValidator.yaml
2024-09-26 02:03:21 -07:00

61 lines
3 KiB
YAML

name: NotCompromisedPasswordValidator
class_comment: "# * Checks if a password has been leaked in a data breach using haveibeenpwned.com's\
\ API.\n# * Use a k-anonymity model to protect the password being searched for.\n\
# *\n# * @see https://haveibeenpwned.com/API/v2#SearchingPwnedPasswordsByRange\n\
# *\n# * @author K\xE9vin Dunglas <dunglas@gmail.com>"
dependencies:
- name: HttpClient
type: class
source: Symfony\Component\HttpClient\HttpClient
- name: Constraint
type: class
source: Symfony\Component\Validator\Constraint
- name: ConstraintValidator
type: class
source: Symfony\Component\Validator\ConstraintValidator
- name: LogicException
type: class
source: Symfony\Component\Validator\Exception\LogicException
- name: UnexpectedTypeException
type: class
source: Symfony\Component\Validator\Exception\UnexpectedTypeException
- name: UnexpectedValueException
type: class
source: Symfony\Component\Validator\Exception\UnexpectedValueException
- name: ExceptionInterface
type: class
source: Symfony\Contracts\HttpClient\Exception\ExceptionInterface
- name: HttpClientInterface
type: class
source: Symfony\Contracts\HttpClient\HttpClientInterface
properties: []
methods:
- name: validate
visibility: public
parameters:
- name: value
- name: constraint
comment: "# * Checks if a password has been leaked in a data breach using haveibeenpwned.com's\
\ API.\n# * Use a k-anonymity model to protect the password being searched for.\n\
# *\n# * @see https://haveibeenpwned.com/API/v2#SearchingPwnedPasswordsByRange\n\
# *\n# * @author K\xE9vin Dunglas <dunglas@gmail.com>\n# */\n# class NotCompromisedPasswordValidator\
\ extends ConstraintValidator\n# {\n# private const DEFAULT_API_ENDPOINT = 'https://api.pwnedpasswords.com/range/%s';\n\
# \n# private HttpClientInterface $httpClient;\n# private string $charset;\n#\
\ private bool $enabled;\n# private string $endpoint;\n# \n# public function __construct(?HttpClientInterface\
\ $httpClient = null, string $charset = 'UTF-8', bool $enabled = true, ?string\
\ $endpoint = null)\n# {\n# if (null === $httpClient && !class_exists(HttpClient::class))\
\ {\n# throw new LogicException(\\sprintf('The \"%s\" class requires the \"HttpClient\"\
\ component. Try running \"composer require symfony/http-client\".', self::class));\n\
# }\n# \n# $this->httpClient = $httpClient ?? HttpClient::create();\n# $this->charset\
\ = $charset;\n# $this->enabled = $enabled;\n# $this->endpoint = $endpoint ??\
\ self::DEFAULT_API_ENDPOINT;\n# }\n# \n# /**\n# * @throws ExceptionInterface"
traits:
- Symfony\Component\HttpClient\HttpClient
- Symfony\Component\Validator\Constraint
- Symfony\Component\Validator\ConstraintValidator
- Symfony\Component\Validator\Exception\LogicException
- Symfony\Component\Validator\Exception\UnexpectedTypeException
- Symfony\Component\Validator\Exception\UnexpectedValueException
- Symfony\Contracts\HttpClient\Exception\ExceptionInterface
- Symfony\Contracts\HttpClient\HttpClientInterface
interfaces: []