Extracts a bearer token from the Authorization header and assigns current_scope.
Auto-detects token type by format:
- Tokens starting with the configured API token prefix -> opaque API token (DB lookup)
- Tokens starting with "eyJ" and JWT enabled -> JWT (signature verification)
- All other tokens -> opaque API token path (DB lookup)
Assigns current_scope with token_scopes, auth_method, and token_id fields.
Skips if current_scope is already assigned.
Options
:config- A%Sigra.Config{}struct (required):scope_module- The module to call.new/1on (the host app's Scope module)
Example
plug Sigra.Plug.FetchBearer,
config: @sigra_config,
scope_module: MyApp.Auth.Scope
Summary
Functions
Extract bearer token from Authorization header and assign current_scope.
Initialize the plug with the given options.