Exported context-key helpers for callers that need to synthesize an authenticated request without going through the auth middleware chain (e.g. the in-process MCP HTTP-handler dispatcher in internal/mcp/dispatch_http.go, which resolves OAuth users via the MCP middleware and then calls the API handle
(ctx context.Context, user *models.User)
| 23 | // |
| 24 | // Pass nil to clear (rare; mostly useful in tests). |
| 25 | func WithCurrentUser(ctx context.Context, user *models.User) context.Context { |
| 26 | return context.WithValue(ctx, ctxCurrentUser, user) |
| 27 | } |
| 28 | |
| 29 | // WithAPITokenAuth marks ctx as authenticated via an API token, the |
| 30 | // same way TokenAuth does on the Bearer-token path. Required when |
no outgoing calls