spring-bootoauth-2.0single-sign-onspring-cloudspring-boot-starter-parent

Spring boot SSO with Oauth2 and Spring-boot-starter-parent version 2+


I got a good and simple SSO sample project from here

Currently the sample works as below.

Now my issue is the sample uses spring-boot-starter-parent version 1.5.9.RELEASE

The sample uses spring-cloud dependency also. I read like spring-cloud will not support spring-boot-starter-parent version 2 or above.

So I tried to remove spring cloud dependency from app1 and I could start the application after a tough try. My new pom is as below.

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

<groupId>com.shekhargulati</groupId>
<artifactId>app1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>app1</name>
<description>App1</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security.oauth.boot</groupId>
        <artifactId>spring-security-oauth2-autoconfigure</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        <version>2.1.3.RELEASE</version>
    </dependency>
</dependencies>

Now on loading app1, it will show sso login window. But after successfull login, it will throw 404 error.

And if I do the same changes in sso-server application, the authorization will not work. Authorization API wil lthrow 404.

Please help me to fix this. My need is, make this application work as earlier with spring boot starter parent version 2+.


Solution

  • Here is the link for the code in github which is forked from the link which is provided in the above question which is providing all the feature you have expected using Spring-Boot 2.X version.

    In the above code I have moved your code from Spring boot version 1.5.9.RELEASE to 2.1.3.RELEASE and Spring Cloud version from Edgware.SR1 to Finchley.SR1