Skip to content

Instantly share code, notes, and snippets.

@guillaumebort
Created June 6, 2013 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillaumebort/5720192 to your computer and use it in GitHub Desktop.
Save guillaumebort/5720192 to your computer and use it in GitHub Desktop.
request.headers.get(CONTENT_TYPE) match {
case Some(ct) if ct.trim.startsWith("multipart/form-data") =>
filterLogger.trace("[CSRF] request is multipart/form-data")
checkMultipart(request, token, next)
case Some(ct) if ct.trim.startsWith("application/x-www-form-urlencoded") =>
filterLogger.trace("[CSRF] request is application/x-www-form-urlencoded")
checkFormUrlEncodedBody(request, token, next)
case Some(ct) if ct.trim.startsWith("text/plain") =>
filterLogger.trace("[CSRF] request is text/playn")
checkTextBody(request, token, next)
case None if request.method == "GET" =>
filterLogger.trace("[CSRF] GET request, adding the token")
next(addRequestToken(request, token)).map(result => addResponseToken(request, result, token))(defaultContext)
case ct =>
filterLogger.trace("[CSRF] bypass the request (%s)".format(ct.toString))
next(request)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment