Playframework with CSRF : “CSRF token not found in session”?

后端 未结 2 1415
無奈伤痛
無奈伤痛 2021-02-15 18:36

I\'m making a simple authentication system using Playframework with their built-in CSRF filter and Security.Authenticator system, but I\'m facing a problem :

When the us

相关标签:
2条回答
  • 2021-02-15 19:22

    Add the below line in Global.java

    @Override
    public <T extends EssentialFilter> Class<T>[] filters() {
        return new Class[]{CSRFFilter.class};
    }
    

    For this you have to import

    import play.api.mvc.EssentialFilter;
    import play.filters.csrf.CSRFFilter;
    

    Hope this will help you

    0 讨论(0)
  • 2021-02-15 19:27

    Finally the problem was located in an other part of my code that was cleaning the session in the login() method, removing the csrf token with it ...

    0 讨论(0)
提交回复
热议问题