Documentation
¶
Index ¶
- type Agent
- type AgentToken
- type CreateAgentRequest
- type CreateAgentTokenRequest
- type CreateAgentTokenResponse
- type CreateDelegationRequest
- type Delegation
- type DelegationRevoker
- type Handler
- func (h *Handler) Create(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateDelegation(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateToken(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Get(w http.ResponseWriter, r *http.Request)
- func (h *Handler) List(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListDelegations(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListTokens(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Revoke(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RevokeDelegation(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RevokeToken(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Routes() chi.Router
- func (h *Handler) Update(w http.ResponseWriter, r *http.Request)
- type Service
- func (s *Service) Create(ctx context.Context, req CreateAgentRequest) (*Agent, error)
- func (s *Service) CreateDelegation(ctx context.Context, delegatorID, orgID string, req CreateDelegationRequest) (*Delegation, error)
- func (s *Service) CreateToken(ctx context.Context, agentID string, req CreateAgentTokenRequest) (*CreateAgentTokenResponse, error)
- func (s *Service) GetByID(ctx context.Context, id string) (*Agent, error)
- func (s *Service) List(ctx context.Context, orgIDs []string, includeAll bool, limit, offset int) ([]Agent, int64, error)
- func (s *Service) ListDelegationsByAgent(ctx context.Context, agentID string) ([]Delegation, error)
- func (s *Service) ListTokens(ctx context.Context, agentID string) ([]AgentToken, error)
- func (s *Service) Revoke(ctx context.Context, id string) error
- func (s *Service) RevokeDelegation(ctx context.Context, id, delegatorFilter string) (int64, error)
- func (s *Service) RevokeToken(ctx context.Context, agentID, tokenID string) error
- func (s *Service) Update(ctx context.Context, id string, req UpdateAgentRequest) (*Agent, error)
- func (s *Service) ValidateToken(ctx context.Context, plainToken string) (*Agent, *AgentToken, error)
- type UpdateAgentRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
OrgID *string `json:"org_id,omitempty"`
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
OwnerID *string `json:"owner_id,omitempty"`
Status string `json:"status"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type AgentToken ¶
type AgentToken struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
Name string `json:"name"`
Scopes []string `json:"scopes"`
Permissions map[string]interface{} `json:"permissions"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type CreateAgentRequest ¶
type CreateAgentRequest struct {
OrgID *string `json:"org_id"`
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Type string `json:"type" validate:"required"` // service, ai_agent, mcp_server
OwnerID *string `json:"owner_id"`
Metadata map[string]interface{} `json:"metadata"`
}
type CreateAgentTokenRequest ¶
type CreateAgentTokenResponse ¶
type CreateAgentTokenResponse struct {
AgentToken
PlainToken string `json:"token"` // returned only once at creation
}
type CreateDelegationRequest ¶
type Delegation ¶
type Delegation struct {
ID string `json:"id"`
DelegatorID string `json:"delegator_id"`
DelegateeAgentID string `json:"delegatee_agent_id"`
Scopes []string `json:"scopes"`
Constraints map[string]interface{} `json:"constraints"`
Active bool `json:"active"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
type DelegationRevoker ¶
type DelegationRevoker interface {
RevokeByDelegation(ctx context.Context, delegationID string) (int64, error)
}
DelegationRevoker cascades a delegation revocation to the live tokens minted from it. Satisfied by the revocation store; an interface keeps the agent package decoupled from it.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(service *Service, revoker DelegationRevoker) *Handler
func (*Handler) CreateDelegation ¶
func (h *Handler) CreateDelegation(w http.ResponseWriter, r *http.Request)
func (*Handler) CreateToken ¶
func (h *Handler) CreateToken(w http.ResponseWriter, r *http.Request)
func (*Handler) ListDelegations ¶
func (h *Handler) ListDelegations(w http.ResponseWriter, r *http.Request)
func (*Handler) ListTokens ¶
func (h *Handler) ListTokens(w http.ResponseWriter, r *http.Request)
func (*Handler) RevokeDelegation ¶
func (h *Handler) RevokeDelegation(w http.ResponseWriter, r *http.Request)
func (*Handler) RevokeToken ¶
func (h *Handler) RevokeToken(w http.ResponseWriter, r *http.Request)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CreateDelegation ¶
func (s *Service) CreateDelegation(ctx context.Context, delegatorID, orgID string, req CreateDelegationRequest) (*Delegation, error)
CreateDelegation records a user's delegation to an agent. orgID is the delegatee agent's organization (resolved and authorized by the caller); it is stored so the delegation can be governed and audited per tenant.
func (*Service) CreateToken ¶
func (s *Service) CreateToken(ctx context.Context, agentID string, req CreateAgentTokenRequest) (*CreateAgentTokenResponse, error)
func (*Service) List ¶
func (s *Service) List(ctx context.Context, orgIDs []string, includeAll bool, limit, offset int) ([]Agent, int64, error)
List returns agents visible to the caller. When includeAll is false (a non-superadmin), results are restricted to agents in the given organizations; org-less (global) agents are visible only to superadmins.
func (*Service) ListDelegationsByAgent ¶
func (*Service) ListTokens ¶
func (*Service) RevokeDelegation ¶
RevokeDelegation deactivates a delegation. When delegatorFilter is non-empty (a user revoking their own), the update is scoped to that delegator so one tenant cannot revoke another's delegation by guessing ids. Returns the number of rows affected so the caller can distinguish "not found / not yours" (0).
func (*Service) RevokeToken ¶
RevokeToken deletes a token, binding it to its agent so a caller authorized for one agent cannot delete another agent's token by id.
func (*Service) ValidateToken ¶
func (s *Service) ValidateToken(ctx context.Context, plainToken string) (*Agent, *AgentToken, error)
ValidateToken validates an agent token and returns the agent. Used by the agent auth middleware.