Floating Server

Role-Based Access Control

14min

Starting from version 1.5.0, for role-based access control (RBAC), the following functionalities have been added to the floating server:

  • Two Roles: Admin and User.
  • Any individual accessing server functionality must be assigned either an Admin or User role.
  • Admin Permissions:
    • Add new users and admins.
    • Add and remove licenses (online, offline, and air-gapped).
    • Configure license and management API URLs.
    • Set shared and API keys.
  • User Permissions (Admins and non-admin users):
    • Register as a floating user.
    • Add consumptions.
    • Access reports.
    • Check server health.
    • Borrow licenses.
    • Change their own password.

This RBAC model applies to both browser and API access.

Start the Server

To start the server in authentication mode, use the following command:

./floating-server -userAuthentication true

API Access

For API access, users must first log in and obtain a JWT, which is then included in subsequent requests. An example is shown below.

If a user attempts to register without logging in, they will receive an error prompting them to log in first.

Curl

Response: {"message":"Unauthorized: Please log in"}

To log in, users send a request containing their username and password to the /authendpoint. An example is shown below.

Curl

Response: {"message":"Login successful","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoidXNlciIsInVzZXJuYW1lIjoidXNlcjEifQ.laskPwD_z36WjODEGKNpVojnouqXYCtKr9HXrLPBqWw"}

This endpoint returns a JWT, which the user must then include in subsequent requests. After receiving the token, the user can resend the registration request using the JWT for authentication.


Curl


The registeration is successful.

Browser

The login page in authentication mode:

login page


The Users Management tab displays a list of all users and their assigned roles.

  • Admin Permissions:
    • Admins can add new users or remove existing ones.
    • When adding a user, the admin assigns a temporary password, which the user must change upon their first login.
Document image


Users and admins can change their own password form the Change password tab:

Document image


If a non-admin user attempts to perform actions restricted to admins, they will receive an error message, as shown below.

Document image


Initialize Users

Initializing the First Admin User

The first admin user can be set up during the server initialization by adding a password hash to the config/config.yaml file in the following format:

  1. Generate the SHA-256 hash of the admin's password.
  2. Enter this hash into the config file as shown below. This will create an admin user with the username "admin," and the specified password will be registered in the server's database. This admin can then add other users later.

Example YAML format for admin setup:

YAML


Here’s an improved version of the text for your documentation:

Initializing the First Admin User

The first admin user can be set up during the server initialization by adding a password hash to the config/config.yaml file in the following format:

  1. Generate the SHA-256 hash of the admin's password.
  2. Enter this hash into the config file as shown below. This will create an admin user with the username "admin," and the specified password will be registered in the server's database. This admin can then add other users later.

Example YAML format for admin setup:

YAML


Note on Version 1.5.0

In version 1.5.0, user initialization in the config file allowed multiple users with any role to be specified. However, this was restricted starting in version 1.5.1 and later versions. In version 1.5.0, the configuration format for multiple users looked like this:



YAML


Starting from version 1.5.1, user initialization is limited to a single admin user at the setup stage.

Number of Admins

At least one admin is required when running the server in authentication mode. If no admin is configured, the server will fail to launch, displaying an error message requesting you to provide the necessary configuration.

Storage

User information is stored in the database, and passwords are securely stored as hashed values.