From 421fcaee12ef287eea9cf01b4ab89825c666cad0 Mon Sep 17 00:00:00 2001 From: Max Batischev Date: Sun, 27 Apr 2025 18:16:17 +0300 Subject: [PATCH] Add Assertions To WebAuthnConfigurer Signed-off-by: Max Batischev --- .../annotation/web/configurers/WebAuthnConfigurer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/WebAuthnConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/WebAuthnConfigurer.java index 104a0be328..fba5f016fa 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/WebAuthnConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/WebAuthnConfigurer.java @@ -46,6 +46,7 @@ import org.springframework.security.web.webauthn.registration.DefaultWebAuthnReg import org.springframework.security.web.webauthn.registration.PublicKeyCredentialCreationOptionsFilter; import org.springframework.security.web.webauthn.registration.PublicKeyCredentialCreationOptionsRepository; import org.springframework.security.web.webauthn.registration.WebAuthnRegistrationFilter; +import org.springframework.util.Assert; /** * Configures WebAuthn for Spring Security applications @@ -75,6 +76,7 @@ public class WebAuthnConfigurer> * @return the {@link WebAuthnConfigurer} for further customization */ public WebAuthnConfigurer rpId(String rpId) { + Assert.hasText(rpId, "rpId be null or empty"); this.rpId = rpId; return this; } @@ -85,6 +87,7 @@ public class WebAuthnConfigurer> * @return the {@link WebAuthnConfigurer} for further customization */ public WebAuthnConfigurer rpName(String rpName) { + Assert.hasText(rpName, "rpName can't be null or empty"); this.rpName = rpName; return this; } @@ -106,6 +109,7 @@ public class WebAuthnConfigurer> * @see #allowedOrigins(String...) */ public WebAuthnConfigurer allowedOrigins(Set allowedOrigins) { + Assert.notNull(allowedOrigins, "allowedOrigins can't be null"); this.allowedOrigins = allowedOrigins; return this; } @@ -129,6 +133,7 @@ public class WebAuthnConfigurer> * @return the {@link WebAuthnConfigurer} for further customization */ public WebAuthnConfigurer messageConverter(HttpMessageConverter converter) { + Assert.notNull(converter, "converter can't be null"); this.converter = converter; return this; } @@ -140,6 +145,7 @@ public class WebAuthnConfigurer> */ public WebAuthnConfigurer creationOptionsRepository( PublicKeyCredentialCreationOptionsRepository creationOptionsRepository) { + Assert.notNull(creationOptionsRepository, "creationOptionsRepository can't be null"); this.creationOptionsRepository = creationOptionsRepository; return this; }