Skip to content

Demonstrates using Auth0 with Java using plain Servlets and JSP pages.

License

Notifications You must be signed in to change notification settings

PascalLike/auth0-servlet-sample

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demonstrates using Auth0 with Java using plain Servlets and JSP pages.

This is a companion sample for the Auth0 Servlet library. Please refer to that library and documentation for further information specific to the library itself.

A simple (plain) Java web application that demonstrates how to use Auth0 with Java for server-side MVC web apps. Validates the JWT from Auth0 in every API call to assert authentication according to configuration. If your application only needs secured endpoints and the ability to programmatically work with a Principal object for GrantedAuthority checks this library is a good fit.

However, if you are already using Java Spring and wish to leverage fully Java Spring Security - with powerful support for Security Annotations, Security JSTL Tag libraries, Fine-grained Annotation level method security and URL endpoint security at the Role / Group level - then see this project Auth0 Spring Security MVC and associated sample Auth0 Spring Security MVC Sample

If you are not ready for Java Spring Security yet, but would prefer to be using Java Spring (Boot), and leverage the benefits of convention over configuration, dependency injection and so on, then this project Auth0 Spring MVC and associated sample Auth0 Spring MVC Sample

Prerequisites

In order to run this example you will need to have Java 7+ and Maven installed.

Check that your maven version is 3.0.x or above:

mvn -v

Setup

Create an Auth0 Account (if not already done so - free!).

From the Auth0 Dashboard

Create an application - for the purposes of this sample - app

Ensure you add the following to the settings.

Allowed Callback URL:

http://localhost:3099/callback

Ensure you add the following to the settings.

Allowed Logout URLs:

http://localhost:3099/logout

Add one or more connections to your application - for instance Google Social Connection, or username-password DB connection.

Inside the Application - update configuration information

Enter your:

auth0.domain, auth0.issuer, auth0.clientId, and auth0.clientSecret into src/main/webapp/WEB-INF/web.xml

Note:

auth0.issuer should have the value https://YOUR_DOMAIN/ (the trailing slash is important). For example, if your auth0.domain is example.auth0.com then auth0.issuer should have value https://example.auth0.com/.

Build and Run

In order to build and run the project you must execute:

mvn clean install tomcat7:run

Then, go to http://localhost:3099/login.


Screenshots of the overall flow (minus growler notifications):

1.Login

2. Home

About

Demonstrates using Auth0 with Java using plain Servlets and JSP pages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 64.8%
  • CSS 35.2%