Configuration
Mojito exposes the following settings that can be configured in code or through environment variables.
API
To access the config through code you can import the config and modify any of the keys:
Config
Attributes:
| Name | Type | Description |
|---|---|---|
LOGIN_URL |
str
|
Defaults to |
MESSAGE_FLASH_COOKIE |
str
|
Name of the cookie message flash data will be stored to. |
SECRET_KEY |
str
|
Secret key used to encrypt sensitive data. |
SUPERUSER_PERMISSION_NAME |
Optional[str]
|
The name of the superuser permission. |
USER_SESSION_COOKIE |
str
|
Name of the user session cookie. |
USER_SESSION_EXPIRES |
int
|
In seconds. How long the session cookie should be allowed to exist before being replaced. |
USER_SESSION_REVALIDATE_AFTER |
int
|
In seconds. How long the session cookie should be considered valid before running revalidation |
Source code in mojito/config.py
LOGIN_URL: str = os.getenv('LOGIN_URL', '/login')
class-attribute
instance-attribute
Defaults to /login
MESSAGE_FLASH_COOKIE: str = os.getenv('MESSAGE_FLASH_COOKIE', 'mo_flash_messages')
class-attribute
instance-attribute
Name of the cookie message flash data will be stored to.
Defaults to mo_flash_messages
SECRET_KEY: str = os.getenv('SECRET_KEY', '')
class-attribute
instance-attribute
Secret key used to encrypt sensitive data.
Defaults to empty string.
SUPERUSER_PERMISSION_NAME: Optional[str] = os.getenv('SUPERUSER_PERMISSION_NAME')
class-attribute
instance-attribute
The name of the superuser permission.
When present in the Request.user.permissions, this role will bypass any permission (authorization) requirements defined for a route function. This permission does not bypass authentication.
USER_SESSION_COOKIE: str = os.getenv('USER_SESSION_COOKIE', 'mo_user_session')
class-attribute
instance-attribute
Name of the user session cookie.
Defaults to mo_user_session
USER_SESSION_EXPIRES: int = int(os.getenv('USER_SESSION_EXPIRES', 60 * 60 * 24 * 7))
class-attribute
instance-attribute
In seconds. How long the session cookie should be allowed to exist before being replaced.
Defaults to 1 week.
USER_SESSION_REVALIDATE_AFTER: int = int(os.getenv('USER_SESSION_REVALIDATE_AFTER', 0))
class-attribute
instance-attribute
In seconds. How long the session cookie should be considered valid before running revalidation on the users authentication. Within this time, as long as the cookie signature is valid, the user will be considered authenticated and all the cookie data will be used.
Defaults to 0, revalidate on every request.