【问题标题】:Custom authentication overriding Spring Security自定义身份验证覆盖 Spring Security
【发布时间】:2016-10-31 00:13:56
【问题描述】:

我的 2.5.4 grails 版本应用程序由 Sp​​ring Security 保护并且运行良好。只有在休息服务的回复允许时,我才需要更改它并授予用户访问权限。也就是说,我不想使用请求用户名/密码的spring安全功能,而是想调用一个休息服务(我已经有了),如果这个服务回复用户可以访问应用程序,我想授予访问权限给这个用户。 据我了解,我需要覆盖spring security core的LoginController的auth方法。我还需要 grails 过滤器吗? 你能给我一些关于这个话题的建议吗?

【问题讨论】:

    标签: grails spring-security


    【解决方案1】:

    这适用于我在运行 grails 3.1.9 的 BootStrap.groovy 中。不确定它会帮助你,但它可能是一个起点。

    import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
    import org.springframework.security.core.context.SecurityContextHolder as SCH
    ...
    SCH.context.authentication = new UsernamePasswordAuthenticationToken(admin.username, admin.password, admin.authorities)
    

    【讨论】:

      【解决方案2】:

      您是否查看过spring security rest plugin(grails 2.5.x 的版本 1.5.3)并使用 JWT 传递身份验证?

      【讨论】:

        猜你喜欢
        • 2014-04-20
        • 2014-12-13
        • 2017-07-17
        • 2016-08-05
        • 2020-12-05
        • 2015-04-27
        • 2014-12-08
        • 2014-01-12
        • 2016-09-05
        相关资源
        最近更新 更多