Skip to main content

[Config] Roles, Perms and Ranks

Roles

Roles are assigned to members, to distinguish staff from drivers, drivers from other members. They often work with permissions, making users with the role have one or more permissions, granting them access to specific endpoints.
The roles item in config is a list. Each item of the list must follow the format below:

{
    "id": "", // integar id
    "name": "", // string name
    "color": "" // optional hex color
}

The id must be an integar, like 100. It must be unique, conflicts might lead to issues, like only the list one in the last will be considered. It should not be changed once set and given to users, if changed, an "Unknown Role" will appear and you can no longer add or remove the role from users unless the id is recovered, but the permissions will persist. It's recommended to preserve a gap of id between roles, in case you want to insert a new role in the future. Also, the id will decide the order of the role list, smaller is higher.
The color is a hex color, starting with #, like #770202. This is an optional field and might be removed. Also, color rendering is only available to Frontend V2.

Below is an example of Founder and Driver role.

"roles": [{
    "id": "1",
    "name": "Founder",
    "color": "00ff00"
},{
    "id": "100",
    "name": "Driver",
    "color": "0000ff"
}]

Perms

Permissions are assigned to roles, to power the roles and grant users with the roles the access to specific endpoints.

Available permissions are:
admin - Full permission, including config, reload, audit permissions.
hrm - hr permission, plus disable_user_mfa, update_user_discord, delete_account_connections, delete_user, update_application_positions, delete_dlog permissions.
hr - patch_username, add_member, update_member_roles, update_member_points, dismiss_member, get_pending_user_list, ban_user permissions.
Plugin permissions include announcement, challenge, division, downloads, event, they have access to all endpoints of the plugin.
Another special permission is driver, which represents that the role is a driver role. This permission must include only one role.

All permissions are optional except admin. There must be at least one role with admin permission and one user with the role. Otherwise the Drivers Hub might become unusable.

The format of perms is a dict, with a role ID list following the permission, like:

"perms": {
    "admin": ["0", "1"],
    "driver": ["100"]
}

Below is an example with all permissions included, you might do modifications based on it for convenience:

"perms": {
    "admin": ["0"],
    "config": [],
    "reload": [],

    "hrm": [],
    "disable_user_mfa": [],
    "update_user_discord": [],
    "delete_account_connections": [],
    "delete_user": [],
    "update_application_positions": [],
    "delete_dlog": [],

    "hr": [],
    "patch_username": [],
    "add_member": [],
    "update_member_roles": [],
    "update_member_points": [],
    "dismiss_member": [],
    "get_pending_user_list": [],
    "ban_user": [],

    "audit": [],
    "announcement": [],
    "challenge": [],
    "division": [],
    "downloads": [],
    "event": [],

    "driver": ["100"]
}

Ranks

Rankings are neither roles or permissions, it is a separate term that represents the level of a driver.

The ranks item in config is a list. Each item of the list must follow the format below:

 {
    "points": "", // integar points
    "name": "", // string name
    "discord_role_id": "", // integar Discord Role ID
    "color": "" // optional hex color
}

The points must be an integar, like 2000. It represents how many points the driver must have to get the role. This is the total points of the driver, combing distance, challenge, division, event and myth.
The name is the name of the role, like Rookie.
The discord_role_id must be an integar (Discord Snowflake), like 941544375790489660. It represents the Discord Role to add to the driver in Discord when the driver ranks up.
The color is a hex color, starting with #, like #80e8dd. This is an optional field and might be removed. Also, color rendering is only available to Frontend V2.

Below is an example of a Rookie rank:

"ranks": [{
    "points": "2000"
    "name": "Rookie",
    "discord_role_id": "941544375790489660",
    "color": "#80e8dd"
}]