Coder Social home page Coder Social logo

theassyrian / okta-spring-boot-saml-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oktadev/okta-spring-boot-saml-example

0.0 1.0 0.0 1.12 MB

Spring Boot, SAML, and Okta

Home Page: http://developer.okta.com/blog/2017/03/16/spring-boot-saml

License: Apache License 2.0

Java 95.99% HTML 4.01%

okta-spring-boot-saml-example's Introduction

Spring Boot, SAML, and Okta

A Spring Boot example app that shows how to implement single sign-on (SSO) with Spring Security's SAML DSL and Okta.

Please read Get Started with Spring Boot, SAML, and Okta to see how this app was created.

Prerequisites: Java 8.

Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.

Getting Started

To install this example application, run the following commands:

git clone https://github.com/oktadeveloper/okta-spring-boot-saml-example.git
cd okta-spring-boot-saml-example

This will get a copy of the project installed locally. To install all of its dependencies and start the app, run:

./mvnw spring-boot:run

Create a SAML App in Okta

The first thing you'll need to do is create a developer account at https://developer.okta.com. After activating your account, log in to it. If you just created an account, you'll see a screen similar to the one below.

Okta Dev Console

Click on < > Developer Console in the top-left corner and switch to the Classic UI. If you see a screen like the following, you're good to go! The reason you need to use the Classic UI for this tutorial is because we haven't yet added SAML support to the Developer Console.

Okta Classic UI

Click Add Applications in the top right to continue. This will bring you to a screen with a Create New App green button on the left.

Create New App

Click the button and choose Web for the platform and SAML 2.0 for the sign on method.

New App with SAML 2.0

Click the Create button. The next screen will prompt you for an application name. I used "Spring SAML”, but any name will work.

Enter App name

Click the Next button. This brings you to the second step, configuring SAML. Enter the following values:

  • Single sign on URL: https://localhost:8443/saml/SSO
  • Audience URI: https://localhost:8443/saml/metadata

SAML Integration

Scroll to the bottom of the form and click Next. This will bring you to the third step, feedback. Choose "I'm an Okta customer adding an internal app” and optionally select the App type.

Customer or Partner

Click the Finish button to continue. This will bring you to the application's "Sign On” tab which has a section with a link to your applications metadata in a yellow box. Copy the Identity Provider metadata link as you'll need it to configure your Spring Boot application.

SAML Metadata

The final setup step you'll need is to assign people to the application. Click on the Assignments tab and the Assign > Assign to People button. You'll see a list of people with your account in it.

Assign People

Click the Assign button, accept the default username (your email), and click the Done button.

Update src/main/resources/application.properties, to have the metadata-url for the app you just created. Make sure to use the "Identity Provider metadata" value you copied earlier (hint: you can find it again under the "Sign On” tab in your Okta application).

server.port = 8443
server.ssl.enabled = true
server.ssl.key-alias = spring
server.ssl.key-store = classpath:saml/keystore.jks
server.ssl.key-store-password = secret

security.saml2.metadata-url = <your metadata url>

Run the App and Login with Okta

Start the app using your IDE or mvn spring-boot:run and navigate to https://localhost:8443. If you're using Chrome, you'll likely see a privacy error.

Connection Not Private

Click the "ADVANCED" link at the bottom. Then click the "proceed to localhost (unsafe)” link.

Proceed to localhost

Next, you'll be redirected to Okta to sign in and redirected back to your app. If you're already logged in, you won't see anything from Okta. If you sign out from Okta, you'll see a login screen such as the one below.

Okta Login

After you've logged in, you should see a screen like the one below.

Hello SAML

Links

This example uses Spring Security SAML DSL to integrate with Okta. Kudos to the project's spring-security-saml-dsl-sample for its instructions.

Help

Please post any questions as comments on the blog post, or visit our Okta Developer Forums. You can also email [email protected] if would like to create a support ticket.

License

Apache 2.0, see LICENSE.

okta-spring-boot-saml-example's People

Contributors

mraible avatar johngronberg-okta avatar

Watchers

The Assyrian 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.