MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / requireAgentAccess

Method requireAgentAccess

internal/httpapi/scope.go:54–64  ·  view source on GitHub ↗

requireAgentAccess authenticates the caller and confirms it may act as agentID. Account-scoped credentials may act as any agent they own (ownership is still checked separately by the handler). An agent-scoped credential is pinned: it may act ONLY as the single agent it is bound to — any other agent

(ctx context.Context, agentID string)

Source from the content-addressed store, hash-verified

52// pinned: it may act ONLY as the single agent it is bound to — any other agent
53// is 403, even if the same owner owns both.
54func (s *Server) requireAgentAccess(ctx context.Context, agentID string) (*identity.Principal, error) {
55 p, err := s.requirePrincipal(ctx)
56 if err != nil {
57 return nil, err
58 }
59 if p.Scope == identity.ScopeAgent && p.AgentID != agentID {
60 return nil, NewError(http.StatusForbidden, "forbidden",
61 "this agent-scoped credential is bound to a different agent")
62 }
63 return p, nil
64}

Callers

nothing calls this directly

Calls 2

requirePrincipalMethod · 0.95
NewErrorFunction · 0.85

Tested by

no test coverage detected