OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
twisted
/
web
/
_auth
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/31/2022 06:22:39 AM
rwxr-xr-x
📄
__init__.py
190 bytes
09/08/2017 10:38:36 AM
rw-r--r--
📁
__pycache__
-
03/31/2022 06:22:40 AM
rwxr-xr-x
📄
basic.py
1.65 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
digest.py
1.71 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
wrapper.py
8.31 KB
09/08/2017 10:38:36 AM
rw-r--r--
Editing: basic.py
Close
# -*- test-case-name: twisted.web.test.test_httpauth -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ HTTP BASIC authentication. @see: U{http://tools.ietf.org/html/rfc1945} @see: U{http://tools.ietf.org/html/rfc2616} @see: U{http://tools.ietf.org/html/rfc2617} """ from __future__ import division, absolute_import import binascii from zope.interface import implementer from twisted.cred import credentials, error from twisted.web.iweb import ICredentialFactory @implementer(ICredentialFactory) class BasicCredentialFactory(object): """ Credential Factory for HTTP Basic Authentication @type authenticationRealm: L{bytes} @ivar authenticationRealm: The HTTP authentication realm which will be issued in challenges. """ scheme = b'basic' def __init__(self, authenticationRealm): self.authenticationRealm = authenticationRealm def getChallenge(self, request): """ Return a challenge including the HTTP authentication realm with which this factory was created. """ return {'realm': self.authenticationRealm} def decode(self, response, request): """ Parse the base64-encoded, colon-separated username and password into a L{credentials.UsernamePassword} instance. """ try: creds = binascii.a2b_base64(response + b'===') except binascii.Error: raise error.LoginFailed('Invalid credentials') creds = creds.split(b':', 1) if len(creds) == 2: return credentials.UsernamePassword(*creds) else: raise error.LoginFailed('Invalid credentials')