├── README.md ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── javatechie │ │ └── spring │ │ └── okta │ │ └── sso │ │ └── SpringBootOktaSsoApplication.java └── resources │ └── application.properties └── test └── java └── com └── javatechie └── spring └── okta └── sso └── SpringBootOktaSsoApplicationTests.java /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-okta-sso 2 | How to Add Single Sign-On to Your Spring Boot Web Application using okta & OAuth 2.0 3 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.1.4.RELEASE 10 | 11 | 12 | com.javatechie 13 | spring-boot-okta-sso 14 | 0.0.1-SNAPSHOT 15 | spring-boot-okta-sso 16 | Enable Single Sign-On to Your Spring Boot Web App 17 | 18 | 19 | 1.8 20 | Greenwich.SR2 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-security 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | com.okta.spring 34 | okta-spring-boot-starter 35 | 0.6.0 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-oauth2 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | org.springframework.security 49 | spring-security-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.cloud 58 | spring-cloud-dependencies 59 | ${spring-cloud.version} 60 | pom 61 | import 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-maven-plugin 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/okta/sso/SpringBootOktaSsoApplication.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.okta.sso; 2 | 3 | import java.security.Principal; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @SpringBootApplication 12 | @RestController 13 | @EnableOAuth2Sso 14 | public class SpringBootOktaSsoApplication { 15 | 16 | @GetMapping("/") 17 | public String welcome2User(Principal principal) { 18 | return "Hi "+principal.getName()+" Welcome to javatechie"; 19 | } 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(SpringBootOktaSsoApplication.class, args); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | okta.oauth2.issuer= https://dev-165093.okta.com/oauth2/default 2 | okta.oauth2.clientId=0oaz16emnjw4TZVZ0356 3 | okta.oauth2.clientSecret=zEeuINnfu36oNGCWTdmnadAjgT-BtbTu79XdFwe0 4 | server.port=9090 5 | spring.main.allow-bean-definition-overriding=true 6 | -------------------------------------------------------------------------------- /src/test/java/com/javatechie/spring/okta/sso/SpringBootOktaSsoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.okta.sso; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootOktaSsoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------