style
This commit is contained in:
parent
8303f816df
commit
164e2f5c28
@ -30,7 +30,7 @@ def context(params):
|
|||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
def JsonResponse(request, data):
|
def json_response(request, data):
|
||||||
data["messages"] = []
|
data["messages"] = []
|
||||||
for msg in messages.get_messages(request):
|
for msg in messages.get_messages(request):
|
||||||
data["messages"].append({'message': msg.message, 'level': msg.level_tag})
|
data["messages"].append({'message': msg.message, 'level': msg.level_tag})
|
||||||
@ -146,16 +146,16 @@ def gen_saml_id():
|
|||||||
class PGTUrlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
class PGTUrlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
PARAMS = {}
|
PARAMS = {}
|
||||||
|
|
||||||
def do_GET(s):
|
def do_GET(self):
|
||||||
s.send_response(200)
|
self.send_response(200)
|
||||||
s.send_header(b"Content-type", "text/plain")
|
self.send_header(b"Content-type", "text/plain")
|
||||||
s.end_headers()
|
self.end_headers()
|
||||||
s.wfile.write(b"ok")
|
self.wfile.write(b"ok")
|
||||||
url = urlparse(s.path)
|
url = urlparse(self.path)
|
||||||
params = dict(parse_qsl(url.query))
|
params = dict(parse_qsl(url.query))
|
||||||
PGTUrlHandler.PARAMS.update(params)
|
PGTUrlHandler.PARAMS.update(params)
|
||||||
|
|
||||||
def log_message(self, template, *args):
|
def log_message(self, *args):
|
||||||
return
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -35,7 +35,7 @@ import cas_server.utils as utils
|
|||||||
import cas_server.forms as forms
|
import cas_server.forms as forms
|
||||||
import cas_server.models as models
|
import cas_server.models as models
|
||||||
|
|
||||||
from .utils import JsonResponse
|
from .utils import json_response
|
||||||
from .models import ServiceTicket, ProxyTicket, ProxyGrantingTicket
|
from .models import ServiceTicket, ProxyTicket, ProxyGrantingTicket
|
||||||
from .models import ServicePattern
|
from .models import ServicePattern
|
||||||
|
|
||||||
@ -154,13 +154,13 @@ class LogoutView(View, LogoutMixin):
|
|||||||
'url': url,
|
'url': url,
|
||||||
'session_nb': session_nb
|
'session_nb': session_nb
|
||||||
}
|
}
|
||||||
return JsonResponse(request, data)
|
return json_response(request, data)
|
||||||
else:
|
else:
|
||||||
return redirect("cas_server:login")
|
return redirect("cas_server:login")
|
||||||
else:
|
else:
|
||||||
if self.ajax:
|
if self.ajax:
|
||||||
data = {'status': 'success', 'detail': 'logout', 'session_nb': session_nb}
|
data = {'status': 'success', 'detail': 'logout', 'session_nb': session_nb}
|
||||||
return JsonResponse(request, data)
|
return json_response(request, data)
|
||||||
else:
|
else:
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@ -253,7 +253,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
raise EnvironmentError("invalid output for LoginView.process_post")
|
raise EnvironmentError("invalid output for LoginView.process_post")
|
||||||
return self.common()
|
return self.common()
|
||||||
|
|
||||||
def process_post(self, pytest=False):
|
def process_post(self):
|
||||||
if not self.check_lt():
|
if not self.check_lt():
|
||||||
values = self.request.POST.copy()
|
values = self.request.POST.copy()
|
||||||
# if not set a new LT and fail
|
# if not set a new LT and fail
|
||||||
@ -330,7 +330,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
)
|
)
|
||||||
if self.ajax:
|
if self.ajax:
|
||||||
data = {"status": "error", "detail": "confirmation needed"}
|
data = {"status": "error", "detail": "confirmation needed"}
|
||||||
return JsonResponse(self.request, data)
|
return json_response(self.request, data)
|
||||||
else:
|
else:
|
||||||
warn_form = forms.WarnForm(initial={
|
warn_form = forms.WarnForm(initial={
|
||||||
'service': self.service,
|
'service': self.service,
|
||||||
@ -357,7 +357,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
return HttpResponseRedirect(redirect_url)
|
return HttpResponseRedirect(redirect_url)
|
||||||
else:
|
else:
|
||||||
data = {"status": "success", "detail": "auth", "url": redirect_url}
|
data = {"status": "success", "detail": "auth", "url": redirect_url}
|
||||||
return JsonResponse(self.request, data)
|
return json_response(self.request, data)
|
||||||
except ServicePattern.DoesNotExist:
|
except ServicePattern.DoesNotExist:
|
||||||
error = 1
|
error = 1
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
@ -401,7 +401,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
data = {"status": "error", "detail": "auth", "code": error}
|
data = {"status": "error", "detail": "auth", "code": error}
|
||||||
return JsonResponse(self.request, data)
|
return json_response(self.request, data)
|
||||||
|
|
||||||
def authenticated(self):
|
def authenticated(self):
|
||||||
"""Processing authenticated users"""
|
"""Processing authenticated users"""
|
||||||
@ -423,7 +423,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
"detail": "login required",
|
"detail": "login required",
|
||||||
"url": utils.reverse_params("cas_server:login", params=self.request.GET)
|
"url": utils.reverse_params("cas_server:login", params=self.request.GET)
|
||||||
}
|
}
|
||||||
return JsonResponse(self.request, data)
|
return json_response(self.request, data)
|
||||||
else:
|
else:
|
||||||
return utils.redirect_params("cas_server:login", params=self.request.GET)
|
return utils.redirect_params("cas_server:login", params=self.request.GET)
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
else:
|
else:
|
||||||
if self.ajax:
|
if self.ajax:
|
||||||
data = {"status": "success", "detail": "logged"}
|
data = {"status": "success", "detail": "logged"}
|
||||||
return JsonResponse(self.request, data)
|
return json_response(self.request, data)
|
||||||
else:
|
else:
|
||||||
return render(
|
return render(
|
||||||
self.request,
|
self.request,
|
||||||
@ -476,7 +476,7 @@ class LoginView(View, LogoutMixin):
|
|||||||
"detail": "login required",
|
"detail": "login required",
|
||||||
"url": utils.reverse_params("cas_server:login", params=self.request.GET)
|
"url": utils.reverse_params("cas_server:login", params=self.request.GET)
|
||||||
}
|
}
|
||||||
return JsonResponse(self.request, data)
|
return json_response(self.request, data)
|
||||||
else:
|
else:
|
||||||
return render(
|
return render(
|
||||||
self.request,
|
self.request,
|
||||||
|
Loading…
Reference in New Issue
Block a user