melix / repro-graalvm-indy-bug

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java REST API Examples: Micronaut, Quarkus, Spring Boot, and Helidon

This repository contains example OAuth 2.0 resource servers built with Micronaut, Quarkus, Spring Boot, and Helidon.

Prerequisites: Java 20 with GraalVM and HTTPie.

Getting Started

First, clone this repository:

git clone https://github.com/oktadev/auth0-java-rest-api-examples.git

You will need a JDK with GraalVM and its native-image compiler. Using SDKMAN, run the following command and set it as the default:

sdk install java 22.3.3.r20-grl

Next, you'll need a free Auth0 developer account.

Install the Auth0 CLI and run auth0 login to connect it to your account.

Create an access token using Auth0's CLI:

auth0 test token -a https://<your-auth0-domain>/api/v2/

Set the access token as a TOKEN environment variable in a terminal window.

TOKEN=eyJraWQiOiJYa2pXdjMzTDRBYU1ZSzNGM...

Change the following files for each framework to match your Auth0 domain:

  • Micronaut: micronaut/src/main/resources/application.yml
  • Quarkus: quarkus/src/main/resources/application.properties
  • Spring Boot: spring-boot/src/main/resources/application.properties
  • Helidon: helidon/src/main/resources/META-INF/microprofile-config.properties

You can start each app using its CLI, Gradle, or Maven. Note that you will only be able to start one at a time since they all run on port 8080.

  • Micronaut: ./gradlew optimizedRun
  • Quarkus: quarkus dev
  • Spring Boot: ./gradlew bootRun
  • Helidon: helidon dev

Then, you can test them with an access token and HTTPie.

Use HTTPie to pass the JWT in as a bearer token in the Authorization header.

http :8080/hello Authorization:"Bearer $TOKEN"

You should see your email address printed to your terminal.

You can also build and run each example as a native app.

  • Micronaut: ./gradlew nativeOptimizedCompile
  • Quarkus: quarkus build --native
  • Spring Boot: ./gradlew nativeCompile
  • Helidon: mvn package -Pnative-image

Then, start each app as a native executable.

  • Micronaut: ./build/native/nativeOptimizedCompile/app
  • Quarkus: ./build/quarkus-1.0.0-SNAPSHOT-runner
  • Spring Boot: ./build/native/nativeCompile/spring-boot
  • Helidon: ./target/helidon

Links

This example uses the following open source libraries:

Help

Please post any questions as issues in this repo or on the Auth0 Community Forums.

License

Apache 2.0, see LICENSE.

About

License:Apache License 2.0


Languages

Language:HTML 97.8%Language:Java 1.7%Language:Dockerfile 0.3%Language:Shell 0.2%