sso: Fixes for regressions after adding captcha and axes

- Change sso refresh url to refresh-pubtkt since refresh was conflicting with
  captcha's image refresh url.
- Fix datetime.timedelta calculation for refresh interval. Now validity of
  ticket is 30 seconds as it was intended to be. It was wrongly set to 30 days
  earlier.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati authored and James Valleroy committed 2017-12-02 17:03:07 -05:00
1 parent 1fe9bb317a
commit 111f8f9145
5 files changed
+41 -25

No files matched your search

+7 -3
View File
@@ -20,11 +20,15 @@ URLs for the Single Sign On module.
from django.conf.urls import url
from .views import SSOLoginView, refresh
from stronghold.decorators import public
from plinth.utils import non_admin_view
urlpatterns = [
url(r'^accounts/sso/login/$', public(SSOLoginView.as_view()), name='sso-login'),
url(r'^accounts/sso/refresh/$', refresh, name='sso-refresh'),
url(r'^accounts/sso/login/$',
public(SSOLoginView.as_view()),
name='sso-login'),
url(r'^accounts/sso/refresh-pubtkt/$',
non_admin_view(refresh),
name='sso-refresh'),
]
+2 -2
View File
@@ -23,7 +23,6 @@ import os
import urllib
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import LoginView, LogoutView
from django.http import HttpResponseRedirect
@@ -112,10 +111,11 @@ class SSOLogoutView(LogoutView):
return response
@login_required
def refresh(request):
"""Simulate cookie refresh - redirect logged in user with a new cookie"""
redirect_url = request.GET.get(REDIRECT_FIELD_NAME, '')
response = HttpResponseRedirect(redirect_url)
response.delete_cookie(SSO_COOKIE_NAME)
# Redirect with cookie doesn't work with 300 series
response.status_code = 200
return set_ticket_cookie(request.user, response)