perf: Callback client

pull/15630/merge
feng 2025-07-22 11:39:20 +08:00 committed by ZhaoJiSen
parent 8f91cb1473
commit 75575af56f
5 changed files with 24 additions and 29 deletions

View File

@ -1,9 +1,10 @@
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
from django.views import View
from users.models import User
from authentication.views.utils import redirect_to_guard_view
from common.utils import get_logger
from users.models import User
UserModel = get_user_model()
logger = get_logger(__file__)
@ -62,3 +63,10 @@ class JMSBaseAuthBackend:
class JMSModelBackend(JMSBaseAuthBackend, ModelBackend):
pass
class BaseAuthCallbackClientView(View):
http_method_names = ['get']
def get(self, request):
return redirect_to_guard_view(query_string='next=client')

View File

@ -1,11 +1,10 @@
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect
from django.views.generic import View
from django_cas_ng.views import LoginView
__all__ = ['LoginView']
from authentication.backends.base import BaseAuthCallbackClientView
from authentication.views.utils import redirect_to_guard_view
__all__ = ['LoginView']
class CASLoginView(LoginView):
@ -16,8 +15,5 @@ class CASLoginView(LoginView):
return HttpResponseRedirect('/')
class CASCallbackClientView(View):
http_method_names = ['get', ]
def get(self, request):
return redirect_to_guard_view(query_string='next=client')
class CASCallbackClientView(BaseAuthCallbackClientView):
pass

View File

@ -5,10 +5,10 @@ from django.urls import reverse
from django.utils.http import urlencode
from django.views import View
from authentication.backends.base import BaseAuthCallbackClientView
from authentication.mixins import authenticate
from authentication.utils import build_absolute_uri
from authentication.views.mixins import FlashMessageMixin
from authentication.views.utils import redirect_to_guard_view
from common.utils import get_logger
logger = get_logger(__file__)
@ -67,11 +67,8 @@ class OAuth2AuthCallbackView(View, FlashMessageMixin):
return HttpResponseRedirect(redirect_url)
class OAuth2AuthCallbackClientView(View):
http_method_names = ['get', ]
def get(self, request):
return redirect_to_guard_view(query_string='next=client')
class OAuth2AuthCallbackClientView(BaseAuthCallbackClientView):
pass
class OAuth2EndSessionView(View):

View File

@ -29,7 +29,7 @@ from authentication.utils import build_absolute_uri_for_oidc
from authentication.views.mixins import FlashMessageMixin
from common.utils import safe_next_url
from .utils import get_logger
from ...views.utils import redirect_to_guard_view
from ..base import BaseAuthCallbackClientView
logger = get_logger(__file__)
@ -210,11 +210,8 @@ class OIDCAuthCallbackView(View, FlashMessageMixin):
return HttpResponseRedirect(settings.AUTH_OPENID_AUTHENTICATION_FAILURE_REDIRECT_URI)
class OIDCAuthCallbackClientView(View):
http_method_names = ['get', ]
def get(self, request):
return redirect_to_guard_view(query_string='next=client')
class OIDCAuthCallbackClientView(BaseAuthCallbackClientView):
pass
class OIDCEndSessionView(View):

View File

@ -19,7 +19,7 @@ from onelogin.saml2.idp_metadata_parser import (
from authentication.views.mixins import FlashMessageMixin
from common.utils import get_logger
from .settings import JmsSaml2Settings
from ...views.utils import redirect_to_guard_view
from ..base import BaseAuthCallbackClientView
logger = get_logger(__file__)
@ -300,11 +300,8 @@ class Saml2AuthCallbackView(View, PrepareRequestMixin, FlashMessageMixin):
return super().dispatch(*args, **kwargs)
class Saml2AuthCallbackClientView(View):
http_method_names = ['get', ]
def get(self, request):
return redirect_to_guard_view(query_string='next=client')
class Saml2AuthCallbackClientView(BaseAuthCallbackClientView):
pass
class Saml2AuthMetadataView(View, PrepareRequestMixin):