来个另类的, 让 Spring Web 应用使用 ASP.NET Core Identity 的数据库进行用户认证

2021-03-26 12:47:48 +08:00
 beginor

最近开始接触 Java 的 Spring 全家桶, 感觉 Spring 在安全认证方面做的比较松散, 不如 ASP.NET Core Identity 来的严谨和完善。

认真学习 Spring Security 和 Apache Shiro 这两个常用的认证类库之后, 发现它们居然可以无缝对接到 ASP.NET Core Identity 的数据库, 甚至使用同样的用户信息进行认证。

有兴趣的可以看看 https://beginor.github.io/2021/03/26/using-aspnet-core-identity-database-with-spring.html

也可以直接浏览源代码 https://github.com/beginor/spring-identity-demo

1671 次点击
所在节点    程序员
6 条回复
xuanbg
2021-03-26 13:06:07 +08:00
Spring Security 和 Apache Shiro 这两个一点都不好用
beginor
2021-03-26 13:39:01 +08:00
@xuanbg 那么请问 Spring 应用的话用什么做认证更好用呢?
zoharSoul
2021-03-26 13:44:57 +08:00
@beginor 写个拦截器验证下 token 完事
hantsy
2021-03-26 13:49:08 +08:00
用同样的数据库?真奇葩啊。

你完全可以用 .Net Identity Server 作为安全方案 。
hantsy
2021-03-26 13:52:03 +08:00
Identity Server 符合 Oauth2,OIDC 标准,与 Spring Secuirty 集成,几行配置就完成了。
https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/identity-server
beginor
2021-03-26 16:47:20 +08:00
@zoharSoul @hantsy 不是一个层面上的问题, 我要实现的是一套用户表, 同时给 .net 和 java 使用

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/765362

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX