Skip to main content

Module auth

Module auth 

Source
Expand description

JWT authentication and authorization. JWT authentication middleware and token management.

Structs§

AuthenticatedAgent
Claims
JWT claims embedded in every token.
TokenOptions
Extra claims for create_token_with.
TokenPolicy
Rules a token must meet beyond a valid signature.
TokenRequest
Request body for the token generation endpoint.
TokenVerifier
How bearer tokens are checked.

Enums§

Scope
What a token may do. Levels are ordered: each includes the ones before it.

Functions§

admin_authorized
Authorize an admin request from request headers against the configured admin key. Errors if no admin key is configured (admin endpoints are disabled) or the provided x-api-key / bearer does not match. Used by the /v1/admin endpoints.
auth_middleware
Middleware that enforces JWT auth when a secret is configured.
create_scoped_token
Create a signed JWT limited to dbs (all when None).
create_token
Create a signed JWT for the given agent.
create_token_with
Create a signed HS256 JWT with every optional claim.
generate_token
glob_match
Whether text matches pattern, where * in the pattern matches any run of characters (including none) and everything else matches itself.