Skip to main content

Module auth_context

Module auth_context 

Source
Expand description

Task-local auth identity context.

Before dispatching a tools/call, resources/read, or prompts/get request, core.rs calls scope to set the current identity for that async task. Handler code retrieves it via current (or through the Auth extractor, which calls current internally).

Using a task-local means:

  • ToolHandlerFn signatures stay unchanged — no breaking API change.
  • Concurrently running handlers in different tasks each see their own identity.
  • The overhead is a single tokio::task_local! lookup per extractor use.

Functions§

current
Retrieve the current identity, or None if running outside an auth scope.
scope
Run fut with identity set as the current auth context for this task.