Skip to content

Commit 421fcae

Browse files
franticticktickrwinch
authored andcommitted
Add Assertions To WebAuthnConfigurer
Signed-off-by: Max Batischev <[email protected]>
1 parent 184cd96 commit 421fcae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configurers/WebAuthnConfigurer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.security.web.webauthn.registration.PublicKeyCredentialCreationOptionsFilter;
4747
import org.springframework.security.web.webauthn.registration.PublicKeyCredentialCreationOptionsRepository;
4848
import org.springframework.security.web.webauthn.registration.WebAuthnRegistrationFilter;
49+
import org.springframework.util.Assert;
4950

5051
/**
5152
* Configures WebAuthn for Spring Security applications
@@ -75,6 +76,7 @@ public class WebAuthnConfigurer<H extends HttpSecurityBuilder<H>>
7576
* @return the {@link WebAuthnConfigurer} for further customization
7677
*/
7778
public WebAuthnConfigurer<H> rpId(String rpId) {
79+
Assert.hasText(rpId, "rpId be null or empty");
7880
this.rpId = rpId;
7981
return this;
8082
}
@@ -85,6 +87,7 @@ public WebAuthnConfigurer<H> rpId(String rpId) {
8587
* @return the {@link WebAuthnConfigurer} for further customization
8688
*/
8789
public WebAuthnConfigurer<H> rpName(String rpName) {
90+
Assert.hasText(rpName, "rpName can't be null or empty");
8891
this.rpName = rpName;
8992
return this;
9093
}
@@ -106,6 +109,7 @@ public WebAuthnConfigurer<H> allowedOrigins(String... allowedOrigins) {
106109
* @see #allowedOrigins(String...)
107110
*/
108111
public WebAuthnConfigurer<H> allowedOrigins(Set<String> allowedOrigins) {
112+
Assert.notNull(allowedOrigins, "allowedOrigins can't be null");
109113
this.allowedOrigins = allowedOrigins;
110114
return this;
111115
}
@@ -129,6 +133,7 @@ public WebAuthnConfigurer<H> disableDefaultRegistrationPage(boolean disable) {
129133
* @return the {@link WebAuthnConfigurer} for further customization
130134
*/
131135
public WebAuthnConfigurer<H> messageConverter(HttpMessageConverter<Object> converter) {
136+
Assert.notNull(converter, "converter can't be null");
132137
this.converter = converter;
133138
return this;
134139
}
@@ -140,6 +145,7 @@ public WebAuthnConfigurer<H> messageConverter(HttpMessageConverter<Object> conve
140145
*/
141146
public WebAuthnConfigurer<H> creationOptionsRepository(
142147
PublicKeyCredentialCreationOptionsRepository creationOptionsRepository) {
148+
Assert.notNull(creationOptionsRepository, "creationOptionsRepository can't be null");
143149
this.creationOptionsRepository = creationOptionsRepository;
144150
return this;
145151
}

0 commit comments

Comments
 (0)