Add Single Sign-On to Your Spring Boot Web App in 15 Minutes

Brian Demers

Hey @disqus_aWUfMRF2X0:disqus,

IIRC the standard http(s).proxy* properties work with Spring Boot. If that doesn’t work let us know!

Nivas Mane-Patil

@mattraible @disqus_u7ZhPHjjDC:disqus I trying all step which you mention above, but still i have same problem. Please give some solution for spring boot 2.0.x
Thank you

Matt Raible

Are you using Spring MVC with Spring Boot 2.0? If so, the above solution with the spring-security-starter and oauth2-autoconfigure works. If you’re using WebFlux, I don’t think Spring Security + OAuth works with it yet.

KiranB

Are you able to get the solution on it

Nivas Mane-Patil

No…@kiranbarhate

Nivas Mane-Patil

Thank you so much for reply @mattraible
I am using spring boot 2.0.1 and spring security…while i am adding above dependency and configuration then getting the " NoSuchMethodError: YamlPropertySourceLoader.load " Error

Matt Raible

Make sure you remove Okta’s Spring Boot Starter. The current version only works with Spring Boot 1.5.x.

Radhe Rajput

I have run into same problem, found that this tutorial only works with Spring Boot 1.5.X.
Step 1 ask you to download demo.zip from https://start.spring.io/, which genrerates the latest and great Spring Boot POM.xml, which is problem.
Just for reference I’m here posting Spring Boot 1.5.9 pom.xml, it may be helpful to others, and need not to spent too much of time googling and debugging the issue.
Just replace the downloaded pom.xml with below. The tutorial will work with charm.

<project xsi:schemalocation=“http://maven.apache.org/POM… http://maven.apache.org/xsd…” xmlns:xsi=“http://www.w3.org/2001/XMLS…” xmlns=“http://maven.apache.org/POM…”>
<modelversion>4.0.0</modelversion>
<groupid>com.example</groupid>
<artifactid>demo</artifactid>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-parent</artifactid>
<version>1.5.9.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-security</artifactid>
</dependency>
<dependency>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-web</artifactid>
</dependency>
<dependency>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-test</artifactid>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.springframework.security</groupid>
<artifactid>spring-security-test</artifactid>
<scope>test</scope>
</dependency>

<dependency>
<groupid>com.okta.spring</groupid>
<artifactid>okta-spring-boot-starter</artifactid>
<version>0.2.0</version>
</dependency>
<dependency>
<groupid>org.springframework.security.oauth</groupid>
<artifactid>spring-security-oauth2</artifactid>
<version>2.2.0.RELEASE</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-maven-plugin</artifactid>
</plugin>
</plugins>
</build>
</project>

SB1208

Hi, I’m getting issuer can’t be empty error

SB1208

can you suggest me any one

Brian Demers

Which version of SpringBoot are you using?

SB1208

2.0.3.RELEASE

Brian Demers

Take a look at this example (which uses Spring Boot 2):
https://github.com/okta/sam…

Sujit Tripathy

I setup for Text auth as part of MFA. For the first time its asked for mobile number setup which I did and MFA working like a charm. My question is, where is the mobile number for MFA gets stored? on the application on the Okta profile or somewhere?

Ram V

Does it work with JDK 1.7

Brian Demers

No, 1.7 is no longer publicly supported: https://java.com/en/downloa…

Brian Demers

It is stored as a new factor associated with the users account. You can list them with the API if that is what you are looking for: https://developer.okta.com/…

Arvind Singh

I am running okta-hosted-login project from https://github.com/okta/sam and getting 400 error.

my login redirect is http://localhost:8080/login in OCTA

https://uploads.disquscdn.c…

Brian Demers

Hey Arvind!
I’m guessing your redirect URI is not configured correctly on the Okta side. Take a look at the “Get Your Okta Credentials” section above. By default Spring uses /login for the callback URL. If you have changed the default port or hostname, you would need to change what is listed above (as http://localhost:8080/login)

Pal

How can I make this work both with SSO and login login.
I mean when UI tries the url /sso/login I want the SSO flow and when I do /login or /admin/login, I want the normal Username/pwd login that hits my server.