Package org.wso2.carbon.ui.filters.csrf
Class CSRFProtector
java.lang.Object
org.wso2.carbon.ui.filters.csrf.CSRFProtector
This class generates a CSRF token for a valid session and protects the request against that token.
This also implements the logic to inject a javascript for the response, to enforce that the generated token is
added as a hidden parameter in every form.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyProtection(javax.servlet.http.HttpServletRequest request, CSRFResponseWrapper responseWrapper) Validates POST requests for CSRF tokenvoidenforceProtection(javax.servlet.http.HttpServletRequest request, CSRFResponseWrapper responseWrapper) Generates and injects CSRF Token in the response as a hidden parameterboolean
-
Constructor Details
-
CSRFProtector
-
-
Method Details
-
skipUrl
-
applyProtection
public void applyProtection(javax.servlet.http.HttpServletRequest request, CSRFResponseWrapper responseWrapper) throws CSRFException Validates POST requests for CSRF token- Parameters:
request- HTTPServerRequest instanceresponseWrapper- HTTPServerletResponseWrapper instance- Throws:
CSRFException- exception is thrown when there is a probable attack
-
enforceProtection
public void enforceProtection(javax.servlet.http.HttpServletRequest request, CSRFResponseWrapper responseWrapper) throws IOException Generates and injects CSRF Token in the response as a hidden parameter- Parameters:
request- HTTPServerRequest instanceresponseWrapper- HTTPServerletResponseWrapper instance- Throws:
IOException
-
getConfig
-