Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
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&timestamp=%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)
Exemple #4
0
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&timestamp=%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)
Exemple #5
0
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&timestamp=%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)