-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Describe the bug
The issue is a Java null pointer exception resulted from checking for OpenSAML version within the SAML2 login configurer when used with Java Modules rather than Classpath.
Exception:
Caused by: java.lang.NullPointerException: null
at spring.security.config@5.5.1/org.springframework.security.config.annotation.web.configurers.saml2.Saml2LoginConfigurer$AuthenticationRequestEndpointConfig.getResolver(Saml2LoginConfigurer.java:349) ~[spring-security-config-5.5.1.jar:na]
at spring.security.config@5.5.1/org.springframework.security.config.annotation.web.configurers.saml2.Saml2LoginConfigurer$AuthenticationRequestEndpointConfig.build(Saml2LoginConfigurer.java:340) ~[spring-security-config-5.5.1.jar:na]
at
This is due to the code that doesn't check if the nullable Version class is null:
Lines 346 to 355 in bff3779
private Saml2AuthenticationRequestFactory getResolver(B http) { | |
Saml2AuthenticationRequestFactory resolver = getSharedOrBean(http, Saml2AuthenticationRequestFactory.class); | |
if (resolver == null) { | |
if (Version.getVersion().startsWith("4")) { | |
return new OpenSaml4AuthenticationRequestFactory(); | |
} | |
return new OpenSamlAuthenticationRequestFactory(); | |
} | |
return resolver; | |
} |
This was introduced by this issue: #9095
To Reproduce
Simply import saml2 provider: (with spring-boot version: 2.5.2)
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-saml2-service-provider</artifactId>
</dependency
And build with maven without module-info.java
file, which means it will be using the classpath instead. This will work, however migrating to module will make the Version of Opensaml completely null resulting in the above exception.
Expected behavior
Check for null Version class as it is allowed to be nullable org.opensaml.core.Version
.