jam.jose.lists.memory¶
memory
¶
Classes:
| Name | Description |
|---|---|
MemoryList |
In-memory JWT black/white list. |
MemoryList
¶
MemoryList(
type: Literal["white", "black"],
prefix: str = "jwt_list",
logger: BaseLogger | None = None,
)
Bases: BaseJWTList
In-memory JWT black/white list.
Suitable for development, testing, or when external storage is not needed. No TTL support - tokens persist until explicitly removed.
Attributes:
| Name | Type | Description |
|---|---|---|
_storage |
dict
|
Internal storage for tokens. |
Methods:
| Name | Description |
|---|---|
add |
add single token to list |
add_many |
add multiple tokens to list |
check |
check if token exists in list |
check_many |
check multiple tokens in list |
delete |
remove token from list |
delete_many |
remove multiple tokens from list |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Literal['white', 'black']
|
Type of list. |
required |
prefix
|
str
|
Key prefix for storage. |
'jwt_list'
|
logger
|
BaseLogger | None
|
Logger instance. |
None
|
add
¶
add(token: str) -> None
Add a single token to the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
JWT token. |
required |
add_many
¶
add_many(tokens: list[str]) -> None
Add multiple tokens to the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokens
|
list[str]
|
List of JWT tokens. |
required |
check
¶
check(token: str) -> bool
Check if a token is present in the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
JWT token. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if token exists in list. |
check_many
¶
check_many(tokens: list[str]) -> dict[str, bool]
Check multiple tokens in the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokens
|
list[str]
|
List of JWT tokens. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, bool]
|
dict[str, bool]: Mapping of token to presence. |
delete
¶
delete(token: str) -> None
Remove a token from the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
JWT token. |
required |
delete_many
¶
delete_many(tokens: list[str]) -> None
Remove multiple tokens from the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokens
|
list[str]
|
List of JWT tokens. |
required |