Skip to content

Instantly share code, notes, and snippets.

@wpf500
Created August 15, 2014 16:04
Show Gist options
  • Save wpf500/ac3b161269107d8e5f60 to your computer and use it in GitHub Desktop.
Save wpf500/ac3b161269107d8e5f60 to your computer and use it in GitHub Desktop.
Conditional CSRFFilter
class CSRFFilterWithExemptions extends EssentialFilter {
val csrfFilter = CSRFFilter()
def apply(next: EssentialAction): EssentialAction = new EssentialAction {
def apply(rh: RequestHeader): Iteratee[Array[Byte], Result] = {
if (/* some test here */) {
csrfFilter(next)(rh)
} else {
next(rh)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment