jam.ext.litestar¶
litestar
¶
Litestar integration.
Litestar docs: https://docs.litestar.dev
Modules:
| Name | Description |
|---|---|
middleware |
|
objects |
|
plugins |
|
Classes:
| Name | Description |
|---|---|
BasePlugin |
Base Litestar plugin. |
BaseUser |
Abstract user model for AuthResult. |
JWTPlugin |
JWT plugin for litestar. |
OAuth2Plugin |
OAuth2 plugin for litestar. |
PASETOPlugin |
PASETO plugin for litestar. |
SessionPlugin |
Sessions plugin for litestar. |
SimpleUser |
Simple user with payload. |
Token |
Data for Authresult. |
BasePlugin
¶
BasePlugin(
config: dict[str, Any] | str | None = None,
pointer: str = GENERIC_POINTER,
cookie_name: str | None = None,
header_name: str | None = None,
bearer: bool = False,
middleware: bool = True,
user: type[BaseUser] | None = None,
**kwargs,
)
Bases: InitPlugin
Base Litestar plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | str | None
|
Jam config as path/to/file or dict. |
None
|
pointer
|
str
|
Config pointer |
GENERIC_POINTER
|
cookie_name
|
str | None
|
Cookie name to read token |
None
|
header_name
|
str | None
|
Header name to read token |
None
|
bearer
|
bool
|
Use bearer prefix for token (e.g. "Bearer ") |
False
|
middleware
|
bool
|
Use middleware? |
True
|
user
|
type[BaseUser]
|
User for request state. See: DOCUMENTATION |
None
|
**kwargs
|
Config arguments if config=None |
{}
|
BaseUser
dataclass
¶
BaseUser()
Bases: ABC
Abstract user model for AuthResult.
Methods:
| Name | Description |
|---|---|
from_payload |
Build model from payload. |
from_payload
abstractmethod
classmethod
¶
from_payload(payload: dict[str, Any]) -> User
Build model from payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
Payload for your data. |
required |
JWTPlugin
¶
JWTPlugin(
config: dict[str, Any] | str | None = None,
pointer: str = GENERIC_POINTER,
cookie_name: str | None = None,
header_name: str | None = None,
middleware: bool = True,
bearer: bool = False,
use_list: bool = False,
user: type[BaseUser] | None = None,
**kwargs,
)
Bases: BasePlugin
JWT plugin for litestar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | str | None
|
Jam config as path/to/file or dict. |
None
|
pointer
|
str
|
Config pointer |
GENERIC_POINTER
|
cookie_name
|
str | None
|
Cookie name to read token |
None
|
header_name
|
str | None
|
Header name to read token |
None
|
middleware
|
bool
|
Use middleware? |
True
|
bearer
|
bool
|
Use bearer prefix for token (e.g. "Bearer ") |
False
|
use_list
|
bool
|
Use token list for authentication? |
False
|
user
|
type[BaseUser]
|
User for request state. See: DOCUMENTATION |
None
|
**kwargs
|
Config arguments if config=None |
{}
|
OAuth2Plugin
¶
OAuth2Plugin(
config: str | dict[str, Any] | None = None,
pointer: str = GENERIC_POINTER,
**kwargs,
)
Bases: BasePlugin
OAuth2 plugin for litestar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | str | None
|
Jam config as path/to/file or dict. |
None
|
pointer
|
str
|
Config pointer |
GENERIC_POINTER
|
**kwargs
|
Config arguments if config=None |
{}
|
PASETOPlugin
¶
PASETOPlugin(
config: dict[str, Any] | str | None = None,
pointer: str = GENERIC_POINTER,
cookie_name: str | None = None,
header_name: str | None = None,
bearer: bool = False,
middleware: bool = True,
user: type[BaseUser] | None = None,
**kwargs,
)
SessionPlugin
¶
SessionPlugin(
config: dict[str, Any] | str | None = None,
pointer: str = GENERIC_POINTER,
cookie_name: str | None = None,
header_name: str | None = None,
bearer: bool = False,
middleware: bool = True,
user: type[BaseUser] | None = None,
**kwargs,
)
SimpleUser
dataclass
¶
SimpleUser(payload: dict[str, Any])
Bases: BaseUser
Simple user with payload.
Methods:
| Name | Description |
|---|---|
from_payload |
Set payload=payload. |