Authentication Mixin
Server-side authentication via BasicAuthMixin.
BasicAuthMixin
Authentication mixin for AsgiServer.
Provides server.authenticate(scope) as the single extension point for auth. The whole backend logic (bearer, basic, JWT) lives in authentication.AuthCore; this mixin binds it to the server class and adds the local identity source.
When the server carries a user_store (server(users=True)), both
credential paths consult the store FIRST, then fall back to the config basic
dict (bootstrap/legacy compat). The store’s tags enter the auth result exactly
where the config tags do, so /_server/login and Basic-auth requests both work
with store users unchanged. AuthCore itself stays config-only: it is also used
standalone by AuthMiddleware, which has no store.
- Usage:
- class MyServer(BasicAuthMixin, RoutingClass):
- def __init__(self):
BasicAuthMixin.__init__(self, bearer={…}, basic={…}) …
# In middleware or dispatcher: auth = server.authenticate(scope)
- class genro_asgi.server.auth_mixin.BasicAuthMixin(**entries)[source]
Bases:
AuthCoreServer-side auth mixin: bearer, basic, JWT, plus the local user store.
Backend configuration and verification are inherited from AuthCore. The two
basicpaths (the login helper and the Authorization-header dispatch) are extended here so auser_storeuser authenticates as well, checked before the config dict.