Skip to content
Snippets Groups Projects
Verified Commit 9d3d1a47 authored by Ewoud Ruighaver's avatar Ewoud Ruighaver :octopus:
Browse files

Fixes a bug where a request without an origin header would result in an NPE

parent 23cd6848
No related branches found
No related tags found
2 merge requests!148Release 2.3.0,!138CorsPatchFilter NPE
Pipeline #221980 passed
......@@ -10,6 +10,7 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import org.springframework.web.filter.GenericFilterBean;
import javax.annotation.Nullable;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
......@@ -187,10 +188,12 @@ public class CorsPatchFilter extends GenericFilterBean {
* @return {@code true} if the headers may need patching, {@code false} otherwise
*/
private boolean requiresHeaderPatchCheck(
final HttpServletRequest req, final String origin
final HttpServletRequest req, final @Nullable String origin
) {
final var allowedOrigins = this.settings.get("allowed API origins", List.class);
return allowedOrigins.contains(origin) && req.getRequestURI().startsWith("/api");
return origin != null
&& allowedOrigins.contains(origin)
&& req.getRequestURI().startsWith("/api");
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment