Changeset View
Changeset View
Standalone View
Standalone View
swh/web/client/auth.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 General Public License version 3, or any later version | # License: GNU 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 typing import Any, Dict | from typing import Any, Dict | ||||
from urllib.parse import urljoin | from urllib.parse import urljoin | ||||
import requests | import requests | ||||
SWH_OIDC_SERVER_URL = 'https://auth.softwareheritage.org/auth/' | SWH_OIDC_SERVER_URL = 'https://auth.softwareheritage.org/auth/' | ||||
SWH_REALM_NAME = 'SoftwareHeritage' | SWH_REALM_NAME = 'SoftwareHeritage' | ||||
SWH_WEB_CLIENT_ID = 'swh-web' | SWH_WEB_CLIENT_ID = 'swh-web' | ||||
class AuthenticationError(Exception): | |||||
"""Authentication related error. | |||||
Example: A bearer token has expired. | |||||
""" | |||||
pass | |||||
class OpenIDConnectSession: | class OpenIDConnectSession: | ||||
""" | """ | ||||
Simple class wrapping requests sent to an OpenID Connect server. | Simple class wrapping requests sent to an OpenID Connect server. | ||||
Args: | Args: | ||||
oidc_server_url: URL of OpenID Connect server | oidc_server_url: URL of OpenID Connect server | ||||
realm_name: name of the OpenID Connect authentication realm | realm_name: name of the OpenID Connect authentication realm | ||||
client_id: OpenID Connect client identifier in the realm | client_id: OpenID Connect client identifier in the realm | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |