def _check_basic_auth(req, hdr, credentials):
if isinstance(credentials, six.text_type): # ``token68`` form
try:
credentials = base64.b64decode(credentials)
except Exception as e:
req.complain(1210, header=hdr, error=e)
else:
# RFC 7617 section 2 requires that,
# whatever the encoding of the credentials,
# it must be ASCII-compatible, so we don't need to know it.
if b':' not in credentials:
req.complain(1211, header=hdr)
for c in six.iterbytes(credentials):
if CTL.match(six.int2byte(c)):
req.complain(1212, header=hdr, char=hex(c))
else:
req.complain(1209, header=hdr)
评论列表
文章目录