This example shows how to build a simple REST service with Jetty embedded, how to create the same service using Spring Boot and Jetty embedded, and how to secure the service with Okta and OAuth/OIDC.
Please read [NEED A LINK]
Prerequisites: Java 11, HTTPie, and an Okta Developer Account.
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.
Clone this repository to your local hard drive using Git.
git clone https://<need.a.link> spring-boot-jetty
There are two separate applications within the project:
jettyembedded
: a Jetty embedded REST servlet appSpringBootJava
: a Spring Boot REST service
You can run the jettyembedded
app directly from the root directory of the project by running gradle apprun
.
To run the Spring Boot app, you will need to create an OIDC Application in Okta.
- Log in to your developer account on developer.okta.com.
- Navigate to Applications and click on Add Application.
- Select Web and click Next.
- Give the application a name (e.g.,
Spring Boot Jetty
) and add the following as Login redirect URIs:https://oidcdebugger.com/debug
- Click Done, then edit the project and enable "Implicit (Hybrid)" as a grant type (allow ID and access tokens) and click Save.
Go to API and Authorization Servers. Look under the default
server for the Issuer URI
.
Copy the Issuer URI
from your auth server into SpringBootJetty/src/main/resources/application.properties
:
okta.oauth2.issuer=https://{yourOktaUri}/oauth2/default
You should now be able to run the Spring Boot app from a shell by going to the project base directory (not the repository base directory, but the base directory for the Spring Boot app, SpringBootJetty
) and running gradle bootRun
.
This example uses the following open source libraries:
Please post any questions as comments on the blog post, or visit our Okta Developer Forums. You can also email developers@okta.com if you'd like to create a support ticket.
Apache 2.0, see LICENSE.