Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Auth0 Micronaut template

CI GitHub issues GitHub last commit


App is deployed to AWS Lambda:

JAR with StreamLambdaHandler Graal VM native binary with custom runtime
Branch master aws-lambda-graalvm

Client application using this API:

Website URL Github repository


Example should serve as a template when necessary to write a small service which uses JWT tokens signed by Auth0 server.

Blog post explaining implementation -

JWT config (by using JWKS) is visible in application.yml. Controller endpoint then uses @Secured annotation.

API endpoints

  • / - returns status UP in plain text
  • /me - returns user in JSON response


Running locally

Start Micronaut server

./gradlew run

Then to check status

curl http://localhost:8080

Running with SAM

This requires Docker to be running locally and sam CLI installed.

sam local start-api --template template.yaml --port 8080


Mounting ExampleFunction at [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
Mounting ExampleFunction at{proxy+} [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2020-03-02 22:16:20  * Running on (Press CTRL+C to quit)

Invoking function with events

Instead of running the application and then trying to invoke API in the browser you could just invoke Lambda function with pre-built events:

sam local invoke --template template.yaml --event aws-test-events/options-me.json --skip-pull-image

Packaging and deployment

Utilizing AWS Lambda to make sure I'm not paying for idle time.

Example micronaut implementations:


  1. Build jar

    ./gradlew clean build --info
  2. Create S3 bucket where application version is going to be uploaded before deployed to Cloudformation:

    aws s3 mb s3://BUCKET_NAME
  3. Package Lambda (uploads to S3):

    sam package \
        --output-template-file packaged.yaml \
        --s3-bucket BUCKET_NAME
  4. Create Cloudformation Stack and deploy your SAM resources.

    sam deploy \
        --template-file packaged.yaml \
        --stack-name STACK_NAME \
        --capabilities CAPABILITY_IAM
  5. After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:

    aws cloudformation describe-stacks \
        --stack-name STACK_NAME \
        --query 'Stacks[].Outputs[?OutputKey==`ApiUrl`]' \
        --output table

Simpler way

Below sam validate requires AWS Credentials to be set up.

sam validate && LAMBDA_APP_NAME=auth0-micronaut-template bash

Cloudformation cleanup

In order to delete our Serverless Application recently deployed you can use the following AWS CLI Command:

aws cloudformation delete-stack --stack-name STACK_NAME


Micronaut v2 API server using Auth0 JWT tokens to authenticate







No releases published


No packages published