Skip to content

An example of using embedded Tomcat 10 With Pac4J and Generic OAuth.

Notifications You must be signed in to change notification settings

daberkow/Pac4J_Oauth_Tomcat_10_Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pac4J_Oauth_Tomcat_10_Example

An example of using embedded Tomcat 10 With Pac4J and Generic OAuth. I spent a chunk of time learning how to integrate Tomcat 10 (Jakarta) with Pac4J and Keycloak. This code is an example to anyone who needs to do similar. I have also thrown in some examples of Tomcat security settings which can help you get through a Nessus scan.

Targeting: Java 17, PAC4J 5.7, Tomcat 10.1

Using this Repo

  1. Follow the guide on my blog post to get Keycloak setup, or be prepared with your own OAuth server
  2. Clone this repo down
  3. Edit .\src\main\java\com\github\daberkow\pac4j_oauth_tomcat_10_example\oauth\AbstractAuth.class with your client ID (Key) and secret
  4. On Windows .\gradlew.bat build run, on Linux/Mac ./gradlew build run
  5. Browse to http://127.0.0.1:8080

Please keep in mind this is demonstration code, not production ready code.

Some added things to play with, I included 2 plugins for Gradle I always like to use.

First Shadow this creates a single jar with all your dependencies to easily package your app up. Running .\gradle.bat shadowJar will drop a file named Pac4J_Oauth_Tomcat_10_Example-all.jar in .\build\libs\. Then running java -jar Pac4J_Oauth_Tomcat_10_Example-all.jar will run the whole app.

Second The Gradle Versions Plugin this adds the dependencyUpdates task to Gradle, making it one command to see which of your dependencies need upgraded.

Hope this repo helps someone out there, if it does please star it or drop a comment over at the blog!

About

An example of using embedded Tomcat 10 With Pac4J and Generic OAuth.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published