|
196 | 196 | import org.springframework.security.web.firewall.RequestRejectedException; |
197 | 197 | import org.springframework.security.web.server.firewall.ServerExchangeRejectedException; |
198 | 198 | import org.springframework.security.web.session.HttpSessionCreatedEvent; |
| 199 | +import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs; |
| 200 | +import org.springframework.security.web.webauthn.api.AuthenticatorTransport; |
| 201 | +import org.springframework.security.web.webauthn.api.Bytes; |
| 202 | +import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput; |
| 203 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput; |
| 204 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs; |
| 205 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor; |
| 206 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions; |
| 207 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialType; |
| 208 | +import org.springframework.security.web.webauthn.api.TestBytes; |
| 209 | +import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions; |
| 210 | +import org.springframework.security.web.webauthn.api.UserVerificationRequirement; |
199 | 211 | import org.springframework.util.ReflectionUtils; |
200 | 212 |
|
201 | 213 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -515,6 +527,39 @@ class SpringSecurityCoreVersionSerializableTests { |
515 | 527 | (r) -> new AuthenticationSwitchUserEvent(authentication, user)); |
516 | 528 | generatorByClassName.put(HttpSessionCreatedEvent.class, |
517 | 529 | (r) -> new HttpSessionCreatedEvent(new MockHttpSession())); |
| 530 | + |
| 531 | + // webauthn |
| 532 | + CredProtectAuthenticationExtensionsClientInput.CredProtect credProtect = new CredProtectAuthenticationExtensionsClientInput.CredProtect( |
| 533 | + CredProtectAuthenticationExtensionsClientInput.CredProtect.ProtectionPolicy.USER_VERIFICATION_OPTIONAL, |
| 534 | + true); |
| 535 | + Bytes id = TestBytes.get(); |
| 536 | + AuthenticationExtensionsClientInputs inputs = new ImmutableAuthenticationExtensionsClientInputs( |
| 537 | + ImmutableAuthenticationExtensionsClientInput.credProps); |
| 538 | + // @formatter:off |
| 539 | + PublicKeyCredentialDescriptor descriptor = PublicKeyCredentialDescriptor.builder() |
| 540 | + .id(id) |
| 541 | + .type(PublicKeyCredentialType.PUBLIC_KEY) |
| 542 | + .transports(Set.of(AuthenticatorTransport.USB)) |
| 543 | + .build(); |
| 544 | + // @formatter:on |
| 545 | + generatorByClassName.put(AuthenticatorTransport.class, (a) -> AuthenticatorTransport.USB); |
| 546 | + generatorByClassName.put(PublicKeyCredentialType.class, (k) -> PublicKeyCredentialType.PUBLIC_KEY); |
| 547 | + generatorByClassName.put(UserVerificationRequirement.class, (r) -> UserVerificationRequirement.REQUIRED); |
| 548 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.CredProtect.class, (c) -> credProtect); |
| 549 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.class, |
| 550 | + (c) -> new CredProtectAuthenticationExtensionsClientInput(credProtect)); |
| 551 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInputs.class, (i) -> inputs); |
| 552 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInput.class, |
| 553 | + (i) -> ImmutableAuthenticationExtensionsClientInput.credProps); |
| 554 | + generatorByClassName.put(Bytes.class, (b) -> id); |
| 555 | + generatorByClassName.put(PublicKeyCredentialDescriptor.class, (d) -> descriptor); |
| 556 | + // @formatter:off |
| 557 | + generatorByClassName.put(PublicKeyCredentialRequestOptions.class, (o) -> TestPublicKeyCredentialRequestOptions.create() |
| 558 | + .extensions(inputs) |
| 559 | + .allowCredentials(List.of(descriptor)) |
| 560 | + .build() |
| 561 | + ); |
| 562 | + // @formatter:on |
518 | 563 | } |
519 | 564 |
|
520 | 565 | @ParameterizedTest |
|
0 commit comments