Class CsrfFilter
java.lang.Object
org.codice.ddf.security.filter.csrf.CsrfFilter
- All Implemented Interfaces:
org.codice.ddf.platform.filter.SecurityFilter
Contains multiple checks to prevent cross-site requests for protected context paths.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, org.codice.ddf.platform.filter.SecurityFilterChain chain) Checks that the origin or referer header of the request matches a system trusted authority when attempting to access certain contexts.voidinit()voidsetWhiteListContexts(List<String> whiteListContexts)
-
Field Details
-
CSRF_HEADER
- See Also:
-
ORIGIN_HEADER
- See Also:
-
REFERER_HEADER
- See Also:
-
-
Constructor Details
-
CsrfFilter
public CsrfFilter(ddf.security.audit.SecurityLogger securityLogger)
-
-
Method Details
-
init
public void init()- Specified by:
initin interfaceorg.codice.ddf.platform.filter.SecurityFilter
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, org.codice.ddf.platform.filter.SecurityFilterChain chain) throws IOException, org.codice.ddf.platform.filter.AuthenticationException Checks that the origin or referer header of the request matches a system trusted authority when attempting to access certain contexts. Also checks for the existence of an anti-CSRF header "X-Requested-With". A 403 is returned and the request is stopped if one or more of these conditions are met: - Neither the Origin nor Referer header is present on the request. - Neither the Origin nor Referer header match a trusted authority. - The "X-Requested-With" header is not present on the request.- Specified by:
doFilterin interfaceorg.codice.ddf.platform.filter.SecurityFilter- Parameters:
request- incoming http requestresponse- response stream for returning the responsechain- chain of filters to be invoked following this filter- Throws:
IOExceptionorg.codice.ddf.platform.filter.AuthenticationException
-
setWhiteListContexts
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.codice.ddf.platform.filter.SecurityFilter
-