Commit 269e1b6c by Kálmán Viktor

dashboard: superuser accounts with shorter sessions

parent 7cef5bd6
...@@ -63,6 +63,14 @@ from .util import saml_available, DeleteViewBase, LoginView ...@@ -63,6 +63,14 @@ from .util import saml_available, DeleteViewBase, LoginView
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def set_session_expiry(request, user):
if user.is_superuser:
messages.info(request, _("You've logged in with an administrator "
"account, your session will expire when "
"the web browser is closed."))
request.session.set_expiry(0)
class NotificationView(LoginRequiredMixin, TemplateView): class NotificationView(LoginRequiredMixin, TemplateView):
def get_template_names(self): def get_template_names(self):
...@@ -119,6 +127,7 @@ class CircleLoginView(LoginView): ...@@ -119,6 +127,7 @@ class CircleLoginView(LoginView):
else: else:
response = super(CircleLoginView, self).form_valid(form) response = super(CircleLoginView, self).form_valid(form)
set_language_cookie(self.request, response) set_language_cookie(self.request, response)
set_session_expiry(self.request, user)
return response return response
...@@ -646,6 +655,8 @@ class TwoFactorLoginView(FormView): ...@@ -646,6 +655,8 @@ class TwoFactorLoginView(FormView):
login(self.request, user) login(self.request, user)
response = redirect(self.request.session['two-fa-redirect']) response = redirect(self.request.session['two-fa-redirect'])
set_language_cookie(self.request, response) set_language_cookie(self.request, response)
set_session_expiry(self.request, user)
return response return response
...@@ -732,6 +743,7 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'): ...@@ -732,6 +743,7 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
return redirect(reverse("two-factor-login")) return redirect(reverse("two-factor-login"))
else: else:
login(request, user) login(request, user)
set_session_expiry(request, user)
def _set_subject_id(session, subject_id): def _set_subject_id(session, subject_id):
session['_saml2_subject_id'] = code(subject_id) session['_saml2_subject_id'] = code(subject_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment