mcvirt.auth package

Submodules

mcvirt.auth.auth module

Provide auth class for managing permissions.

class mcvirt.auth.auth.Auth[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides authentication and permissions for performing functions within MCVirt.

add_superuser(user_object, ignore_duplicate=False)[source]

Add a new superuser.

add_user_permission_group(*args, **kwargs)
assert_permission(permission_enum, vm_object=None)[source]

Use check_permission function to determine if a user has a given permission and throws an exception if the permission is not present.

assert_user_type(*user_type_names)[source]

Ensure that the currently logged in user is of a specified type.

check_permission(permission_enum, vm_object=None, user_object=None)[source]

Check that the user has a given permission, either globally through MCVirt or for a given VM.

check_permission_in_config(permission_config, user, permission_enum)[source]

Read permissions config and determines if a user has a given permission.

static check_root_privileges()[source]

Ensure that the user is either running as root or using sudo.

check_user_type(*user_type_names)[source]

Check that the currently logged-in user is of a specified type.

copy_permissions(source_vm, dest_vm)[source]

Copy the permissions from a given VM to this VM. This functionality is used whilst cloning a VM

delete_superuser(user_object)[source]

Remove a superuser.

delete_user_permission_group(*args, **kwargs)
get_permission_groups()[source]

Return list of user groups.

get_superusers()[source]

Return a list of superusers

get_users_in_permission_group(permission_group, vm_object=None)[source]

Obtain a list of users in a given group, either in the global permissions or for a specific VM.

is_superuser()[source]

Determine if the current user is a superuser of MCVirt.

mcvirt.auth.cluster_user module

Provide class for managing cluster users.

class mcvirt.auth.cluster_user.ClusterUser(username)[source]

Bases: mcvirt.auth.user_base.UserBase

User type for cluster daemon users.

CAN_GENERATE = True
CLUSTER_USER = True
DISTRIBUTED = False
USER_PREFIX = 'mcv-cluster-'
allow_proxy_user

Connection users can proxy for another user.

static get_default_config()[source]

Return the default user config.

node

Return the node that the user is used for

update_host(host)[source]

Update the host associated with the user.

mcvirt.auth.connection_user module

Provide class for managing connection users.

class mcvirt.auth.connection_user.ConnectionUser(username)[source]

Bases: mcvirt.auth.user_base.UserBase

User type for initial connection users

CAN_GENERATE = True
CLUSTER_USER = True
DISTRIBUTED = False
PERMISSIONS = [<Mock id='140218820756944'>]
USER_PREFIX = 'mcv-connection-'
allow_proxy_user

Connection users can proxy for another user.

create_cluster_user(host)[source]

Create a cluster user for the remote node.

mcvirt.auth.factory module

Provide factory class to create/obtain users.

class mcvirt.auth.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class for obtaining user objects

USER_CLASS

alias of UserBase

add_config(username, user_config)[source]

Add a user config to the local node.

authenticate(username, password)[source]

Attempt to authenticate a user, using username/password.

create(username, password, user_type=<class 'mcvirt.auth.user.User'>)[source]

Create a user.

ensure_valid_user_type(user_type)[source]

Ensure that a given user_type is valid.

generate_user(user_type)[source]

Remove any existing connection user and generates credentials for a new connection user.

get_all_user_objects(user_class=None)[source]

Return the user objects for all users, optionally filtered by user type.

get_all_users()[source]

Return all the users, excluding built-in users.

get_cluster_user_by_node(node)[source]

Obtain a cluster user for a given node

get_user_by_username(username)[source]

Obtain a user object for the given username.

get_user_types()[source]

Return the available user classes.

mcvirt.auth.permissions module

Provide permission enum and permission group definitions.

mcvirt.auth.session module

Provide class for managing authentication sessions.

class mcvirt.auth.session.Session[source]

Bases: object

Handle daemon user sessions.

USER_SESSIONS = {}
authenticate_session(username, session)[source]

Authenticate user session.

authenticate_user(username, password)[source]

Authenticate using username/password and store session

get_current_user_object()[source]

Return the current user object, based on pyro session.

get_proxy_user_object()[source]

Return the user that is being proxied as.

mcvirt.auth.user module

Provide class for regular MCVirt interactive users

class mcvirt.auth.user.User(username)[source]

Bases: mcvirt.auth.user_base.UserBase

Provides an interaction with the local user backend

set_password(new_password)[source]

Change the current user’s password.

mcvirt.auth.user_base module

Provide a base class for user objects.

class mcvirt.auth.user_base.UserBase(username)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Base object for users (both user and automated).

CAN_GENERATE = False
CLUSTER_USER = False
DISTRIBUTED = True
PERMISSIONS = []
USER_PREFIX = None
allow_proxy_user

Connection users can proxy for another user.

delete(*args, **kwargs)
static generate_password(length, numeric_only=False)[source]

Return a randomly generated password

get_config()[source]

Return the configuration of the user.

static get_default_config()[source]

Return the default configuration for the user type.

get_user_type()[source]

Return the user type of the user

get_username()[source]

Return the username of the current user

Module contents