本文整理汇总了Python中sentry.utils.auth.parse_auth_header函数的典型用法代码示例。如果您正苦于以下问题:Python parse_auth_header函数的具体用法?Python parse_auth_header怎么用?Python parse_auth_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_auth_header函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: extract_auth_vars
def extract_auth_vars(request):
if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'):
return parse_auth_header(request.META['HTTP_X_SENTRY_AUTH'])
elif request.META.get('HTTP_AUTHORIZATION', '').startswith('Sentry'):
return parse_auth_header(request.META['HTTP_AUTHORIZATION'])
else:
return request.GET
开发者ID:flyankur,项目名称:sentry,代码行数:7,代码来源:coreapi.py
示例2: auth_from_request
def auth_from_request(self, request):
result = {
k: request.GET[k]
for k in six.iterkeys(request.GET)
if k[:7] == 'sentry_'
}
if request.META.get('HTTP_X_SENTRY_AUTH', '')[:7].lower() == 'sentry ':
if result:
raise SuspiciousOperation('Multiple authentication payloads were detected.')
result = parse_auth_header(request.META['HTTP_X_SENTRY_AUTH'])
elif request.META.get('HTTP_AUTHORIZATION', '')[:7].lower() == 'sentry ':
if result:
raise SuspiciousOperation('Multiple authentication payloads were detected.')
result = parse_auth_header(request.META['HTTP_AUTHORIZATION'])
if not result:
raise APIUnauthorized('Unable to find authentication information')
origin = self.origin_from_request(request)
auth = Auth(result, is_public=bool(origin))
# default client to user agent
if not auth.client:
auth.client = request.META.get('HTTP_USER_AGENT')
return auth
开发者ID:duanshuaimin,项目名称:sentry,代码行数:25,代码来源:coreapi.py
示例3: extract_auth_vars
def extract_auth_vars(request):
if request.META.get("HTTP_X_SENTRY_AUTH", "").startswith("Sentry"):
return parse_auth_header(request.META["HTTP_X_SENTRY_AUTH"])
elif request.META.get("HTTP_AUTHORIZATION", "").startswith("Sentry"):
return parse_auth_header(request.META["HTTP_AUTHORIZATION"])
else:
return dict((k, request.GET[k]) for k in request.GET.iterkeys() if k.startswith("sentry_"))
开发者ID:achun2080,项目名称:sentry,代码行数:7,代码来源:coreapi.py
示例4: extract_auth_vars
def extract_auth_vars(request):
if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'):
# Auth version 3.0 (same as 2.0, diff header)
return parse_auth_header(request.META['HTTP_X_SENTRY_AUTH'])
elif request.META.get('HTTP_AUTHORIZATION', '').startswith('Sentry'):
# Auth version 2.0
return parse_auth_header(request.META['HTTP_AUTHORIZATION'])
else:
return None
开发者ID:Crowdbooster,项目名称:sentry,代码行数:9,代码来源:coreapi.py
示例5: extract_auth_vars
def extract_auth_vars(request):
if request.META.get("HTTP_X_SENTRY_AUTH", "").startswith("Sentry"):
# Auth version 3.0 (same as 2.0, diff header)
return parse_auth_header(request.META["HTTP_X_SENTRY_AUTH"])
elif request.META.get("HTTP_AUTHORIZATION", "").startswith("Sentry"):
# Auth version 2.0
return parse_auth_header(request.META["HTTP_AUTHORIZATION"])
else:
return None
开发者ID:nikitka,项目名称:sentry,代码行数:9,代码来源:coreapi.py
示例6: extract_auth_vars
def extract_auth_vars(request):
if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'):
return parse_auth_header(request.META['HTTP_X_SENTRY_AUTH'])
elif request.META.get('HTTP_AUTHORIZATION', '').startswith('Sentry'):
return parse_auth_header(request.META['HTTP_AUTHORIZATION'])
else:
return dict(
(k, request.GET[k])
for k in request.GET.iterkeys()
if k.startswith('sentry_')
)
开发者ID:fab10m,项目名称:sentry,代码行数:11,代码来源:coreapi.py
示例7: handle
def handle(self, data, address):
from sentry.utils.auth import parse_auth_header
from sentry.coreapi import (project_from_auth_vars, decode_and_decompress_data, safely_load_json_string,
validate_data, insert_data_to_database, APIError)
try:
try:
auth_header, data = data.split("\n\n", 1)
except ValueError:
raise APIError("missing auth header")
project = project_from_auth_vars(parse_auth_header(auth_header), data)
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data)
except InvalidTimestamp:
# Log the error, remove the timestamp, and revalidate
logger.error('Client %r passed an invalid value for timestamp %r' % (
data['timestamp'],
client or '<unknown client>',
))
del data['timestamp']
validate_data(project, data)
return insert_data_to_database(data)
except APIError, error:
logger.error('bad message from %s: %s' % (address, error.msg))
return error
开发者ID:lboaretto,项目名称:sentry,代码行数:30,代码来源:udp.py
示例8: handle_sentry
def handle_sentry(data, address):
from sentry.exceptions import InvalidData
from sentry.coreapi import project_from_auth_vars, decode_and_decompress_data, \
safely_load_json_string, validate_data, insert_data_to_database, APIError
from sentry.utils.auth import parse_auth_header
try:
try:
auth_header, data = data.split('\n\n', 1)
except ValueError:
raise APIError('missing auth header')
auth_vars = parse_auth_header(auth_header)
project = project_from_auth_vars(auth_vars, data)
client = auth_vars.get('sentry_client')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, client)
except InvalidData, e:
raise APIError(unicode(e))
return insert_data_to_database(data)
开发者ID:eventbrite,项目名称:django-sentry,代码行数:27,代码来源:udp.py
示例9: auth_from_request
def auth_from_request(self, request):
if request.META.get("HTTP_X_SENTRY_AUTH", "").startswith("Sentry"):
result = parse_auth_header(request.META["HTTP_X_SENTRY_AUTH"])
elif request.META.get("HTTP_AUTHORIZATION", "").startswith("Sentry"):
result = parse_auth_header(request.META["HTTP_AUTHORIZATION"])
else:
result = dict((k, request.GET[k]) for k in request.GET.iterkeys() if k.startswith("sentry_"))
if not result:
raise APIUnauthorized("Unable to find authentication information")
origin = self.origin_from_request(request)
auth = Auth(result, is_public=bool(origin))
# default client to user agent
if not auth.client:
auth.client = request.META.get("HTTP_USER_AGENT")
return auth
开发者ID:wlcx,项目名称:sentry,代码行数:16,代码来源:coreapi.py
示例10: handle_sentry
def handle_sentry(data, address):
from sentry.coreapi import (
project_from_auth_vars,
decode_and_decompress_data,
safely_load_json_string,
validate_data,
insert_data_to_database,
APIError,
APIForbidden,
)
from sentry.models import Group
from sentry.exceptions import InvalidData
from sentry.plugins import plugins
from sentry.utils.auth import parse_auth_header
try:
try:
auth_header, data = data.split("\n\n", 1)
except ValueError:
raise APIError("missing auth header")
try:
auth_vars = parse_auth_header(auth_header)
except (ValueError, IndexError):
raise APIError("invalid auth header")
project, user = project_from_auth_vars(auth_vars)
result = plugins.first("has_perm", user, "create_event", project)
if result is False:
raise APIForbidden("Creation of this event was blocked")
client = auth_vars.get("sentry_client")
if not data.startswith("{"):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, client)
except InvalidData, e:
raise APIError(u"Invalid data: %s (%s)" % (unicode(e), type(e)))
Group.objects.normalize_event_data(data)
return insert_data_to_database(data)
开发者ID:beyondtime,项目名称:sentry,代码行数:46,代码来源:udp.py
示例11: handle
def handle(self, data, address):
from sentry.utils.auth import parse_auth_header
from sentry.coreapi import (project_from_auth_vars, decode_and_decompress_data, safely_load_json_string,
ensure_valid_project_id, insert_data_to_database, APIError)
try:
try:
auth_header, data = data.split("\n\n", 1)
except ValueError:
raise APIError("missing auth header")
project = project_from_auth_vars(parse_auth_header(auth_header), data)
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
ensure_valid_project_id(project, data)
return insert_data_to_database(data)
except APIError, error:
logger.error('bad message from %s: %s' % (address, error.msg))
return error
开发者ID:Kronuz,项目名称:django-sentry,代码行数:21,代码来源:udp.py
示例12: handle_sentry
def handle_sentry(data, address):
from sentry.coreapi import project_from_auth_vars, decode_and_decompress_data, \
safely_load_json_string, validate_data, insert_data_to_database, APIError, \
APIForbidden
from sentry.exceptions import InvalidData
from sentry.plugins import plugins
from sentry.utils.auth import parse_auth_header
try:
try:
auth_header, data = data.split('\n\n', 1)
except ValueError:
raise APIError('missing auth header')
try:
auth_vars = parse_auth_header(auth_header)
except (ValueError, IndexError):
raise APIError('invalid auth header')
project, user = project_from_auth_vars(auth_vars)
result = plugins.first('has_perm', user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
client = auth_vars.get('sentry_client')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, client)
except InvalidData, e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
return insert_data_to_database(data)
开发者ID:DouweM,项目名称:sentry,代码行数:37,代码来源:udp.py
注:本文中的sentry.utils.auth.parse_auth_header函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论