Skip to content

Fix PublicKeyCredentialType.PUBLIC_KEY comparison with Spring Session #17223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* <a href="https://www.w3.org/TR/webauthn-3/#webauthn-relying-party">WebAuthn Relying
* Parties</a> may use <a href=
Expand All @@ -26,7 +29,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class AttestationConveyancePreference {
public final class AttestationConveyancePreference implements Serializable {

@Serial
private static final long serialVersionUID = -746545182023303673L;

/**
* The <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import java.io.Serializable;

/**
* A <a href="https://www.w3.org/TR/webauthn-3/#client-extension-input">client extension
* input</a> entry in the {@link AuthenticationExtensionsClientInputs}.
Expand All @@ -25,7 +27,7 @@
* @since 6.4
* @see ImmutableAuthenticationExtensionsClientInput
*/
public interface AuthenticationExtensionsClientInput<T> {
public interface AuthenticationExtensionsClientInput<T> extends Serializable {

/**
* Gets the <a href="https://www.w3.org/TR/webauthn-3/#extension-identifier">extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import java.io.Serializable;
import java.util.List;

/**
Expand All @@ -31,7 +32,7 @@
* @since 6.4
* @see PublicKeyCredentialCreationOptions#getExtensions()
*/
public interface AuthenticationExtensionsClientInputs {
public interface AuthenticationExtensionsClientInputs extends Serializable {

/**
* Gets all of the {@link AuthenticationExtensionsClientInput}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* <a href=
* "https://www.w3.org/TR/webauthn-3/#dictdef-authenticatorselectioncriteria">AuthenticatorAttachment</a>
Expand All @@ -31,7 +34,10 @@
* @since 6.4
* @see PublicKeyCredentialCreationOptions#getAuthenticatorSelection()
*/
public final class AuthenticatorSelectionCriteria {
public final class AuthenticatorSelectionCriteria implements Serializable {

@Serial
private static final long serialVersionUID = 6295924992300524641L;

private final AuthenticatorAttachment authenticatorAttachment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import java.io.Serial;
import java.io.Serializable;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Base64;
Expand All @@ -28,7 +30,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class Bytes {
public final class Bytes implements Serializable {

@Serial
private static final long serialVersionUID = -3278138671365709777L;

private static final SecureRandom RANDOM = new SecureRandom();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* <a href=
* "https://www.w3.org/TR/webauthn-3/#sctn-alg-identifier">COSEAlgorithmIdentifier</a> is
Expand All @@ -25,7 +28,10 @@
* @since 6.4
* @see PublicKeyCredentialParameters#getAlg()
*/
public final class COSEAlgorithmIdentifier {
public final class COSEAlgorithmIdentifier implements Serializable {

@Serial
private static final long serialVersionUID = -7174114312834239069L;

public static final COSEAlgorithmIdentifier EdDSA = new COSEAlgorithmIdentifier(-8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* Implements <a href=
* "https://fidoalliance.org/specs/fido-v2.2-rd-20230321/fido-client-to-authenticator-protocol-v2.2-rd-20230321.html#sctn-credProtect-extension">
Expand All @@ -27,6 +30,9 @@
public class CredProtectAuthenticationExtensionsClientInput
implements AuthenticationExtensionsClientInput<CredProtectAuthenticationExtensionsClientInput.CredProtect> {

@Serial
private static final long serialVersionUID = -6418175591005843455L;

private final CredProtect input;

public CredProtectAuthenticationExtensionsClientInput(CredProtect input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import java.io.Serial;

/**
* An immutable {@link AuthenticationExtensionsClientInput}.
*
Expand All @@ -26,6 +28,9 @@
*/
public class ImmutableAuthenticationExtensionsClientInput<T> implements AuthenticationExtensionsClientInput<T> {

@Serial
private static final long serialVersionUID = -1738152485672656808L;

/**
* https://www.w3.org/TR/webauthn-3/#sctn-authenticator-credential-properties-extension
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import java.io.Serial;
import java.util.Arrays;
import java.util.List;

Expand All @@ -27,6 +28,9 @@
*/
public class ImmutableAuthenticationExtensionsClientInputs implements AuthenticationExtensionsClientInputs {

@Serial
private static final long serialVersionUID = 4277817521578485720L;

private final List<AuthenticationExtensionsClientInput> inputs;

public ImmutableAuthenticationExtensionsClientInputs(List<AuthenticationExtensionsClientInput> inputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import java.io.Serial;

/**
* <a href=
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity">PublicKeyCredentialUserEntity</a>
Expand All @@ -28,6 +30,9 @@
*/
public final class ImmutablePublicKeyCredentialUserEntity implements PublicKeyCredentialUserEntity {

@Serial
private static final long serialVersionUID = -3438693960347279759L;

/**
* When inherited by PublicKeyCredentialUserEntity, it is a human-palatable identifier
* for a user account. It is intended only for display, i.e., aiding the user in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import java.io.Serial;
import java.io.Serializable;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -32,7 +34,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class PublicKeyCredentialCreationOptions {
public final class PublicKeyCredentialCreationOptions implements Serializable {

@Serial
private static final long serialVersionUID = -8805501645775760774L;

private final PublicKeyCredentialRpEntity rp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import java.io.Serial;
import java.io.Serializable;
import java.util.Set;

/**
Expand All @@ -29,7 +31,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class PublicKeyCredentialDescriptor {
public final class PublicKeyCredentialDescriptor implements Serializable {

@Serial
private static final long serialVersionUID = 8793385059692676240L;

private final PublicKeyCredentialType type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* The <a href=
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialparameters">PublicKeyCredentialParameters</a>
Expand All @@ -25,7 +28,10 @@
* @since 6.4
* @see PublicKeyCredentialCreationOptions#getPubKeyCredParams()
*/
public final class PublicKeyCredentialParameters {
public final class PublicKeyCredentialParameters implements Serializable {

@Serial
private static final long serialVersionUID = 8471974877710173696L;

public static final PublicKeyCredentialParameters EdDSA = new PublicKeyCredentialParameters(
COSEAlgorithmIdentifier.EdDSA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* The <a href=
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialrpentity">PublicKeyCredentialRpEntity</a>
Expand All @@ -25,7 +28,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class PublicKeyCredentialRpEntity {
public final class PublicKeyCredentialRpEntity implements Serializable {

@Serial
private static final long serialVersionUID = -5219081524858472915L;

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* The <a href=
* "https://www.w3.org/TR/webauthn-3/#enum-credentialType">PublicKeyCredentialType</a>
Expand All @@ -24,7 +27,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class PublicKeyCredentialType {
public final class PublicKeyCredentialType implements Serializable {

@Serial
private static final long serialVersionUID = 7025333122210061679L;

/**
* The only credential type that currently exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest;
import org.springframework.security.web.webauthn.management.WebAuthnRelyingPartyOperations;

import java.io.Serializable;

/**
* <a href=
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity">PublicKeyCredentialUserEntity</a>
Expand All @@ -30,7 +32,7 @@
* @since 6.4
* @see WebAuthnRelyingPartyOperations#authenticate(RelyingPartyAuthenticationRequest)
*/
public interface PublicKeyCredentialUserEntity {
public interface PublicKeyCredentialUserEntity extends Serializable {

/**
* The <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* The <a href=
* "https://www.w3.org/TR/webauthn-3/#enumdef-residentkeyrequirement">ResidentKeyRequirement</a>
Expand All @@ -24,7 +27,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class ResidentKeyRequirement {
public final class ResidentKeyRequirement implements Serializable {

@Serial
private static final long serialVersionUID = 2047716518193458797L;

/**
* The <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

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

import java.io.Serial;
import java.io.Serializable;

/**
* <a href=
* "https://www.w3.org/TR/webauthn-3/#enumdef-userverificationrequirement">UserVerificationRequirement</a>
Expand All @@ -24,7 +27,10 @@
* @author Rob Winch
* @since 6.4
*/
public final class UserVerificationRequirement {
public final class UserVerificationRequirement implements Serializable {

@Serial
private static final long serialVersionUID = -2801001231345540040L;

/**
* The <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.security.web.webauthn.jackson;

import java.io.IOException;
import java.io.Serial;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
Expand All @@ -33,6 +34,9 @@
*/
class AuthenticationExtensionsClientInputsSerializer extends StdSerializer<AuthenticationExtensionsClientInputs> {

@Serial
private static final long serialVersionUID = -5579815774497047153L;

/**
* Creates a new instance.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private List<com.webauthn4j.data.PublicKeyCredentialParameters> convertCredentia

private com.webauthn4j.data.PublicKeyCredentialParameters convertParamToWebauthn4j(
PublicKeyCredentialParameters parameter) {
if (parameter.getType() != PublicKeyCredentialType.PUBLIC_KEY) {
if (!PublicKeyCredentialType.PUBLIC_KEY.getValue().equals(parameter.getType().getValue())) {
throw new IllegalArgumentException(
"Cannot convert unknown credential type " + parameter.getType() + " to webauthn4j");
}
Expand Down
Loading