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)
| 24 | // domain claim/verify/delete, API-key and account management) — the structural |
| 25 | // guarantee that a leaked agent credential cannot widen its own authority. |
| 26 | func (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 |
no test coverage detected