本文整理汇总了Python中python_digest.calculate_partial_digest函数的典型用法代码示例。如果您正苦于以下问题:Python calculate_partial_digest函数的具体用法?Python calculate_partial_digest怎么用?Python calculate_partial_digest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calculate_partial_digest函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: hello_with_digest_auth
def hello_with_digest_auth(request):
auth = request.META.get('HTTP_AUTHORIZATION', None)
if auth is None:
return _digest_unauthenticated(request)
try:
method, data = auth.split(' ', 1)
if 'digest' != method.lower():
return _digest_unauthenticated(request)
except:
raise
return _digest_unauthenticated(request)
digest_response = python_digest.parse_digest_credentials(auth)
expected = python_digest.calculate_request_digest(
request.method,
python_digest.calculate_partial_digest(digest_response.username, 'DEV', '12345'),
digest_response)
if digest_response.response != expected:
return _digest_unauthenticated(request)
return HttpResponse('Hello World')
开发者ID:XemaCobra,项目名称:Cycles,代码行数:23,代码来源:views.py
示例2: _prepare_partial_digests
def _prepare_partial_digests(user, raw_password):
realm = get_setting('DIGEST_REALM', DEFAULT_REALM)
partial_digests = []
for (confirmed, factory_method) in ((True, _confirmed_logins),
(False, _unconfirmed_logins)):
partial_digests += [(login, calculate_partial_digest(login, realm,
raw_password), confirmed)
for login in factory_method(user)]
password_hash = user.password
_postponed_partial_digests[password_hash] = partial_digests
开发者ID:dimagi,项目名称:bhoma,代码行数:11,代码来源:models.py
示例3: is_authenticated
def is_authenticated(self, request, **kwargs):
"""
Finds the user and checks their API key.
Should return either ``True`` if allowed, ``False`` if not or an
``HttpResponse`` if you need something custom.
"""
if not request.META.get('HTTP_AUTHORIZATION'):
return self._unauthorized()
try:
(auth_type, data) = request.META['HTTP_AUTHORIZATION'].split(
' ', 1)
if auth_type.lower() != 'digest':
return self._unauthorized()
except:
return self._unauthorized()
digest_response = python_digest.parse_digest_credentials(
request.META['HTTP_AUTHORIZATION'])
# FIXME: Should the nonce be per-user?
if not python_digest.validate_nonce(
digest_response.nonce, getattr(settings, 'SECRET_KEY', '')):
return self._unauthorized()
user = self.get_user(digest_response.username)
api_key = self.get_key(user)
if user is False or api_key is False:
return self._unauthorized()
expected = python_digest.calculate_request_digest(
request.method,
python_digest.calculate_partial_digest(digest_response.username,
self.realm, api_key),
digest_response)
if not digest_response.response == expected:
return self._unauthorized()
if not self.check_active(user):
return False
request.user = user
return True
开发者ID:mahendra,项目名称:django-tastypie,代码行数:47,代码来源:authentication.py
示例4: is_authenticated
def is_authenticated(self, request, **kwargs):
"""
Finds the user and checks their API key.
Should return either ``True`` if allowed, ``False`` if not or an
``HttpResponse`` if you need something custom.
"""
try:
self.get_authorization_data(request)
except ValueError:
return self._unauthorized()
digest_response = python_digest.parse_digest_credentials(request.META["HTTP_AUTHORIZATION"])
# FIXME: Should the nonce be per-user?
if not python_digest.validate_nonce(digest_response.nonce, settings.SECRET_KEY):
return self._unauthorized()
user = self.get_user(digest_response.username)
api_key = self.get_key(user)
if user is False or api_key is False:
return self._unauthorized()
expected = python_digest.calculate_request_digest(
request.method,
python_digest.calculate_partial_digest(digest_response.username, self.realm, api_key),
digest_response,
)
if not digest_response.response == expected:
return self._unauthorized()
if not self.check_active(user):
return False
request.user = user
return True
开发者ID:mattbriancon,项目名称:django-tastypie,代码行数:38,代码来源:authentication.py
示例5: setDigest
def setDigest(self, password):
self.digest = python_digest.calculate_partial_digest(
self.login.lower(), self.realm, password)
开发者ID:Education-Numerique,项目名称:api,代码行数:3,代码来源:users.py
示例6: calculate_request_digest
def calculate_request_digest(self, request, digest_response, username, api_key):
return python_digest.calculate_request_digest(
request.method,
python_digest.calculate_partial_digest(username, self.realm, api_key),
digest_response)
开发者ID:garbados,项目名称:piecrust,代码行数:5,代码来源:authentication.py
注:本文中的python_digest.calculate_partial_digest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论