6

Spring Security OAuth正式终止维护,已从官网下架

 2 years ago
source link: https://www.cnblogs.com/felordcn/p/16338457.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Spring Security团队正式宣布Spring Security OAuth终止维护。

1739473-20220602171201925-760523367.png

目前官网的主页已经高亮提醒彻底停止维护。

1739473-20220602171202314-543347803.png

旧的Spring Security OAuth项目终止到2.5.2.RELEASE版本,该项目将不会再进行任何的迭代,包括Bug修复,之前胖哥已经提醒该项目即将停止维护,有心的同学已经进行了迁移。

2020年就已经宣布了EOL时间表

项目文档和代码仓库被移除

目前该项目的官方文档已经正式从spring.io移除,文档已经指向404,这是连文档也没有了。新增了OAuth2授权服务器Spring Authorization Server的文档。

1739473-20220602171202936-632922142.png

不仅仅文档被移除,连项目的仓库也被迁移到Spring的过期项目仓库spring-attic并被标记为read-only

Spring Security OAuth仓库已经迁移

Spring Security OAuthSpring Boot自动配置代码仓库也一并被迁移,也就是说Spring Boot相关的自动配置也被移除。

Spring Security OAuth2 Boot仓库被迁移

从这种情况看来大约Spring Security OAuth的确是死了。难道就没有可用的了吗?当然不是。

这是胖哥总结的迁移指南。

依赖项检查

那么如何检查你的项目是否用了旧的OAuth2设施呢?当然是对依赖进行检查。以下清单中的依赖任何版本的都是过期的,都需要迁移:

        <dependency>		
                <groupId>org.springframework.security.oauth</groupId>
                <artifactId>spring-security-oauth-parent</artifactId>
        </dependency>
        <dependency>		
                <groupId>org.springframework.security.oauth</groupId>
                <artifactId>spring-security-oauth</artifactId>
        </dependency>
        <dependency>		
                <groupId>org.springframework.security.oauth</groupId>
                <artifactId>spring-security-oauth2</artifactId>
        </dependency>
        <dependency>
		 	<groupId>org.springframework.security</groupId>
	        <artifactId>spring-security-jwt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth.boot</groupId>
            <artifactId>spring-security-oauth2-autoconfigure</artifactId>
        </dependency>

你可以通过mvn dependency:tree来检查依赖树是否集成了上述依赖项。

新的OAuth2替代方案

需要开发者掌握OAuth2.0OAuth2.1OIDC 1.0的一些知识。

Spring Security 5中集成了OAuth2 ClientResource Server两个模块。如果有迁移的需要,建议迁移至最新的Spring Security 5.7.x,方便向Spring 6过渡。以Spring Boot为例,首先要集成Spring Security

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

这里建议使用最新版本,目前是2.7。

集成OAuth2 Client依赖

OAuth2 Client依赖于Spring Security,不能单独使用:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>

集成Resource Server依赖

Resource Server同样也依赖于Spring Security,不能单独使用:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
        </dependency>

集成OAuth2授权服务器依赖

目前Spring生态中的OAuth2授权服务器是Spring Authorization Server,目前已具备生产就绪能力。在最新的0.3.0版本中,官方文档正式在spring.io上线,需要你知道的是它必须在Java 11及以上版本才能使用。它也作为一个Spring Security子模块,不能单独使用:

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-authorization-server</artifactId>
            <version>0.3.0</version>
        </dependency>

透露一下,该项目的Spring Boot Starter也将在不久实装。

胖哥近几个月一直在对新的OAuth2相关的进行系统化总结。因此你只要关注胖哥,总能获得相关的知识和实战干货分享。当然这里胖哥也给出了一些参考的文献:

项目参考代码DEMO:

旧的Spring Security OAuth过期,其实也不必恐慌,除非你们在这一方面的架构需要继续迭代。不过随着新的方案面世,旧方案的可维护性会大大降低,有条件的还是要迁移一下的。Spring Cloud也将会在未来某个时间点做出一些调整以适应新的架构。请持续关注,后面会及时带来相关的消息。

关注公众号:Felordcn 获取更多资讯

个人博客:https://felord.cn


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK