throttle - backend¶
BaseBackend
¶
Bases: ABC
Abstract base class for authentication backends. All authentication backends must inherit from this class.
authenticate
abstractmethod
async
¶
Performs authentication using the request scope.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Payload
|
Authentication data or None
TYPE:
|
Source code in webtool/auth/backend.py
BaseAnnoBackend
¶
Bases: BaseBackend
Base backend class for handling anonymous users The implementation of BaseAnnoBackend should include a function to identify unauthenticated users
IPBackend
¶
Bases: BaseBackend
Authentication backend based on IP address
authenticate
async
¶
Performs authentication using the client's IP address.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuthData
|
IP address or None
TYPE:
|
Source code in webtool/auth/backend.py
SessionBackend
¶
Bases: BaseBackend
Session-based authentication backend
PARAMETER | DESCRIPTION |
---|---|
session_name
|
Name of the session cookie
TYPE:
|
Source code in webtool/auth/backend.py
get_session
¶
Extracts session information from request scope.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str | None
|
Session string or None |
Source code in webtool/auth/backend.py
authenticate
async
¶
Performs authentication using session information.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuthData
|
session
TYPE:
|
Source code in webtool/auth/backend.py
AnnoSessionBackend
¶
AnnoSessionBackend(
session_name,
max_age=1209600,
secure=True,
same_site="lax",
session_factory=uuid4,
)
Bases: SessionBackend
, BaseAnnoBackend
Session backend for anonymous users. Automatically creates and assigns new sessions.
PARAMETER | DESCRIPTION |
---|---|
session_name
|
Name of the session cookie
TYPE:
|
max_age
|
Session expiration time (seconds)
TYPE:
|
secure
|
HTTPS only flag
TYPE:
|
same_site
|
SameSite cookie policy: lax, strict, none
TYPE:
|
session_factory
|
Session ID generation function
TYPE:
|
Source code in webtool/auth/backend.py
security_flags
instance-attribute
¶
authenticate
async
¶
Performs authentication using session information.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuthData
|
session
TYPE:
|
Source code in webtool/auth/backend.py
get_session
¶
Extracts session information from request scope.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str | None
|
Session string or None |
Source code in webtool/auth/backend.py
verify_identity
async
¶
Assigns new session to anonymous users and redirects.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
send
|
ASGI send function
TYPE:
|
Source code in webtool/auth/backend.py
JWTBackend
¶
Bases: BaseBackend
JWT (JSON Web Token) based authentication backend
PARAMETER | DESCRIPTION |
---|---|
jwt_service
|
Service object for JWT processing
TYPE:
|
Source code in webtool/auth/backend.py
validate_token
async
¶
Validates JWT.
PARAMETER | DESCRIPTION |
---|---|
token
|
JWT string
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Payload
|
Validated token data or None |
Source code in webtool/auth/backend.py
authenticate
async
¶
Performs authentication using JWT.
PARAMETER | DESCRIPTION |
---|---|
scope
|
ASGI request scope
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuthData
|
Validated token data or None |
Source code in webtool/auth/backend.py
KeycloakBackend
¶
Bases: BaseBackend