Changeset View
Changeset View
Standalone View
Standalone View
swh/web/auth/utils.py
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | Args: | ||||
password: user password that will be used to generate a Fernet key | password: user password that will be used to generate a Fernet key | ||||
derivation function | derivation function | ||||
salt: value that will be used to generate a Fernet key | salt: value that will be used to generate a Fernet key | ||||
derivation function | derivation function | ||||
Returns: | Returns: | ||||
The decrypted data | The decrypted data | ||||
""" | """ | ||||
return _get_fernet(password, salt).decrypt(data) | return _get_fernet(password, salt).decrypt(data) | ||||
anlambert: `privileged_user` sounds like a better name for me. | |||||
def privileged_user(request) -> bool: | |||||
"""Determine whether a user is authenticated and is a privileged one (e.g ambassador). | |||||
This allows such user to have access to some more actions (e.g. bypass save code now | |||||
review, access to 'bundle' type...) | |||||
""" | |||||
return request.user.is_authenticated and request.user.has_perm( | |||||
SWH_AMBASSADOR_PERMISSION | |||||
) |
privileged_user sounds like a better name for me.