Skip to content

Load balanced Spring Boot + Spring Session application with OAuth 2.0

Notifications You must be signed in to change notification settings

oktadev/okta-spring-sessions-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Session Clustering for OAuth 2.0 Applications With Spring Boot, Redis, and HAProxy

This repository contains example load balanced OAuth 2.0 application built with Spring Boot. If you'd like to see how it was built, please read, Session Clustering for OAuth 2.0 Applications.

Prerequisites: Java 11 with GraalVM, HTTPie, and Docker v20.10+, and the Okta CLI.

Getting Started

First, clone this repository:

git clone https://github.com/oktadev/okta-spring-sessions-example.git

You will need Java 11+, Install a JDK using SDKMAN

Next, you'll need a free Okta developer account. Install the Okta CLI and run okta register to sign up for a new account. If you already have an account, run okta login. Then, run okta apps create. Select the default app name, or change it as you see fit. Choose Okta Spring Boot Starter and press Enter. Accept the remaining defaults.

Start Redis and HAProxy using Docker Compose:

docker compose up

Start two terminal windows and start two instances of the Spring Boot application one on port 8081 and another on 8082:

SERVER_PORT=8081 ./mvnw spring-boot:run

# and the second server

SERVER_PORT=8082 ./mvnw spring-boot:run

Open your browser to http://localhost:8080, after authentication reload the page a few times to toggle between servers.

Help

Please post any questions as comments on this example's blog post, or on the Okta Developer Forums.

License

Apache 2.0, see LICENSE.

About

Load balanced Spring Boot + Spring Session application with OAuth 2.0

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Languages