Skip to content

Commit 177ce59

Browse files
committed
Merge branch '6.4.x'
Implement Serializable for WebAuthnAuthentication Closes gh-16474
2 parents f813201 + e557c72 commit 177ce59

8 files changed

+42
-6
lines changed

config/src/test/java/org/springframework/security/SpringSecurityCoreVersionSerializableTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@
196196
import org.springframework.security.web.firewall.RequestRejectedException;
197197
import org.springframework.security.web.server.firewall.ServerExchangeRejectedException;
198198
import org.springframework.security.web.session.HttpSessionCreatedEvent;
199+
import org.springframework.security.web.webauthn.api.Bytes;
200+
import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity;
201+
import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity;
202+
import org.springframework.security.web.webauthn.api.TestBytes;
203+
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity;
204+
import org.springframework.security.web.webauthn.authentication.WebAuthnAuthentication;
199205
import org.springframework.util.ReflectionUtils;
200206

201207
import static org.assertj.core.api.Assertions.assertThat;
@@ -515,6 +521,20 @@ class SpringSecurityCoreVersionSerializableTests {
515521
(r) -> new AuthenticationSwitchUserEvent(authentication, user));
516522
generatorByClassName.put(HttpSessionCreatedEvent.class,
517523
(r) -> new HttpSessionCreatedEvent(new MockHttpSession()));
524+
525+
// webauthn
526+
generatorByClassName.put(Bytes.class, (r) -> TestBytes.get());
527+
generatorByClassName.put(ImmutablePublicKeyCredentialUserEntity.class,
528+
(r) -> TestPublicKeyCredentialUserEntity.userEntity().id(TestBytes.get()).build());
529+
generatorByClassName.put(WebAuthnAuthentication.class, (r) -> {
530+
PublicKeyCredentialUserEntity userEntity = TestPublicKeyCredentialUserEntity.userEntity()
531+
.id(TestBytes.get())
532+
.build();
533+
List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_USER");
534+
WebAuthnAuthentication webAuthnAuthentication = new WebAuthnAuthentication(userEntity, authorities);
535+
webAuthnAuthentication.setDetails(details);
536+
return webAuthnAuthentication;
537+
});
518538
}
519539

520540
@ParameterizedTest

web/src/main/java/org/springframework/security/web/webauthn/api/Bytes.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.web.webauthn.api;
1818

19+
import java.io.Serial;
20+
import java.io.Serializable;
1921
import java.security.SecureRandom;
2022
import java.util.Arrays;
2123
import java.util.Base64;
@@ -28,7 +30,10 @@
2830
* @author Rob Winch
2931
* @since 6.4
3032
*/
31-
public final class Bytes {
33+
public final class Bytes implements Serializable {
34+
35+
@Serial
36+
private static final long serialVersionUID = -3278138671365709777L;
3237

3338
private static final SecureRandom RANDOM = new SecureRandom();
3439

web/src/main/java/org/springframework/security/web/webauthn/api/ImmutablePublicKeyCredentialUserEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.web.webauthn.api;
1818

19+
import java.io.Serial;
20+
1921
/**
2022
* <a href=
2123
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity">PublicKeyCredentialUserEntity</a>
@@ -28,6 +30,9 @@
2830
*/
2931
public final class ImmutablePublicKeyCredentialUserEntity implements PublicKeyCredentialUserEntity {
3032

33+
@Serial
34+
private static final long serialVersionUID = -3438693960347279759L;
35+
3136
/**
3237
* When inherited by PublicKeyCredentialUserEntity, it is a human-palatable identifier
3338
* for a user account. It is intended only for display, i.e., aiding the user in

web/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredentialUserEntity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.web.webauthn.api;
1818

19+
import java.io.Serializable;
20+
1921
/**
2022
* <a href=
2123
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity">PublicKeyCredentialUserEntity</a>
@@ -27,7 +29,7 @@
2729
* @since 6.4
2830
* @see org.springframework.security.web.webauthn.management.WebAuthnRelyingPartyOperations#authenticate(org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest)
2931
*/
30-
public interface PublicKeyCredentialUserEntity {
32+
public interface PublicKeyCredentialUserEntity extends Serializable {
3133

3234
/**
3335
* The <a href=

web/src/main/java/org/springframework/security/web/webauthn/authentication/WebAuthnAuthentication.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.security.web.webauthn.authentication;
1818

19+
import java.io.Serial;
1920
import java.util.Collection;
2021

2122
import org.springframework.security.authentication.AbstractAuthenticationToken;
@@ -33,6 +34,9 @@
3334
*/
3435
public class WebAuthnAuthentication extends AbstractAuthenticationToken {
3536

37+
@Serial
38+
private static final long serialVersionUID = -4879907158750659197L;
39+
3640
private final PublicKeyCredentialUserEntity principal;
3741

3842
public WebAuthnAuthentication(PublicKeyCredentialUserEntity principal,

0 commit comments

Comments
 (0)