restapi.services.authentication.BaseAuthentication

class restapi.services.authentication.BaseAuthentication[source]

An almost abstract class with methods to be implemented with a new service that aims to store credentials of users and roles.

__init__()[source]
Return type:

None

Methods

__init__()

add_user_to_group(user, group)

Save the group.members -> user relationship

change_password(user, password, ...)

param user:

check_password_validity(user, ...)

param user:

count_failed_login(username)

param username:

create_group(groupdata)

A method to create a new group

create_role(name, description)

A method to create a new role

create_temporary_token(user, token_type[, ...])

param user:

create_token(payload)

Generate a str token with JWT library to encrypt the payload

create_user(userdata, roles, group)

A method to create a new user

custom_user_properties_post(user, userdata, ...)

param user:

custom_user_properties_pre(userdata)

param userdata:

delete_group(group)

param group:

delete_user(user)

param user:

fill_payload(user[, expiration, token_type])

Informations to store inside the JWT token, starting from the user obtained from the current service

flush_failed_logins(username)

Flush failed logins for the give username

get_group([group_id, name])

How to retrieve a single group from the current authentication db

get_group_members(group)

How to retrieve group users list from the current authentication db

get_groups()

How to retrieve groups list from the current authentication db

get_logins([username, only_unflushed])

Save login information

get_password_hash(password)

param password:

get_qrcode(user)

param user:

get_remote_ip([raise_warnings])

param raise_warnings:

get_roles()

How to retrieve all the roles

get_roles_from_user(user)

Retrieve roles from a user object from the current auth service

get_tokens([user, token_jti, get_all])

Return the list of tokens

get_totp_secret(user)

param user:

get_user([username, user_id])

How to retrieve a single user from the current authentication db, based on the unique username or the user_id return None if no filter parameter is given

get_user_group(user)

How to retrieve the group that the user belongs to from the current auth db

get_users()

How to retrieve a list of all users from the current authentication db

init_auth_db(options)

param options:

init_groups(force)

param force:

init_roles()

rtype:

None

init_users(default_group, roles, force)

param default_group:

invalidate_token(token)

With this method the specified token must be invalidated as expected after a user logout

is_admin(user)

Check if current user has Administration role

is_bcrypt_hashed(password)

param password:

is_coordinator(user)

Check if current user has Coordinator role

is_staff(user)

Check if current user has Staff role

link_roles(user, roles)

A method to assign roles to a user

load_default_user()

rtype:

None

load_roles()

rtype:

None

log_event(event[, target, payload, user])

param event:

make_login(username, password, totp_code)

param username:

module_initialization()

rtype:

None

register_failed_login(username, user)

param username:

save_group(group)

param group:

save_login(username, user, failed)

Save login information

save_role(role)

param role:

save_token(user, token, payload[, token_type])

param user:

save_user(user)

param user:

unpack_token(token[, raiseErrors])

param token:

unpacked_token(valid[, token, jti, user])

param valid:

verify_blocked_username(username)

param username:

verify_password(plain_password, hashed_password)

param plain_password:

verify_password_strength(pwd, old_pwd, ...)

param pwd:

verify_roles(user, roles[, required_roles, ...])

param user:

verify_token(token[, raiseErrors, token_type])

param token:

verify_token_validity(jti, user)

This method MUST be implemented by specific Authentication Methods to add more specific validation contraints

verify_totp(user, totp_code)

param user:

verify_user_status(user)

param user:

Attributes

ACTIVATE_ACCOUNT

DEFAULT_TOKEN_TTL

DISABLE_UNUSED_CREDENTIALS_AFTER

FAILED_LOGINS_EXPIRATION

FORCE_FIRST_PASSWORD_CHANGE

FULL_TOKEN

GRACE_PERIOD

JWT_ALGO

JWT_SECRET

MAX_LOGIN_ATTEMPTS

MAX_PASSWORD_VALIDITY

MIN_PASSWORD_LENGTH

PWD_RESET

SAVE_LAST_ACCESS_EVERY

SECOND_FACTOR_AUTHENTICATION

TOTP

TOTP_VALIDITY_WINDOW

UNLOCK_CREDENTIALS

default_password

default_role

default_user

fernet

role_descriptions

roles

roles_data