Support removal of last_activity session flag

This is a simple change that will support removal of the last activiy
session field within the horizon middleware.  Whith this change, a bunch
of horizon code can be removed.

Change-Id: Ia1c9f116ce731b80fb66a191d937a5ef509c81e9
Partialy-Closes: #1450914
This commit is contained in:
eric 2015-05-04 08:47:18 -06:00
parent 0194814fc2
commit 2e804b0fa3
2 changed files with 7 additions and 2 deletions

View File

@ -13,7 +13,9 @@
""" Module defining the Django auth backend class for the Keystone API. """
import datetime
import logging
import pytz
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
@ -189,6 +191,11 @@ class KeystoneBackend(object):
if request is not None:
request.session['unscoped_token'] = unscoped_token
request.user = user
timeout = getattr(settings, "SESSION_TIMEOUT", 3600)
token_life = user.token.expires - datetime.datetime.now(pytz.utc)
session_time = min(timeout, token_life.seconds)
request.session.set_expiry(session_time)
scoped_client = keystone_client_class(session=session,
auth=scoped_auth)

View File

@ -12,7 +12,6 @@
# limitations under the License.
import logging
import re
import time
import django
from django.conf import settings
@ -124,7 +123,6 @@ def login(request, template_name=None, extra_context=None, **kwargs):
region_name = regions.get(region)
request.session['region_endpoint'] = region
request.session['region_name'] = region_name
request.session['last_activity'] = int(time.time())
return res