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)
| 33 | // |
| 34 | // Pass nil to clear (rare; mostly useful in tests). |
| 35 | func WithCurrentUser(ctx context.Context, user *models.User) context.Context { |
| 36 | return context.WithValue(ctx, ctxCurrentUser, user) |
| 37 | } |
| 38 | |
| 39 | // WithAPITokenAuth marks ctx as authenticated via an API token, the |
| 40 | // same way TokenAuth does on the Bearer-token path. Required when |
no outgoing calls