woodglue.apps.authn¶
Request authentication: bearer tokens and the Session cookie.
Request authentication shared by the woodglue HTTP handlers.
authenticate turns a request into a woodglue.access.Caller, reading the
application settings auth_enabled and auth_store. An app with auth disabled
serves every request as the anonymous Caller.
A request authenticates in one of these ways, tried in order:
Authorization: Bearer <token>, for the CLI, scripts, and LLM tooling.- An identity asserted by a trusted reverse proxy (see
woodglue.apps.identity_providers.TrustedProxy). The first valid assertion signs the person in and sets a Session cookie; later requests reuse that Session while the proxy keeps asserting the same person. - The
wgl_sessioncookie, set by/auth/loginfor browsers. It is HttpOnly, so no page script (including a project UI) can read it (seedocs/adr/0003).
The last two arrive automatically with any browser request, so both count as
cookie authentication, and state-changing handlers must call is_same_origin
for them.
Tokens in query strings are not accepted, since URLs end up in logs, browser
history, and Referer headers.
Authentication
dataclass
¶
The Caller of a request (None if unauthenticated) and how it authenticated.
Source code in src/woodglue/apps/authn.py
bearer_token(request)
¶
The token of an Authorization: Bearer header, or "".
Source code in src/woodglue/apps/authn.py
authenticate(handler)
¶
Who sent this request and how, trying the ways above in order.
Source code in src/woodglue/apps/authn.py
is_same_origin(request)
¶
Whether a browser request comes from this server's own pages. Uses Origin,
falling back to Referer; a request with neither is not a browser
cross-site request and passes.
Source code in src/woodglue/apps/authn.py
public_scheme(handler)
¶
The scheme browsers use to reach this server: that of auth.public_url
when set, since a proxy terminating TLS forwards plain HTTP, else the
request's own.