-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
How to use NotCompromisedPasswordValidator in tests/dev? #30871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Maybe we could register a no-op ConstraintValidator for that constraint in testing mode (not sure about dev mode though) |
Using a MockHttpClient could do it also, not sure how easy it would be though. |
It would be nice to be able to use DIC parameter: /**
* Assert\NotPwnedValidator(disabled="%kernel.debug%")
*/
private $email BTW, we have such behavior in an internal project for google recaptcha; class RecaptchaValidator extends ConstraintValidator
{
private $enabled;
private $privateKey;
private $requestStack;
private $httpClient;
public function __construct(array $recaptchaConfig, RequestStack $requestStack, HttpClient $httpClient)
{
$this->enabled = $recaptchaConfig['enabled'];
$this->privateKey = $recaptchaConfig['private_key'];
$this->requestStack = $requestStack;
$this->httpClient = $httpClient;
}
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
// if recaptcha is disabled, always valid
if (!$this->enabled) {
return;
} |
Well, this |
Given that this issue will come up more frequently now that we have an HTTP client - shouldn't we introduce some global setting that disables all external dependencies, that defaults to |
…swordValidator (lyrixx) This PR was merged into the 4.3-dev branch. Discussion ---------- [Validator] Add an option to disable NotCompromisedPasswordValidator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30871 | License | MIT | Doc PR | symfony/symfony-docs#11327 EUFOSSA Commits ------- 9a2787e [Validator] Add an option to disable NotCompromisedPasswordValidator
…rdValidator configurable (xelan) This PR was squashed before being merged into the 4.3-dev branch (closes #31060). Discussion ---------- [Validator] Make API endpoint for NotCompromisedPasswordValidator configurable | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | yes, but acceptable [1] | Deprecations? | no [1] | Tests pass? | yes | Fixed tickets | #30871, #31054 | License | MIT | Doc PR | symfony/symfony-docs#... (TODO) Makes the API endpoint for the `NotCompromisedPasswordValidator` configurable. The endpoint includes the placeholder which will be replaced with the first digits of the password hash for k-anonymity. The endpoint can either be set via constructor injection of the validator if the component is used standalone, or via the framework configuration of symfony/framework-bundle. [1] As discussed in #31054, the validator is not in a stable release yet, therefore the BC break is considered acceptable. No deprecation / BC layer is necessary. Commits ------- f6a80c2 [Validator] Make API endpoint for NotCompromisedPasswordValidator configurable
Asked on https://symfony.com/blog/new-in-symfony-4-3-compromised-password-validator
What's the recommended way to test/dev with the validator added on entities via annotations?
The text was updated successfully, but these errors were encountered: