rasenmaeher_api.db.logincodes

DB abstraction for storing nonces etc things needed to prevent re-use of certain tokens

Module Contents

Classes

LoginCode

Track the login codes that can be exchanged for session JWTs

Attributes

LOGGER

CODE_CHAR_COUNT

CODE_ALPHABET

CODE_MAX_ATTEMPTS

LOGGER[source]
CODE_CHAR_COUNT = 12[source]
CODE_ALPHABET[source]
CODE_MAX_ATTEMPTS = 100[source]
class LoginCode[source]

Bases: rasenmaeher_api.db.base.ORMBaseModel

Track the login codes that can be exchanged for session JWTs

__tablename__ = 'logincodes'[source]
code[source]
auditmeta[source]
used_on[source]
claims[source]
async classmethod use_code(code, auditmeta=None)[source]

Exchange the code for JWT, if it was already used raise error that is also 403, return JWT with the claims

Parameters:
  • code (str)

  • auditmeta (Optional[Dict[str, Any]])

Return type:

str

async classmethod by_code(code)[source]

Get by token

Parameters:

code (str)

Return type:

Self

async classmethod create_for_claims(claims, auditmeta=None)[source]

Create a new one with random code for the given claims

Parameters:
  • claims (Dict[str, Any])

  • auditmeta (Optional[Dict[str, Any]])

Return type:

str

async delete()[source]

Deletion of enrollments is not allowed

Return type:

bool