Changeset View
Changeset View
Standalone View
Standalone View
swh/auth/django/views.py
# Copyright (C) 2020-2021 The Software Heritage developers | # Copyright (C) 2020-2022 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 typing import Any, Dict, cast | from typing import Any, Dict, cast | ||||
import uuid | import uuid | ||||
from django.conf.urls import url | |||||
from django.contrib.auth import authenticate, login, logout | from django.contrib.auth import authenticate, login, logout | ||||
from django.core.cache import cache | from django.core.cache import cache | ||||
from django.http import HttpRequest | from django.http import HttpRequest | ||||
from django.http.response import ( | from django.http.response import ( | ||||
HttpResponse, | HttpResponse, | ||||
HttpResponseBadRequest, | HttpResponseBadRequest, | ||||
HttpResponseRedirect, | HttpResponseRedirect, | ||||
HttpResponseServerError, | HttpResponseServerError, | ||||
) | ) | ||||
from django.urls import re_path as url | |||||
from swh.auth.django.models import OIDCUser | from swh.auth.django.models import OIDCUser | ||||
from swh.auth.django.utils import keycloak_oidc_client, oidc_profile_cache_key, reverse | from swh.auth.django.utils import keycloak_oidc_client, oidc_profile_cache_key, reverse | ||||
from swh.auth.keycloak import KeycloakError, keycloak_error_message | from swh.auth.keycloak import KeycloakError, keycloak_error_message | ||||
from swh.auth.utils import gen_oidc_pkce_codes | from swh.auth.utils import gen_oidc_pkce_codes | ||||
def oidc_login_view(request: HttpRequest, redirect_uri: str, scope: str = "openid"): | def oidc_login_view(request: HttpRequest, redirect_uri: str, scope: str = "openid"): | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |