Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Spring Security OIDC Demo
class Application {
String home( user) {
'Hello ' +
class HomeController {
public String hello(@AuthenticationPrincipal OidcUser user) {
return "Hello, " + user.getFullName();
Copy link

mraible commented Jan 16, 2020

OIDC QuickStart with Spring Security

For app.groovy to work, you'll need to:

  1. Register a Web app on Okta

  2. Set the Login redirect URI to http://localhost:8080/login/oauth2/code/okta

  3. Create an okta.env with the following settings.

  4. Run source okta.env, followed by spring run app.groovy. Navigate to http://localhost:8080 and you'll be prompted to log in. It will only show you the user's unique identifier.

Do More with Java

  1. To get their full name, create a new Spring Boot app with HTTPie and expand the downloaded zip file.

     http dependencies==okta,web javaVersion==11 -d
     unzip -d java-boot
  2. Use the Okta Maven Plugin to create an Okta account and register a Spring Boot app.

     mvn com.okta:okta-maven-plugin:setup
  3. Start your app with ./mvnw spring-boot:run and go to http://localhost:8080. After logging in, your full name will be displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment