DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4
  • How Spring Boot Starters Integrate With Your Project
  • A Practical Guide to Creating a Spring Modulith Project
  • Structured Logging in Spring Boot 3.4 for Improved Logs

Trending

  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • Building Scalable and Resilient Data Pipelines With Apache Airflow
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • AI Meets Vector Databases: Redefining Data Retrieval in the Age of Intelligence
  1. DZone
  2. Coding
  3. Frameworks
  4. A Quick Guide to Okta and Spring Boot

A Quick Guide to Okta and Spring Boot

In this article, take a look at a tutorial on how to install the Okta CLI and create a Spring Boot app.

By 
Matt Raible user avatar
Matt Raible
·
Jan. 14, 21 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
6.4K Views

Join the DZone community and get the full member experience.

Join For Free

Meet Okta CLI, a new tool created here at Okta. Designed to streamline the creation of new Okta accounts, register apps, and get started, Okta CLI is a one-stop shop for all your Okta needs!

To show you just how Okta CLI can benefit you, I created a screencast. Feel free to watch it here.


For those that would rather read than watch, please read on.

Install the Okta CLI

You can find the website for the Okta CLI at cli.okta.com. This site has instructions on how to use common package managers on macOS, Windows, and Linux. You can also use cURL:

Shell
 




x


 
1
curl https://raw.githubusercontent.com/oktadeveloper/okta-cli/master/cli/src/main/scripts/install.sh | bash


Once you have the Okta CLI installed, you’ll need Java 11 installed to run your Spring Boot app.

Create a Spring Boot App

To create a secure Spring Boot app with Okta, run okta start spring-boot. You’ll need to verify your email and set a password as part of this.If you already have anOkta account, you can run "okta login" first.

This will download our Okta Spring Boot sample, register your app on Okta, and configure it by adding your Okta settings to src/main/resources/application.properties.

Follow the instructions that are printed out for you. To summarize:

Shell
 




xxxxxxxxxx
1


 
1
cd spring-boot
2
./mvnw spring-boot:run


Next, open your browser to http://localhost:8080. You’ll likely be logged in straight away and see your name printed on the screen.Hello: Matt Raible screenshot

If you use another browser or an incognito window, you’ll be prompted to sign in first.


Okta login page

If you open src/main/java/com/example/sample/Application.java, you’ll see the Java code that’s used to render your name. You might appreciate how Spring Security makes authentication with OpenID Connect easy.

Java
 




xxxxxxxxxx
1


 
1
@RestController
2
static class SimpleRestController {
3
    @GetMapping("/")
4
    String sayHello(@AuthenticationPrincipal OidcUser oidcUser) {
5
        return "Hello: " + oidcUser.getFullName();
6
    }
7
}


Learn More About Spring Boot and Okta

I hope you’ve enjoyed this brief intro to the Okta CLI. It’s a tool for developers to make their lives easier. If you have any suggestions for improvement, please add an issue to our okta/okta-cli repository.

If you like Spring Boot and Okta, you might like these posts:

  • Deploy a Secure Spring Boot App to Heroku
  • OAuth 2.0 Patterns with Spring Cloud Gateway
  • OpenID Connect Logout Options with Spring Boot
  • Build a CRUD App with Angular 9 and Spring Boot 2.2
  • OAuth 2.0 Java Guide: Secure Your App in 5 Minutes
Spring Framework Spring Boot

Published at DZone with permission of Matt Raible, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4
  • How Spring Boot Starters Integrate With Your Project
  • A Practical Guide to Creating a Spring Modulith Project
  • Structured Logging in Spring Boot 3.4 for Improved Logs

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!