From 3a71cc2ccac62cc3d8b74a3ecf5844a1d45fe221 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Tue, 21 Jun 2016 15:41:43 +0200 Subject: [PATCH] Add "remember my identity provider" expiry time in a setting parameter --- README.rst | 3 +++ cas_server/default_settings.py | 1 + cas_server/views.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3cf60fb..e9493e3 100644 --- a/README.rst +++ b/README.rst @@ -146,6 +146,9 @@ Federation settings: The default is ``False``. * ``CAS_FEDERATE_PROVIDERS``: A distionnary for the allowed identity providers (see the federate section below). The default is ``{}``. +* ``CAS_FEDERATE_REMEMBER_TIMEOUT``: Time after witch the cookie use for "remember my identity + provider" expire. The default is ``604800``, one week. The cookie is called + ``_remember_provider``. Tickets validity settings: diff --git a/cas_server/default_settings.py b/cas_server/default_settings.py index 2f32134..b7ee5a9 100644 --- a/cas_server/default_settings.py +++ b/cas_server/default_settings.py @@ -81,6 +81,7 @@ setting_default('CAS_SQL_PASSWORD_CHECK', 'crypt') # crypt or plain setting_default('CAS_FEDERATE', False) # A dict of "provider suffix" -> (provider CAS server url, CAS version, verbose name) setting_default('CAS_FEDERATE_PROVIDERS', {}) +setting_default('CAS_FEDERATE_REMEMBER_TIMEOUT', 604800) # one week if settings.CAS_FEDERATE: settings.CAS_AUTH_CLASS = "cas_server.auth.CASFederateAuth" diff --git a/cas_server/views.py b/cas_server/views.py index 7726eb0..0c2dc73 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -197,7 +197,7 @@ class FederateAuth(View): ) response = HttpResponseRedirect(url) if form.cleaned_data["remember"]: - max_age = 7 * 24 * 60 * 60 # one week + max_age = settings.CAS_FEDERATE_REMEMBER_TIMEOUT utils.set_cookie(response, "_remember_provider", request.POST["provider"], max_age) return response else: