React App 对 Spring 启动 thymeleaf 应用程序的唯一身份验证

Posted

技术标签:

【中文标题】React App 对 Spring 启动 thymeleaf 应用程序的唯一身份验证【英文标题】:Unique Authentication for React App to Spring boot thymeleaf app 【发布时间】:2017-06-02 00:23:08 【问题描述】:

我们有两个网络应用程序 1. 用 react.js 编写,它的后端 API 使用 spring boot + spring security 编写。 2.另一个使用spring boot + spring security编写的web应用 + thymeleaf 模板。

我们称为 react 应用和 thymleaf 应用的应用程序。

我希望将经过身份验证的用户从 React 应用重定向到 thymleaf 应用,但是通过使用相同的身份验证令牌,反应应用当前在每个请求的标头中传递身份验证令牌。

如何将相同的身份验证令牌从 React 应用程序传递给 thymleaf 应用程序,这种集成将如何无缝进行。

在 thymlead 应用程序中,有以下代码请求端点

@RequestMapping("/select/test/method")
    public String selectDepositMethod(Model model, Authentication authentication) 
        model.addAttribute("name", "Select test method");

        return "deposit/select-test-method";
    

想要从 react 应用重定向到 thymleaf 应用到上述端点。

我们需要对 react 应用或 thymeleaf 应用进行哪些​​更改。

您能否向我们提出适当的更改建议,感谢您的帮助。

【问题讨论】:

【参考方案1】:

推荐您查看 Spring Session。见这篇文章:

https://drissamri.be/blog/2015/05/21/spring-security-and-spring-session/

【讨论】:

以上是关于React App 对 Spring 启动 thymeleaf 应用程序的唯一身份验证的主要内容,如果未能解决你的问题,请参考以下文章