Skip to content

Authentication

Fabian Muff edited this page Jan 8, 2025 · 1 revision

API Login Process

The API login process allows users to authenticate themselves and gain access to protected resources. This wiki page provides information on how to perform the login process for a specific API. Login GUI

The login GUI for this API can be accessed using the following URL:

https://localhost:8001/login

Default Credentials

When accessing the login GUI, the following default credentials should be used:

Username: admin
Password: admin

REST API Login Process

Apart from using the GUI, the API also supports a RESTful login process. The login endpoint URL is:

POST https://localhost:8001/login/signin

Request Headers

The following request headers should be included in the API login request:

    Content-Type: application/json
    Accept: application/json

Request Body

The login request requires a JSON payload in the request body, containing the username and password. The structure of the request body should be as follows:

{
  "username": "admin",
  "password": "admin"
}

Replace the values of "username" and "password" with the desired credentials. Example Request

Here is an example of how to perform the login process using cURL:

curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{
  "username": "admin",
  "password": "admin"
}' https://localhost:8001/login/signin

Ensure that you replace "username" and "password" with the appropriate values.

Response

Upon successful authentication, the API will respond with a token or session identifier. By default, the token is stored in cookies. However, it can also be added to the request header for subsequent requests to protected resources such as follow.

x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3QiLCJ1dWlkIjoiMDNmMGNiZjgtMDI3OC00Yzg1LTgxMzAtMjhhZWQ5NzAyODRmIiwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTY4Nzc3MzIwNSwiZXhwIjoxNjg3Nzc2ODA1fQ.HfFBXUqN27NwJcgLY8aU26spTYnDw67SLmneqtAviAY

The token has the following format and content:

{
  "username": "admin",
  "uuid": "ff892138-77e0-47fe-a323-3fe0e1bf0240",
  "isAdmin": true,
  "iat": 1687765998,
  "exp": 1687852398
}
  1. The "username" field contains the username of the authenticated user.
  2. The "uuid" field represents a unique identifier for the user.
  3. The "isAdmin" field indicates whether the user has administrative privileges.
  4. The "iat" field specifies the token's issued at time, and the "exp" field denotes the token's expiration time.

The validity time of the token is 86400000 ms (24 hours).

User Creation with GUI

Users can be created using the GUI provided by the API. A REST call can be done to create a user.

curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{
  "username": "test",
  "password": "test"
}' https://localhost:8001/login/signup

Conclusion

The login process for the API involves either using the login GUI with default credentials or making a POST request to the /login/signin endpoint using the provided REST format. The response from the API will provide a token that can be stored in cookies or added to the request header for subsequent requests.

Clone this wiki locally