Search code examples
javaspringspring-bootoauth-2.0dependencies

spring-boot-starter-oauth2-resource-server vs spring-cloud-starter-oauth2 which to use?


i just getting started to learning Spring Security with OAuth2 and i want to create Authorization Server and Resource Server for my microservice Restful Api. But i am confuse which dependency to start with, since i found some of them. i use spring boot 2.4.1 version. here i list it below :

This one i found it at spring initializer page, when i try to add OAuth2 library, is this one the latest version?

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-oauth2-resource-server -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>

below this one i found it at some tutorial, which is i think this one is already deprecated right?

<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-oauth2 -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-oauth2</artifactId>
    <version>2.2.4.RELEASE</version>
</dependency>

And last one, is this one below, since i don't see there is an updated version anymore, is this one deprecated too?

<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
<dependency>
    <groupId>org.springframework.security.oauth</groupId>
    <artifactId>spring-security-oauth2</artifactId>
    <version>2.5.0.RELEASE</version>
</dependency>

which one should i use?


Solution

  • Spring Boot 2.4.x uses Spring Security 5.4.x, which sadly removed its support for authorization servers.

    There's a new project, spring-authorization-sever, aimed at bringing it back in the future, but currently it's only at version 0.0.3.

    If you need it for your project, I'd recommend using spring boot 2.3.x instead.