auth.manager module

Provides a singleton class to access player permissions.

class auth.manager._AuthManager[source]

Bases: dict

Manages backends and configuration files.

__init__()[source]

Initialize the object.

_unload_active_backend()[source]

Unload the active backend if there is one.

find_and_add_available_backends()[source]

Find and add all available backends.

Raises:ValueError – Raised if no backend or multiple backends are found within a single file.
get_parent_permissions(parent_name)[source]

Return the parent permissions.

Parameters:parent_name (str) – Name of the parent.
Return type:ParentPermissions
get_player_permissions(index)[source]
get_player_permissions_from_steamid(steamid)[source]

Return the permissions of a player.

Parameters:steamid (str/int) – The SteamID2, SteamID3 or SteamID64 of a player.
Returns:If the given SteamID is invalid (e.g. ‘BOT’), None will be returned.
Return type:PlayerPermissions
is_backend_loaded(backend_name)[source]

Return True if the given backend is currently loaded.

Return type:bool
is_parent_authorized(parent_name, permission)[source]

Return True if the parent has been granted the given permission.

Return type:bool
is_player_authorized(index, permission)[source]

Return True if the player has been granted the given permission.

Return type:bool
load()[source]

Load the auth manager.

set_active_backend(backend_name)[source]

Set the active backend.

Parameters:backend_name (str) – Name of the backend.
Raises:ValueError – Raised if the backend does not exist.
targets_this_server(server_id)[source]

Return whether the server ID targets this server.

Parameters:server_id (int) – A server ID to test.
Return type:bool
unload()[source]

Unload the auth manager.

class auth.manager.ParentPermissionDict[source]

Bases: auth.manager._PermissionDict

class auth.manager.ParentPermissions(name)[source]

Bases: auth.manager.PermissionBase

A container for parent permissions.

__init__(name)[source]

Initialize the object.

Parameters:name (str) – Name of the parent.
class auth.manager.PermissionBase(name)[source]

Bases: dict

Base class for parent and player permissions.

__init__(name)[source]

Initialize the object.

static _compile_permission(permission)[source]

Compile a permission.

_has_permission(permission, name_list)[source]
add(permission, server_id=None, update_backend=True)[source]

Add a permission.

Parameters:
  • permission (str) – The permission to add.
  • server_id (int) – The server ID to which the permission should be added. If no server ID is given, it will be only added to this server.
  • update_backend (bool) – If True, the backend will be updated.
add_parent(parent_name, update_backend=True)[source]

Add a parent.

Parameters:
  • parent_name (str) – Name of the parent.
  • update_backend (bool) – If True, the backend will be updated.
clear()[source]

Removes all permissions stored in this object and its parents.

flatten()[source]

Return all permissions flattened recursively.

Return type:generator
remove(permission, server_id=None, update_backend=True)[source]

Remove a permission.

Parameters:
  • permission (str) – The permission to remove.
  • server_id (int) – The server ID from which the permission should be removed. If no server ID is given, it will be only removed from this server.
  • update_backend (bool) – If True, the backend will be updated.
remove_parent(parent_name, update_backend=True)[source]

Remove a parent.

Parameters:
  • parent_name (str) – Name of the parent.
  • update_backend (bool) – If True, the backend will be updated.
class auth.manager.PlayerPermissionDict[source]

Bases: auth.manager._PermissionDict

class auth.manager.PlayerPermissions(name, steamid64)[source]

Bases: auth.manager.PermissionBase

A container for player permissions.

__init__(name, steamid64)[source]

Initialize the object.

Parameters:
  • name (str) – A SteamID2, SteamID3 or SteamID64 value.
  • steamid64 (int) – The SteamID64 value that was also used to store the object in the :class:PlayerPermissionDict`` object.
auth.manager.auth_manager = {'sql': <auth.backend.sql.SQLBackend object>, 'flatfile': <auth.backend.flatfile.FlatfileBackend object>}

The singleton object of _AuthManager.