@ -211,12 +211,23 @@ import org.springframework.security.web.savedrequest.DefaultSavedRequest;
@@ -211,12 +211,23 @@ import org.springframework.security.web.savedrequest.DefaultSavedRequest;
import org.springframework.security.web.savedrequest.SimpleSavedRequest ;
import org.springframework.security.web.server.firewall.ServerExchangeRejectedException ;
import org.springframework.security.web.session.HttpSessionCreatedEvent ;
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs ;
import org.springframework.security.web.webauthn.api.AuthenticatorTransport ;
import org.springframework.security.web.webauthn.api.Bytes ;
import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput ;
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput ;
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs ;
import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity ;
import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor ;
import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions ;
import org.springframework.security.web.webauthn.api.PublicKeyCredentialType ;
import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity ;
import org.springframework.security.web.webauthn.api.TestBytes ;
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions ;
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity ;
import org.springframework.security.web.webauthn.api.UserVerificationRequirement ;
import org.springframework.security.web.webauthn.authentication.WebAuthnAuthentication ;
import org.springframework.util.ReflectionUtils ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.fail ;
@ -584,6 +595,41 @@ class SpringSecurityCoreVersionSerializableTests {
@@ -584,6 +595,41 @@ class SpringSecurityCoreVersionSerializableTests {
webAuthnAuthentication . setDetails ( details ) ;
return webAuthnAuthentication ;
} ) ;
// webauthn
CredProtectAuthenticationExtensionsClientInput . CredProtect credProtect = new CredProtectAuthenticationExtensionsClientInput . CredProtect (
CredProtectAuthenticationExtensionsClientInput . CredProtect . ProtectionPolicy . USER_VERIFICATION_OPTIONAL ,
true ) ;
Bytes id = TestBytes . get ( ) ;
AuthenticationExtensionsClientInputs inputs = new ImmutableAuthenticationExtensionsClientInputs (
ImmutableAuthenticationExtensionsClientInput . credProps ) ;
// @formatter:off
PublicKeyCredentialDescriptor descriptor = PublicKeyCredentialDescriptor . builder ( )
. id ( id )
. type ( PublicKeyCredentialType . PUBLIC_KEY )
. transports ( Set . of ( AuthenticatorTransport . USB ) )
. build ( ) ;
// @formatter:on
generatorByClassName . put ( AuthenticatorTransport . class , ( a ) - > AuthenticatorTransport . USB ) ;
generatorByClassName . put ( PublicKeyCredentialType . class , ( k ) - > PublicKeyCredentialType . PUBLIC_KEY ) ;
generatorByClassName . put ( UserVerificationRequirement . class , ( r ) - > UserVerificationRequirement . REQUIRED ) ;
generatorByClassName . put ( CredProtectAuthenticationExtensionsClientInput . CredProtect . class , ( c ) - > credProtect ) ;
generatorByClassName . put ( CredProtectAuthenticationExtensionsClientInput . class ,
( c ) - > new CredProtectAuthenticationExtensionsClientInput ( credProtect ) ) ;
generatorByClassName . put ( ImmutableAuthenticationExtensionsClientInputs . class , ( i ) - > inputs ) ;
Field credPropsField = ReflectionUtils . findField ( ImmutableAuthenticationExtensionsClientInput . class ,
"credProps" ) ;
generatorByClassName . put ( credPropsField . getType ( ) ,
( i ) - > ImmutableAuthenticationExtensionsClientInput . credProps ) ;
generatorByClassName . put ( Bytes . class , ( b ) - > id ) ;
generatorByClassName . put ( PublicKeyCredentialDescriptor . class , ( d ) - > descriptor ) ;
// @formatter:off
generatorByClassName . put ( PublicKeyCredentialRequestOptions . class , ( o ) - > TestPublicKeyCredentialRequestOptions . create ( )
. extensions ( inputs )
. allowCredentials ( List . of ( descriptor ) )
. build ( )
) ;
// @formatter:on
}
@ParameterizedTest