Skip to content

Latest commit

 

History

History

01-Login

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Java EE Login Sample

This sample demonstrates how to use Auth0 to perform authentication using Java EE and the mvc-auth-commons SDK. Download or clone this repository and follow the instructions below to setup the sample.

Project Setup

Auth0 Dashboard

  1. On the Auth0 Dashboard create a new Application of type Regular Web Application.
  2. On the Settings tab of your application, add the URL http://localhost:3000/callback to the Allowed Callback URLs field.
  3. On the Settings tab of your application, add the URL http://localhost:3000/ to the Allowed Logout URLs field.
  4. Copy the Domain, Client ID and Client Secret values at the top of the page and use them to configure the Java Application.

Application configuration

Copy src/main/webapp/WEB-INF/web.xml.example to src/main/webapp/WEB-INF/web.xml:

cp src/main/webapp/WEB-INF/web.xml.example src/main/webapp/WEB-INF/web.xml

Set the application values in the web.xml file to the values of your Auth0 application.

<env-entry>
    <env-entry-name>auth0.domain</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>{DOMAIN}</env-entry-value>
</env-entry>
<env-entry>
    <env-entry-name>auth0.clientId</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>{CLIENT_ID}</env-entry-value>
</env-entry>
<env-entry>
    <env-entry-name>auth0.clientSecret</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>{CLIENT_SECRET}</env-entry-value>
</env-entry>
<env-entry>
    <env-entry-name>auth0.scope</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>openid profile email</env-entry-value>
</env-entry>

Running the sample

You can run the sample with Maven or Docker.

Maven

Open a terminal, go to the project root directory and execute the wildfly:run Maven goal.

Linux/macOS:

./mvnw clean wildfly:run

Windows:

mvnw.cmd clean wildfly:run

The server will be accessible on http://localhost:3000.

Docker

Linux/macOS:

sh exec.sh

Windows:

./exec.ps1

The server will be available on http://localhost:3000.