Beispiel #1
0
 def _unauthorized(self):
     response = HttpUnauthorized()
     new_uuid = uuid.uuid4()
     opaque = hmac.new(str(new_uuid), digestmod=sha1).hexdigest()
     response['WWW-Authenticate'] = python_digest.build_digest_challenge(
         time.time(), getattr(settings, 'SECRET_KEY', ''), self.realm,
         opaque, False)
     return response
Beispiel #2
0
    def build_challenge_response(self, stale=False):
        response = HttpResponse('Authorization Required',
                                content_type='text/plain', status=401)
        opaque =  ''.join([random.choice('0123456789ABCDEF') for x in range(32)])

        response["WWW-Authenticate"] = python_digest.build_digest_challenge(
            time.time(), self.secret_key, self.realm, opaque, stale)
        return response
 def _unauthorized(self):
     response = HttpUnauthorized()
     new_uuid = uuid.uuid4()
     opaque = hmac.new(str(new_uuid).encode("utf-8"), digestmod=sha1).hexdigest()
     response["WWW-Authenticate"] = python_digest.build_digest_challenge(
         timestamp=time.time(), secret=settings.SECRET_KEY, realm=self.realm, opaque=opaque, stale=False
     )
     return response
Beispiel #4
0
 def _unauthorized(self):
     response = HttpUnauthorized()
     new_uuid = uuid.uuid4()
     opaque = hmac.new(str(new_uuid), digestmod=sha1).hexdigest()
     response["WWW-Authenticate"] = python_digest.build_digest_challenge(
         time.time(), getattr(settings, "SECRET_KEY", ""), self.realm, opaque, False
     )
     return response
Beispiel #5
0
 def _unauthorized(self):
     response = HttpUnauthorized()
     new_uuid = uuid.uuid4()
     opaque = hmac.new(str(new_uuid).encode('utf-8'),
                       digestmod=sha1).hexdigest()
     response['WWW-Authenticate'] = python_digest.build_digest_challenge(
         timestamp=time.time(),
         secret=settings.SECRET_KEY,
         realm=self.realm,
         opaque=opaque,
         stale=False)
     return response
Beispiel #6
0
def _digest_unauthenticated(request):
    response = HttpResponse('', status=401)
    u = uuid.uuid4()
    o = hmac.new(str(u).encode('utf-8'), digestmod=sha1).hexdigest()
    s = python_digest.build_digest_challenge(timestamp=time.time(),
                                             secret=getattr(
                                                 settings, 'SECRET_KEY', ''),
                                             realm='DEV',
                                             opaque=o,
                                             stale=False)
    response['WWW-Authenticate'] = s

    return response
Beispiel #7
0
def _digest_unauthenticated(request):
    response = HttpResponse('', status=401)
    u = uuid.uuid4()
    o = hmac.new(str(u).encode('utf-8'), digestmod=sha1).hexdigest()
    s = python_digest.build_digest_challenge(
            timestamp=time.time(),
            secret=getattr(settings, 'SECRET_KEY', ''),
            realm='DEV',
            opaque=o,
            stale=False
        )
    response['WWW-Authenticate'] = s
    
    return response    
Beispiel #8
0
 def build_challenge_response(self, stale=False):
     """
     If not auth show digest authentification form
     """
     opaque = ''.join([random.choice('0123456789ABCDEF')
                      for x in range(32)])  # IGNORE:W0612 @UnusedVariable
     response = Response()
     response.status = 401
     response.headerlist.append(('WWW-Authenticate',
                                 python_digest.build_digest_challenge(
                                     time.time(),
                                     self.secret_key,
                                     self.realm, opaque, stale)))
     return response
Beispiel #9
0
    def __setAuthenticate(self, stale=False):
        random.seed()
        opaque = str(random.getrandbits(128))

        www_authenticate_header = python_digest.build_digest_challenge(
            time.time(),
            self.__cfg.get('nonce_secret'),
            Config().get('realm'),
            opaque,
            stale
        )

        #grab nonce and calculate reqId
        m = re.search('nonce="([a-z-A-Z0-9.:]+)"', www_authenticate_header)
        sessId = hashlib.sha1(m.group(1).encode('utf-8')).hexdigest()

        self.__storeSession(sessId, opaque, 0)

        self.__resp.headers['WWW-Authenticate'] = www_authenticate_header
Beispiel #10
0
 def getDigestAuth(self):
     www_authenticate_header = python_digest.build_digest_challenge(
         time.time(), self.digestAuthSecret, 'API', 'opaque_ASVASASFAS2131',
         False)
     return www_authenticate_header
Beispiel #11
0
 def _unauthorized(self):
     response = HttpUnauthorized()
     new_uuid = uuid.uuid4()
     opaque = hmac.new(str(new_uuid), digestmod=sha1).hexdigest()
     response['WWW-Authenticate'] = python_digest.build_digest_challenge(time.time(), self.secret_key, self.realm, opaque, False)
     return response