Skip to content

oktadev/okta-spring-boot-mysql-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot and MySQL to go Beyond Authentication

You can find the blog post that this source code backs here

This example leverages the information found in the OidcUser object that is automatically injected after authenticating using OpenId Connect.

It uses JPA to add user activity information to a MySQL database.

Build

In order to use this example, you'll need to create an Okta Org here

You'll also need to create an application.properties file in src/main/resources:

okta.oauth2.issuer={authServerUrl}
okta.oauth2.clientId={clientId}
okta.oauth2.clientSecret={clientSecret}

## MySQL
spring.datasource.url=jdbc:mysql://{mysql url}:{mysql port}/{dbName}

spring.datasource.username={dbUser}
spring.datasource.password={dbPassword}

# drop in to create the table, good for testing, comment this in production. This will create the table for you on each load of application, so you may want to comment this out after the first load
spring.jpa.hibernate.ddl-auto=create

Run

Once you've created an Okta org, configured it according to the blog post and set your application.properties file, you can run the application like so:

mvn spring-boot:run

Additional Resources

To learn more about the Okta OIDC and Single Sign-On (SSO), check out these links:

To learn more about JPA and Hibernate, check these out:

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

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

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.

Releases

No releases published

Packages

No packages published

Languages

  • Java 68.9%
  • HTML 31.1%