playframework禁用CSRF过滤器 [英] playframework disable CSRF filter

查看:113
本文介绍了playframework禁用CSRF过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用Scala编写的播放应用程序.我们希望根据我们的要求完全禁用CSRF过滤器.播放文档上没有给出太多说明( https://www.playframework.com/documentation/2.5.x/JavaCsrf ).任何帮助将不胜感激.

We have a play application written in Scala. We wanted to completely disable CSRF filter based on our requirement. there is no much instruction given on the play document (https://www.playframework.com/documentation/2.5.x/JavaCsrf) . Any help will be appreciated.

推荐答案

如果使用的是编译时依赖项注入,则将忽略过滤器的运行时配置.相反,您需要将代码放入ApplicationLoader:

If you are using compile-time dependency injection, the runtime configuration for filters is ignored. Instead, you need to put code into your ApplicationLoader:

override def httpFilters: Seq[EssentialFilter] = {
  super.httpFilters.filterNot(_.getClass == classOf[CSRFFilter])
}

https://www.playframework.com /documentation/2.6.x/Filters#Compile-Time-Default-Filters

这篇关于playframework禁用CSRF过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆