Auth Controller Documentation

The AuthController handles user authentication and authorization. It provides endpoints for logging in and inviting users.

For more information on Users, check the Melon User Guide.

Controller Route: /auth/

All routes within the AuthController are prefixed by /auth/.


Summary of Endpoints

Endpoint Method Description Authorization
/auth/login GET Login with a username and password to obtain a JWT token. None
/auth/invite GET Generate a new invite code for user registration. Admin
/auth/code-authenticate GET Generate a "Server" role JWT using an invite code. None
/auth/check GET Validate a JWT to check if it is still active. Admin, User, Pass

Login

This endpoint handles logging in users with their username and password, returning a JWT token for authenticating future API calls.

Details:

Parameters:

Responses:

Example Request:

GET /auth/login?username=johndoe&password=secret

Create Invite Code

Generates a four-character invite code that can be used to create new user accounts. This invite code lasts for 10 minutes, during which it can be used to obtain a JWT for account creation. Once an invite code has been used to generate a JWT token, it becomes invalid.

Details:

Notes:

Responses:

Example Request:

GET /auth/invite 
Authorization: Bearer <Admin-JWT>

Code Authenticate

This endpoint generates a "Server" role JWT using an invite code. The invite code is invalidated after being used once to create a token.

Parameters:

Notes:

Responses:

Example Request:

GET /auth/code-authenticate?code=ABCD

JWT Authentication Test

This endpoint verifies if the provided JWT token is valid.

Responses:

Example Request:

GET /auth/check
Authorization: Bearer <JWT>