|
30 | 30 | import java.nio.file.Files; |
31 | 31 | import java.nio.file.Path; |
32 | 32 | import java.nio.file.Paths; |
| 33 | +import java.time.Duration; |
33 | 34 | import java.time.Instant; |
34 | 35 | import java.util.ArrayList; |
35 | 36 | import java.util.Collection; |
|
191 | 192 | import org.springframework.security.web.firewall.RequestRejectedException; |
192 | 193 | import org.springframework.security.web.server.firewall.ServerExchangeRejectedException; |
193 | 194 | import org.springframework.security.web.session.HttpSessionCreatedEvent; |
| 195 | +import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs; |
| 196 | +import org.springframework.security.web.webauthn.api.AuthenticatorTransport; |
| 197 | +import org.springframework.security.web.webauthn.api.Bytes; |
| 198 | +import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput; |
| 199 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput; |
| 200 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs; |
| 201 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor; |
| 202 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions; |
| 203 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialType; |
| 204 | +import org.springframework.security.web.webauthn.api.UserVerificationRequirement; |
194 | 205 |
|
195 | 206 | import static org.assertj.core.api.Assertions.assertThat; |
196 | 207 | import static org.assertj.core.api.Assertions.fail; |
@@ -508,6 +519,43 @@ class SpringSecurityCoreVersionSerializableTests { |
508 | 519 | (r) -> new AuthenticationSwitchUserEvent(authentication, user)); |
509 | 520 | generatorByClassName.put(HttpSessionCreatedEvent.class, |
510 | 521 | (r) -> new HttpSessionCreatedEvent(new MockHttpSession())); |
| 522 | + |
| 523 | + // webauthn |
| 524 | + CredProtectAuthenticationExtensionsClientInput.CredProtect credProtect = new CredProtectAuthenticationExtensionsClientInput.CredProtect( |
| 525 | + CredProtectAuthenticationExtensionsClientInput.CredProtect.ProtectionPolicy.USER_VERIFICATION_OPTIONAL, |
| 526 | + true); |
| 527 | + Bytes id = new Bytes(("test").getBytes()); |
| 528 | + AuthenticationExtensionsClientInputs inputs = new ImmutableAuthenticationExtensionsClientInputs( |
| 529 | + ImmutableAuthenticationExtensionsClientInput.credProps); |
| 530 | + // @formatter:off |
| 531 | + PublicKeyCredentialDescriptor descriptor = PublicKeyCredentialDescriptor.builder() |
| 532 | + .id(id) |
| 533 | + .type(PublicKeyCredentialType.PUBLIC_KEY) |
| 534 | + .transports(Set.of(AuthenticatorTransport.USB)) |
| 535 | + .build(); |
| 536 | + // @formatter:on |
| 537 | + generatorByClassName.put(AuthenticatorTransport.class, (a) -> AuthenticatorTransport.USB); |
| 538 | + generatorByClassName.put(PublicKeyCredentialType.class, (k) -> PublicKeyCredentialType.PUBLIC_KEY); |
| 539 | + generatorByClassName.put(UserVerificationRequirement.class, (r) -> UserVerificationRequirement.REQUIRED); |
| 540 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.CredProtect.class, (c) -> credProtect); |
| 541 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.class, |
| 542 | + (c) -> new CredProtectAuthenticationExtensionsClientInput(credProtect)); |
| 543 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInputs.class, (i) -> inputs); |
| 544 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInput.class, |
| 545 | + (i) -> ImmutableAuthenticationExtensionsClientInput.credProps); |
| 546 | + generatorByClassName.put(Bytes.class, (b) -> id); |
| 547 | + generatorByClassName.put(PublicKeyCredentialDescriptor.class, (d) -> descriptor); |
| 548 | + // @formatter:off |
| 549 | + generatorByClassName.put(PublicKeyCredentialRequestOptions.class, (o) -> PublicKeyCredentialRequestOptions.builder() |
| 550 | + .allowCredentials(List.of(descriptor)) |
| 551 | + .rpId("example.localhost") |
| 552 | + .challenge(Bytes.fromBase64("I69THX904Q8ONhCgUgOu2PCQCcEjTDiNmokdbgsAsYU")) |
| 553 | + .userVerification(UserVerificationRequirement.REQUIRED) |
| 554 | + .extensions(inputs) |
| 555 | + .timeout(Duration.ofMinutes(5)) |
| 556 | + .build() |
| 557 | + ); |
| 558 | + // @formatter:on |
511 | 559 | } |
512 | 560 |
|
513 | 561 | @ParameterizedTest |
|
0 commit comments