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
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
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
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
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
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
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
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
def getDigestAuth(self): www_authenticate_header = python_digest.build_digest_challenge( time.time(), self.digestAuthSecret, 'API', 'opaque_ASVASASFAS2131', False) return www_authenticate_header
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