Skip to content

oktadev/okta-spring-security-authentication-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Authentication with Spring Security

This example code is used in the blog post found here

This example takes you from using Spring Security for basic authentication, to form authentication and finally to integrating with Okta using OAuth 2.0.

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.

Run

In the first two examples, you can simply switch into the basic-auth and form-auth folders respectively and run:

./gradlew bootRun

For the final example, switch into the oauth-okta folder.

You'll need to create an Okta org here.

Follow the instructions in the blog post for creating an application in Okta.

Setup src/main/resources/application.yml like so:

okta:  
  oauth2:  
    issuer: https://okta.okta.com/oauth2/default  
    client-id: {yourClientID}
    client-secret: {yourClientSecret} 
spring:  
  thymeleaf:  
    cache: false

Then, you can run the app as before:

./gradlew bootRun

Additional Resources

If you'd like to learn more about Spring Boot, Spring Security, or secure authentication, check out any of these great tutorials:

If you want to dive deeper, take a look at the Okta Spring Boot Starter GitHub page.

If you have any questions about this post, please add a comment below. For more awesome content, follow @oktadev on Twitter, like us on Facebook, or subscribe to our YouTube channel.