Git Product home page Git Product logo

okta-spring-boot-sso's Introduction

Overview

This project demonstrates securing spring-boot application with okta SSO (Single Sign On).

Prerequisites

  1. Need to have account on okta. How to create account on okta?
  2. Register our spring-boot-app on okta. - Make sure to config login redirect URI to http://localhost:8080/login/oauth2/code/okta in okta, at Login redirect URIs.

Implementation guideline.

  1. Make sure you have all the dependencies from pom.xml
  2. Add @EnableOAuth2Client on main class, OktaSSOApplication.class
  3. Fetch required user profile from okta, and create a custom user object to return. This is implemented in UserServiceImpl.class

How to logout?

We need to logout from two contexts.

  1. Spring security context.
  2. Okta context.
  • To logout from spring-security context add WebSecurityConfig.class from config package. - source
  • To logout from okta context, add okta.oauth2.postLogoutRedirectUri=http://localhost:8080/login/oauth2/code/okta property in app config. (Make sure to configure, the same redirect URI on okta at Logout redirect URIs)
  • After adding the above steps, hit /logout end point directly, this doesn't need any extra config.

For story lovers
This is a special scenario, cause okta SDK will not provide any functionality to logout for now. Ideally, just hitting /logout end point will logout the session by spring security (but okta session is still mantained).

But I faced issue here, spring-security displays successful logout page, but actually it doesn't logout and still maintains session. This can be tested by removing okta.oauth2.post-logout-redirect-uri=http://localhost:8080/ property from application config, and hitting /logout end point.

okta-spring-boot-sso's People

Contributors

snigdhesh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.