Implements interfaces: twisted.cred.checkers.ICredentialsChecker

An extremely simple credentials checker.

This is only of use in one-off test programs or examples which don't want to focus too much on how credentials are verified.

You really don't want to use this for anything else. It is, at best, a toy. If you need a simple credentials checker for a real application, see FilePasswordDB.

Class Variable credentialInterfaces Tuple of IUsernamePassword and IUsernameHashedPassword.
Instance Variable users Mapping of usernames to passwords. (type: dict mapping bytes to bytes)
Method __init__ Initialize the in-memory database.
Method addUser Set a user's password.
Method requestAvatarId Validate credentials and produce an avatar ID.
Method _cbPasswordMatch Undocumented
credentialInterfaces =
users =
Mapping of usernames to passwords. (type: dict mapping bytes to bytes)
def __init__(self, **users):

Initialize the in-memory database.

For example:

   db = InMemoryUsernamePasswordDatabaseDontUse(
       user1=b'sesame',
       user2=b'hunter2',
   )
ParametersusersUsernames and passwords to seed the database with. Each username given as a keyword is encoded to bytes as ASCII. Passwords must be given as bytes. (type: dict of str to bytes)
def addUser(self, username, password):

Set a user's password.

ParametersusernameName of the user. (type: bytes)
passwordPassword to associate with the username. (type: bytes)
def _cbPasswordMatch(self, matched, username):
Undocumented
def requestAvatarId(self, credentials):

Validate credentials and produce an avatar ID.

Parameterscredentialssomething which implements one of the interfaces in credentialInterfaces.
Returnsa Deferred which will fire with a bytes that identifies an avatar, an empty tuple to specify an authenticated anonymous user (provided as twisted.cred.checkers.ANONYMOUS) or fail with UnauthorizedLogin. Alternatively, return the result itself.
See Alsotwisted.cred.credentials
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.