|
206 | 206 | import org.springframework.security.web.savedrequest.SimpleSavedRequest;
|
207 | 207 | import org.springframework.security.web.server.firewall.ServerExchangeRejectedException;
|
208 | 208 | import org.springframework.security.web.session.HttpSessionCreatedEvent;
|
| 209 | +import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs; |
| 210 | +import org.springframework.security.web.webauthn.api.AuthenticatorTransport; |
209 | 211 | import org.springframework.security.web.webauthn.api.Bytes;
|
| 212 | +import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput; |
| 213 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput; |
| 214 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs; |
210 | 215 | import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity;
|
| 216 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor; |
| 217 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions; |
| 218 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialType; |
211 | 219 | import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity;
|
212 | 220 | import org.springframework.security.web.webauthn.api.TestBytes;
|
| 221 | +import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions; |
213 | 222 | import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity;
|
| 223 | +import org.springframework.security.web.webauthn.api.UserVerificationRequirement; |
214 | 224 | import org.springframework.security.web.webauthn.authentication.WebAuthnAuthentication;
|
215 | 225 | import org.springframework.util.ReflectionUtils;
|
216 | 226 |
|
@@ -554,7 +564,39 @@ class SpringSecurityCoreVersionSerializableTests {
|
554 | 564 | });
|
555 | 565 |
|
556 | 566 | // webauthn
|
557 |
| - generatorByClassName.put(Bytes.class, (r) -> TestBytes.get()); |
| 567 | + CredProtectAuthenticationExtensionsClientInput.CredProtect credProtect = new CredProtectAuthenticationExtensionsClientInput.CredProtect( |
| 568 | + CredProtectAuthenticationExtensionsClientInput.CredProtect.ProtectionPolicy.USER_VERIFICATION_OPTIONAL, |
| 569 | + true); |
| 570 | + Bytes id = TestBytes.get(); |
| 571 | + AuthenticationExtensionsClientInputs inputs = new ImmutableAuthenticationExtensionsClientInputs( |
| 572 | + ImmutableAuthenticationExtensionsClientInput.credProps); |
| 573 | + // @formatter:off |
| 574 | + PublicKeyCredentialDescriptor descriptor = PublicKeyCredentialDescriptor.builder() |
| 575 | + .id(id) |
| 576 | + .type(PublicKeyCredentialType.PUBLIC_KEY) |
| 577 | + .transports(Set.of(AuthenticatorTransport.USB)) |
| 578 | + .build(); |
| 579 | + // @formatter:on |
| 580 | + generatorByClassName.put(AuthenticatorTransport.class, (a) -> AuthenticatorTransport.USB); |
| 581 | + generatorByClassName.put(PublicKeyCredentialType.class, (k) -> PublicKeyCredentialType.PUBLIC_KEY); |
| 582 | + generatorByClassName.put(UserVerificationRequirement.class, (r) -> UserVerificationRequirement.REQUIRED); |
| 583 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.CredProtect.class, (c) -> credProtect); |
| 584 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.class, |
| 585 | + (c) -> new CredProtectAuthenticationExtensionsClientInput(credProtect)); |
| 586 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInputs.class, (i) -> inputs); |
| 587 | + Field credPropsField = ReflectionUtils.findField(ImmutableAuthenticationExtensionsClientInput.class, |
| 588 | + "credProps"); |
| 589 | + generatorByClassName.put(credPropsField.getType(), |
| 590 | + (i) -> ImmutableAuthenticationExtensionsClientInput.credProps); |
| 591 | + generatorByClassName.put(Bytes.class, (b) -> id); |
| 592 | + generatorByClassName.put(PublicKeyCredentialDescriptor.class, (d) -> descriptor); |
| 593 | + // @formatter:off |
| 594 | + generatorByClassName.put(PublicKeyCredentialRequestOptions.class, (o) -> TestPublicKeyCredentialRequestOptions.create() |
| 595 | + .extensions(inputs) |
| 596 | + .allowCredentials(List.of(descriptor)) |
| 597 | + .build() |
| 598 | + ); |
| 599 | + // @formatter:on |
558 | 600 | generatorByClassName.put(ImmutablePublicKeyCredentialUserEntity.class,
|
559 | 601 | (r) -> TestPublicKeyCredentialUserEntity.userEntity().id(TestBytes.get()).build());
|
560 | 602 | generatorByClassName.put(WebAuthnAuthentication.class, (r) -> {
|
|
0 commit comments