Code Monkey home page Code Monkey logo

okta-play-oidc-example's Introduction

OIDC Authentication with Play, Pac4j, and Okta

This okta-play-oidc-example project is a Java Play Framework app that shows how to use the play-pac4j-java security library with OpenID Connect (OIDC) and Okta.

Prerequisites:

Create an OIDC App in Okta

Create an OIDC App in Okta to get a {clientId} and {clientSecret}. To do this, log in to your Okta Developer account and navigate to Applications > Add Application. Click Web and click the Next button. Give the app a name you’ll remember, specify http://localhost:9000 as a Base URI, as well as the following values:

  • Login redirect URIs: http://localhost:9000/callback?client_name=OidcClient
  • Logout redirect URIs: http://localhost:9000/?forcepostlogouturlafteridp

Click Done and copy the client ID and secret into your conf/application.conf file. While you're in there, modify the oidc.discoveryUri to match your Okta domain. For example:

oidc.discoveryUri = "https://{yourOktaDomain}.com/oauth2/default/.well-known/openid-configuration"

You can also create groups and include them as claims. For example, create ROLE_ADMIN and ROLE_USER groups and add users into them.

Navigate to API > Authorization Servers, click the Authorization Servers tab and edit the default one. Click the Claims tab and Add Claim. Name it "groups" or "roles", and include it in the ID Token. Set the value type to "Groups" and set the filter to be a Regex of .*.

After making these changes, you should be good to go!

Build and Run

Build the project and launch the Play app on http://localhost:9000:

sbt run

If you have any issues, please create an issue in this project and I'll do my best to help.

okta-play-oidc-example's People

Contributors

mraible avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

okta-play-oidc-example's Issues

Central Logout Not Working

I get the following:

Error Code: illegal_post_logout_redirect_uri
Description: The 'post_logout_redirect_uri' parameter must be an absolute URI that is whitelisted in the client app settings.

404s on index and logout routes

It seems like localhost:9000 should route to / and that should serve a page with a link to the protected page, however this returns a 404.

Also, the /logout route returns a 404. Is this expected or is this a bug? How can I verify that the security configuration class (SecurityModule) is working?

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.