Changeset View
Changeset View
Standalone View
Standalone View
swh/web/auth/utils.py
# Copyright (C) 2020 The Software Heritage developers | # Copyright (C) 2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from base64 import urlsafe_b64encode | from base64 import urlsafe_b64encode | ||||
from cryptography.fernet import Fernet | from cryptography.fernet import Fernet | ||||
from cryptography.hazmat.backends import default_backend | from cryptography.hazmat.backends import default_backend | ||||
from cryptography.hazmat.primitives import hashes | from cryptography.hazmat.primitives import hashes | ||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC | from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC | ||||
OIDC_SWH_WEB_CLIENT_ID = "swh-web" | OIDC_SWH_WEB_CLIENT_ID = "swh-web" | ||||
SWH_AMBASSADOR_PERMISSION = "swh.ambassador" | |||||
def _get_fernet(password: bytes, salt: bytes) -> Fernet: | def _get_fernet(password: bytes, salt: bytes) -> Fernet: | ||||
""" | """ | ||||
Instantiate a Fernet system from a password and a salt value | Instantiate a Fernet system from a password and a salt value | ||||
(see https://cryptography.io/en/latest/fernet/). | (see https://cryptography.io/en/latest/fernet/). | ||||
Args: | 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 | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |