本文整理汇总了Python中python_digest.build_digest_challenge函数的典型用法代码示例。如果您正苦于以下问题:Python build_digest_challenge函数的具体用法?Python build_digest_challenge怎么用?Python build_digest_challenge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_digest_challenge函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _unauthorized
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
示例2: build_challenge_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
示例3: _unauthorized
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
示例4: _digest_unauthenticated
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
示例5: build_challenge_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
示例6: __setAuthenticate
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
示例7: _unauthorized
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