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

Method requireAccountScope

internal/httpapi/scope.go:26–36  ·  view source on GitHub ↗

Scope enforcement — the hard scope ceiling (Slice 5a / design §5 / decision 10). A credential's scope, not its auth method, bounds its blast radius: - account scope: account-wide admin (agent/domain/key management, account settings). Reaches everything the owner owns. - agent scope: bound to a sing

(ctx context.Context)

Source from the content-addressed store, hash-verified

24// domain claim/verify/delete, API-key and account management) — the structural
25// guarantee that a leaked agent credential cannot widen its own authority.
26func (s *Server) requireAccountScope(ctx context.Context) (*identity.Principal, error) {
27 p, err := s.requirePrincipal(ctx)
28 if err != nil {
29 return nil, err
30 }
31 if p.Scope != identity.ScopeAccount {
32 return nil, NewError(http.StatusForbidden, "forbidden",
33 "this operation requires an account-scoped credential; agent-scoped credentials cannot perform account administration")
34 }
35 return p, nil
36}
37
38// requireAccountUser is the user-returning convenience over requireAccountScope
39// for the many account-admin handlers that only need user.ID — a clean drop-in

Callers 11

handleUpdateAgentMethod · 0.95
handleDeleteAgentMethod · 0.95
handleApproveMethod · 0.95
handleRejectMethod · 0.95
handleGetProtectionMethod · 0.95
handlePutProtectionMethod · 0.95
handleListReviewsMethod · 0.95
handleGetReviewMethod · 0.95
handleApproveReviewMethod · 0.95
handleRejectReviewMethod · 0.95
requireAccountUserMethod · 0.95

Calls 2

requirePrincipalMethod · 0.95
NewErrorFunction · 0.85

Tested by

no test coverage detected