def _check_has_timed_timeout(self, request): """Check for session timeout and return timestamp.""" has_timed_out = False # Activate timezone handling tz = request.session.get('django_timezone') if tz: timezone.activate(tz) try: timeout = settings.SESSION_TIMEOUT except AttributeError: timeout = 1800 last_activity = request.session.get('last_activity', None) timestamp = int(time.time()) if ( hasattr(request, "user") and hasattr(request.user, "token") and not auth_utils.is_token_valid(request.user.token) ): # The user was logged in, but his keystone token expired. has_timed_out = True if isinstance(last_activity, int): if (timestamp - last_activity) > timeout: has_timed_out = True if has_timed_out: request.session.pop('last_activity') return (has_timed_out, timestamp)
def _check_auth_expiry(self, auth_ref, margin=None): if not utils.is_token_valid(auth_ref, margin): msg = _("The authentication token issued by the Identity service " "has expired.") LOG.warning("The authentication token issued by the Identity " "service appears to have expired before it was " "issued. This may indicate a problem with either your " "server or client configuration.") raise exceptions.KeystoneTokenExpiredException(msg) return True
def check_auth_expiry(self, auth_ref, margin=None): if not utils.is_token_valid(auth_ref, margin): msg = _("The authentication token issued by the Identity service " "has expired.") LOG.warning("The authentication token issued by the Identity " "service appears to have expired before it was " "issued. This may indicate a problem with either your " "server or client configuration.") raise exceptions.KeystoneAuthException(msg) return True
def is_authenticated(self, margin=None): """Checks for a valid authentication. :param margin: A security time margin in seconds before end of authentication. Will return ``False`` if authentication ends in less than ``margin`` seconds of time. A default margin can be set by the TOKEN_TIMEOUT_MARGIN in the django settings. """ return (self.token is not None and utils.is_token_valid(self.token, margin))
def is_token_expired(self, margin=None): """Determine if the token is expired. Returns ``True`` if the token is expired, ``False`` if not, and ``None`` if there is no token set. :param margin: A security time margin in seconds before real expiration. Will return ``True`` if the token expires in less than ``margin`` seconds of time. A default margin can be set by the TOKEN_TIMEOUT_MARGIN in the django settings. """ if self.token is None: return None return not utils.is_token_valid(self.token, margin)
def is_authenticated(self): """Checks for a valid authentication.""" if (self.token is not None and utils.is_token_valid(self.token)): return deprecation.CallableTrue else: return deprecation.CallableFalse
def is_authenticated(self): """Checks for a valid authentication.""" return self.token is not None and utils.is_token_valid(self.token)