Skip to content

Commit

Permalink
Fixed authenticator_selection_criteria authenticator attachment config (
Browse files Browse the repository at this point in the history
#467)

Co-authored-by: Florent Morselli <florent.morselli@spomky-labs.com>
  • Loading branch information
marcriemer and Spomky committed Sep 6, 2023
1 parent 87895ca commit 77586f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/symfony/src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,31 @@ private function addCreationProfilesConfig(ArrayNodeDefinition $rootNode): void
->end()
->arrayNode('authenticator_selection_criteria')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifArray()
->then(function (array $v): array {
if (isset($v['attachment_mode'])) {
$v['authenticator_attachment'] = $v['attachment_mode'];
unset($v['attachment_mode']);
}

return $v;
})
->end()
->children()
->scalarNode('attachment_mode')
->setDeprecated('web-auth/webauthn-symfony-bundle', '4.7.0', 'Use "authenticator_attachment" instead')
->defaultValue(AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE)
->validate()
->ifNotInArray([
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_PLATFORM,
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM,
])
->thenInvalid($errorTemplate)
->end()
->end()
->scalarNode('authenticator_attachment')
->defaultValue(AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE)
->validate()
->ifNotInArray([
Expand Down
2 changes: 1 addition & 1 deletion tests/symfony/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ webauthn:
icon: null
challenge_length: 32
authenticator_selection_criteria:
attachment_mode: !php/const Webauthn\AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE
authenticator_attachment: !php/const Webauthn\AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE
require_resident_key: false
user_verification: !php/const Webauthn\AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED
resident_key: !php/const Webauthn\AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_REQUIRED
Expand Down

0 comments on commit 77586f3

Please sign in to comment.