def check_token(self, token, id, timestamp): """ checks the token based on id, timestamp, and sso secret """ if time.time() - float(timestamp) <= self.timeout: return token == generate_sso_token(id, timestamp) return False
def sso(request): next = request.GET.get('next', False) if next: id = request.user.id timestamp = time.time() token = generate_sso_token(id, timestamp) url = "%s?id=%s×tamp=%s&token=%s" % (next, id, timestamp, token) else: url = request.META.get('HTTP_REFERER', '') if not url: url = Site.objects.get_current().domain if not url.startswith('http://') and not url.startswith('https://'): url = 'http://' + url return HttpResponsePermanentRedirect(url)
def sso(request): next = request.GET.get("next", False) if next: id = request.user.id timestamp = time.time() token = generate_sso_token(id, timestamp) url = "%s?id=%s×tamp=%s&token=%s" % (next, id, timestamp, token) else: url = request.META.get("HTTP_REFERER", "") if not url: url = Site.objects.get_current().domain if not url.startswith("http://") and not url.startswith("https://"): url = "http://" + url return HttpResponsePermanentRedirect(url)
def sso(request): next = request.GET.get('next', False) if next: user_id, timestamp = request.user.id, time.time() token = generate_sso_token(user_id, timestamp) path, query = urllib.splitquery(next) query = "%s&id=%s×tamp=%s&token=%s&" % (query or '', user_id, timestamp, token) url = "%s?%s" % (path, query) else: url = request.META.get('HTTP_REFERER', '') if not url: url = Site.objects.get_current().domain if not url.startswith('http://') and not url.startswith('https://'): url = 'http://' + url return HttpResponsePermanentRedirect(url)