From 832bb832ce1e7c04bc26c82cc25d785bc2a4aa03 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 16 Sep 2020 17:45:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(authentication):=20=E4=BF=AE=E5=A4=8Dcas?= =?UTF-8?q?=E9=80=80=E5=87=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/api.py | 4 +++- apps/authentication/views/login.py | 11 ++++++----- apps/jumpserver/settings/auth.py | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/authentication/backends/api.py b/apps/authentication/backends/api.py index ff62677ef..4cdbbbe53 100644 --- a/apps/authentication/backends/api.py +++ b/apps/authentication/backends/api.py @@ -202,4 +202,6 @@ class SSOAuthentication(ModelBackend): """ 什么也不做呀😺 """ - pass + + def authenticate(self, request, sso_token=None, **kwargs): + pass diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 506a8cc87..100e190b6 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -17,6 +17,7 @@ from django.views.generic.base import TemplateView, RedirectView from django.views.generic.edit import FormView from django.conf import settings from django.urls import reverse_lazy +from django.contrib.auth import BACKEND_SESSION_KEY from common.const.front_urls import TICKET_DETAIL from common.utils import get_request_ip, get_object_or_none @@ -205,12 +206,12 @@ class UserLoginWaitConfirmView(TemplateView): class UserLogoutView(TemplateView): template_name = 'flash_message_standalone.html' - @staticmethod - def get_backend_logout_url(): - if settings.AUTH_OPENID: + def get_backend_logout_url(self): + backend = self.request.session.get(BACKEND_SESSION_KEY, '') + if 'OIDC' in backend: return settings.AUTH_OPENID_AUTH_LOGOUT_URL_NAME - # if settings.AUTH_CAS: - # return settings.CAS_LOGOUT_URL_NAME + elif 'CAS' in backend: + return settings.CAS_LOGOUT_URL_NAME return None def get(self, request, *args, **kwargs): diff --git a/apps/jumpserver/settings/auth.py b/apps/jumpserver/settings/auth.py index 7d8cecd28..4430aae2f 100644 --- a/apps/jumpserver/settings/auth.py +++ b/apps/jumpserver/settings/auth.py @@ -90,6 +90,7 @@ CAS_LOGIN_URL_NAME = "authentication:cas:cas-login" CAS_LOGOUT_URL_NAME = "authentication:cas:cas-logout" CAS_LOGIN_MSG = None CAS_LOGGED_MSG = None +CAS_IGNORE_REFERER = True CAS_LOGOUT_COMPLETELY = CONFIG.CAS_LOGOUT_COMPLETELY CAS_VERSION = CONFIG.CAS_VERSION CAS_ROOT_PROXIED_AS = CONFIG.CAS_ROOT_PROXIED_AS