From 77586f34c5ee77687b607e16f0d3fccb0c41d1ac Mon Sep 17 00:00:00 2001 From: Marc Riemer Date: Wed, 6 Sep 2023 14:23:18 +0200 Subject: [PATCH] Fixed authenticator_selection_criteria authenticator attachment config (#467) Co-authored-by: Florent Morselli --- .../src/DependencyInjection/Configuration.php | 23 +++++++++++++++++++ tests/symfony/config/config.yml | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/symfony/src/DependencyInjection/Configuration.php b/src/symfony/src/DependencyInjection/Configuration.php index c8b29232..6265c553 100644 --- a/src/symfony/src/DependencyInjection/Configuration.php +++ b/src/symfony/src/DependencyInjection/Configuration.php @@ -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([ diff --git a/tests/symfony/config/config.yml b/tests/symfony/config/config.yml index 00465589..3830ac2a 100644 --- a/tests/symfony/config/config.yml +++ b/tests/symfony/config/config.yml @@ -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