GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - oktadev/auth0-full-stack-java-example: 🔥 Full Stack Java Example

BranchesTags
Open more actions menu

Latest commit

 

History

71 Commits
71 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.husky
.husky
 
 
.jhipster
.jhipster
 
 
.mvn/wrapper
.mvn/wrapper
 
 
screenshots
screenshots
 
 
src
src
 
 
webpack
webpack
 
 
.editorconfig
.editorconfig
 
 
.eslintignore
.eslintignore
 
 
.eslintrc.json
.eslintrc.json
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.lintstagedrc.js
.lintstagedrc.js
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
.yo-rc-global.json
.yo-rc-global.json
 
 
.yo-rc.json
.yo-rc.json
 
 
Procfile
Procfile
 
 
README.md
README.md
 
 
checkstyle.xml
checkstyle.xml
 
 
cypress-audits.json
cypress-audits.json
 
 
cypress.json
cypress.json
 
 
demo.adoc
demo.adoc
 
 
flickr2.jdl
flickr2.jdl
 
 
jest.conf.js
jest.conf.js
 
 
mvnw
mvnw
 
 
mvnw.cmd
mvnw.cmd
 
 
npmw
npmw
 
 
npmw.cmd
npmw.cmd
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
pom.xml
pom.xml
 
 
postcss.config.js
postcss.config.js
 
 
sonar-project.properties
sonar-project.properties
 
 
system.properties
system.properties
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.test.json
tsconfig.test.json
 
 

Repository files navigation

Full Stack Java Example with JHipster (React + Spring Boot) 🤓

This example app shows you how to create a slick-looking, full-stack, secure application using React, Spring Boot, and JHipster.

Please read the following blog posts to learn more:

  • Full Stack Java with React, Spring Boot, and JHipster to see how this app was created.
  • Introducing Spring Native for JHipster: Serverless Full-Stack Made Easy to convert this app to an executable with Spring Native.
  • Use GitHub Actions to Build GraalVM Native Images to automate your GraalVM builds.

Prerequisites:

  • Node.js 14+
  • Java 11+
  • Docker Compose
  • An Auth0 Account

Auth0 is an easy to implement, adaptable authentication and authorization platform. Basically, we make your login box awesome.

  • Getting Started
  • Links
  • Help
  • License

Getting Started

To install this example, clone it.

git clone https://github.com/oktadev/auth0-full-stack-java-example.git
cd auth0-full-stack-java-example

Create a .auth0.env file in the root of the project, and fill it with the code below to override the default OIDC settings:

export SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=https://<your-auth0-domain>/
export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=<your-client-id>
export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=<your-client-secret>
export JHIPSTER_SECURITY_OAUTH2_AUDIENCE=https://<your-auth0-domain>/api/v2/

You'll need to create a new web application in Auth0 and fill in the <...> placeholders before this works.

Create an OpenID Connect App on Auth0

Log in to your Auth0 account (or sign up if you don't have an account). You should have a unique domain like dev-xxx.eu.auth0.com.

Press the Create Application button in Applications section. Use a name like JHipster Baby!, select Regular Web Applications, and click Create.

Switch to the Settings tab and configure your application settings:

  • Allowed Callback URLs: http://localhost:8080/login/oauth2/code/oidc
  • Allowed Logout URLs: http://localhost:8080/

Scroll to the bottom and click Save Changes.

In the roles section, create new roles named ROLE_ADMIN and ROLE_USER.

Create a new user account in the users section. Click on the Role tab to assign the roles you just created to the new account.

Make sure your new user's email is verified before attempting to log in!

Next, head to Auth Pipeline > Rules > Create. Select the Empty rule template. Provide a meaningful name like Group claims and replace the Script content with the following.

function(user, context, callback) {
  user.preferred_username = user.email;
  const roles = (context.authorization || {}).roles;

  function prepareCustomClaimKey(claim) {
    return `https://www.jhipster.tech/${claim}`;
  }

  const rolesClaim = prepareCustomClaimKey('roles');

  if (context.idToken) {
    context.idToken[rolesClaim] = roles;
  }

  if (context.accessToken) {
    context.accessToken[rolesClaim] = roles;
  }

  callback(null, user, context);
}

This code is adding the user's roles to a custom claim (prefixed with https://www.jhipster.tech/roles). This claim is mapped to Spring Security authorities in SecurityUtils.java.

Click Save changes to continue.

NOTE: Want to have all these steps automated for you? Vote for this issue in the Auth0 CLI project.

Run Your JHipster App with Auth0

Set your Auth0 properties in .auth0.env, and start the app.

source .auth0.env
./mvnw

Voilà - your full stack app is using Auth0! Open your favorite browser to http://localhost:8080 and sign-in.

Links

This example uses the following open source libraries:

  • JHipster
  • Spring Boot
  • Spring Security

Help

Please post any questions as comments on the blog post.

License

Apache 2.0, see LICENSE.

About

🔥 Full Stack Java Example

auth0.com/blog/full-stack-java-with-react-spring-boot-and-jhipster/

Topics

auth0fullstackfullstack-javajavaoidcreactspring-boot

Resources

Readme

Code of conduct

Code of conduct
Activity
Custom properties

Stars

34 stars

Watchers

5 watching

Forks

20 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.