pysasl.identity Package

class pysasl.identity.Identity(*args, **kwargs)[source]

Represents an server-side identity that credentials will be authenticated against.

abstract property authcid: str

The authentication identity, e.g. a login username.

abstract compare_authcid(authcid)[source]

Compare the identity’s authcid with the given authcid.

Parameters:

authcid (str) – The authentication identity string value.

Return type:

bool

abstract compare_secret(secret)[source]

Compare the identity’s secret with the given secret. The comparison must account for things like hashing or token algorithms.

Parameters:

secret (str) – The authentication secret string value.

Return type:

bool

abstract get_clear_secret()[source]

Return the cleartext secret string if it is available.

Return type:

str | None

class pysasl.identity.ClearIdentity(authcid, secret, *, prepare=<function saslprep>)[source]

An Identity that stores the secret string in cleartext.

Parameters:
  • authcid (str) – The authentication identity, e.g. a login username.

  • secret (str) – The authentication secret string value, e.g. a login password.

  • prepare (Callable[[str], str]) – The string preparation function.

property authcid: str

The authentication identity, e.g. a login username.

compare_authcid(authcid)[source]

Compare the identity’s authcid with the given authcid.

Parameters:

authcid (str) – The authentication identity string value.

Return type:

bool

compare_secret(secret)[source]

Compare the identity’s secret with the given secret. The comparison must account for things like hashing or token algorithms.

Parameters:

secret (str) – The authentication secret string value.

Return type:

bool

get_clear_secret()[source]

Return the cleartext secret string.

Return type:

str

class pysasl.identity.HashedIdentity(authcid, digest, *, hash, prepare=<function saslprep>)[source]

An Identity where the secret has been hashed for storage.

Parameters:
  • authcid (str) – The authentication identity, e.g. a login username.

  • digest (str) – The hashed secret string, using hash.

  • hash (HashInterface) – The hash algorithm to use to verify the secret.

  • prepare (Callable[[str], str]) – The string preparation function.

property authcid: str

The authentication identity, e.g. a login username.

classmethod create(authcid, secret, *, hash, prepare=<function saslprep>)[source]

Prepare and hash the given secret, returning a HashedIdentity.

Parameters:
  • authcid (str) – The authentication identity, e.g. a login username.

  • secret (str) – The cleartext secret string.

  • hash (HashInterface) – The hash algorithm to use to verify the secret.

  • prepare (Callable[[str], str]) – The string preparation function.

Return type:

Self

property digest: str

The hashed secret string, using hash.

property hash: HashInterface

The hash implementation to use to verify the secret.

compare_authcid(authcid)[source]

Compare the identity’s authcid with the given authcid.

Parameters:

authcid (str) – The authentication identity string value.

Return type:

bool

compare_secret(secret)[source]

Compare the identity’s secret with the given secret. The comparison must account for things like hashing or token algorithms.

Parameters:

secret (str) – The authentication secret string value.

Return type:

bool

get_clear_secret()[source]

Return the cleartext secret string, only if hash is Cleartext.

Return type:

str | None