Skip to content

Commit

Permalink
Allow configuration of NotCompromisedPassword API endpoint in Framewo…
Browse files Browse the repository at this point in the history
…rkBundle
  • Loading branch information
xelan committed Apr 10, 2019
1 parent b35d049 commit c372b16
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,19 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->end()
->end()
->end()
->booleanNode('disable_not_compromised_password')
->defaultFalse()
->info('Disable NotCompromisedPassword Validator: the value will always be valid.')
->arrayNode('not_compromised_password')
->addDefaultsIfNotSet()
->info('not-compromised password validator configuration')
->children()
->booleanNode('enabled')
->defaultTrue()
->info('Enable NotCompromisedPassword Validator. When disabled, the value will always be valid.')
->end()
->scalarNode('endpoint')
->defaultValue('https://api.pwnedpasswords.com/range/%s')
->info('API endpoint for NotCompromisedPassword Validator.')
->end()
->end()
->end()
->arrayNode('auto_mapping')
->useAttributeAsKey('namespace')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,8 @@ private function registerValidationConfiguration(array $config, ContainerBuilder

$container
->getDefinition('validator.not_compromised_password')
->setArgument(2, $config['disable_not_compromised_password'])
->setArgument(2, !$config['not_compromised_password']['enabled'])
->setArgument(3, $config['not_compromised_password']['endpoint'])
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ protected static function getBundleDefaultConfig()
'paths' => [],
],
'auto_mapping' => [],
'disable_not_compromised_password' => false,
'not_compromised_password' => [
'enabled' => true,
'endpoint' => 'https://api.pwnedpasswords.com/range/%s',
],
],
'annotations' => [
'cache' => 'php_array',
Expand Down

0 comments on commit c372b16

Please sign in to comment.