mirror of https://github.com/jumpserver/jumpserver
parent
82de636b5c
commit
d4037998c8
|
@ -0,0 +1,10 @@
|
||||||
|
from django_cas_ng.middleware import CASMiddleware as _CASMiddleware
|
||||||
|
from django.core.exceptions import MiddlewareNotUsed
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class CASMiddleware(_CASMiddleware):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
if not settings.AUTH_CAS:
|
||||||
|
raise MiddlewareNotUsed
|
|
@ -0,0 +1,10 @@
|
||||||
|
from jms_oidc_rp.middleware import OIDCRefreshIDTokenMiddleware as _OIDCRefreshIDTokenMiddleware
|
||||||
|
from django.core.exceptions import MiddlewareNotUsed
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class OIDCRefreshIDTokenMiddleware(_OIDCRefreshIDTokenMiddleware):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
if not settings.AUTH_OPENID:
|
||||||
|
raise MiddlewareNotUsed
|
|
@ -3,10 +3,10 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pytz
|
import pytz
|
||||||
from django.core.exceptions import MiddlewareNotUsed
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.shortcuts import HttpResponse
|
from django.shortcuts import HttpResponse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.exceptions import MiddlewareNotUsed
|
||||||
from django.http.response import HttpResponseForbidden
|
from django.http.response import HttpResponseForbidden
|
||||||
|
|
||||||
from .utils import set_current_request
|
from .utils import set_current_request
|
||||||
|
@ -45,6 +45,7 @@ class DemoMiddleware:
|
||||||
|
|
||||||
if self.DEMO_MODE_ENABLED:
|
if self.DEMO_MODE_ENABLED:
|
||||||
print("Demo mode enabled, reject unsafe method and url")
|
print("Demo mode enabled, reject unsafe method and url")
|
||||||
|
raise MiddlewareNotUsed
|
||||||
|
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
if self.DEMO_MODE_ENABLED and request.method not in self.SAFE_METHOD \
|
if self.DEMO_MODE_ENABLED and request.method not in self.SAFE_METHOD \
|
||||||
|
|
|
@ -76,13 +76,13 @@ MIDDLEWARE = [
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
'jms_oidc_rp.middleware.OIDCRefreshIDTokenMiddleware',
|
|
||||||
'django_cas_ng.middleware.CASMiddleware',
|
|
||||||
'jumpserver.middleware.TimezoneMiddleware',
|
'jumpserver.middleware.TimezoneMiddleware',
|
||||||
'jumpserver.middleware.DemoMiddleware',
|
'jumpserver.middleware.DemoMiddleware',
|
||||||
'jumpserver.middleware.RequestMiddleware',
|
'jumpserver.middleware.RequestMiddleware',
|
||||||
'jumpserver.middleware.RefererCheckMiddleware',
|
'jumpserver.middleware.RefererCheckMiddleware',
|
||||||
'orgs.middleware.OrgMiddleware',
|
'orgs.middleware.OrgMiddleware',
|
||||||
|
'authentication.backends.oidc.middleware.OIDCRefreshIDTokenMiddleware',
|
||||||
|
'authentication.backends.cas.middleware.CASMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue