Documentation
¶
Overview ¶
Package agentshare manages owner-authorized per-agent share lists.
Index ¶
- Variables
- type AccountRepository
- type AuditRepository
- type ManageInput
- type Repository
- type Service
- func (s *Service) Grant(ctx context.Context, input ManageInput) (*models.AgentShareGrant, error)
- func (s *Service) IsActive(ctx context.Context, agentUsername, granteeUsername string) (bool, error)
- func (s *Service) ListByAgent(ctx context.Context, agentUsername, actorUsername string, actorIsAdmin bool) ([]*models.AgentShareGrant, error)
- func (s *Service) ListSharedWith(ctx context.Context, granteeUsername string) ([]*models.AgentShareGrant, error)
- func (s *Service) Revoke(ctx context.Context, input ManageInput) (*models.AgentShareGrant, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotAuthorized means the caller is neither the agent owner nor an administrator. ErrNotAuthorized = errors.New("not authorized to manage agent share list") // ErrAgentNotFound means the requested local agent is unavailable. ErrAgentNotFound = errors.New("agent not found") // ErrGranteeNotFound means no local account exists for the grantee username. ErrGranteeNotFound = errors.New("grantee account not found") // ErrInvalidGrantee means the grantee is not a local Lesser username. ErrInvalidGrantee = errors.New("grantee must be a local Lesser username") // ErrSelfGrant means an owner or acting administrator tried to share with themselves. ErrSelfGrant = errors.New("cannot grant agent access to yourself or the agent owner") // ErrAgentSelfGrant means an agent was named as its own grantee. ErrAgentSelfGrant = errors.New("cannot grant agent access to the agent itself") // ErrGrantNotFound means no persisted grant exists to revoke. ErrGrantNotFound = errors.New("agent share grant not found") )
Functions ¶
This section is empty.
Types ¶
type AccountRepository ¶
type AccountRepository interface {
GetAccount(context.Context, string) (*storage.Account, error)
GetUser(context.Context, string) (*storage.User, error)
}
AccountRepository resolves local agents and local grantees.
type AuditRepository ¶
type AuditRepository interface {
StoreAuditEvent(context.Context, string, string, string, string, string, string, string, string, string, bool, string, map[string]interface{}) error
}
AuditRepository records the grant/revoke activity visible in agent activity logs.
type ManageInput ¶
type ManageInput struct {
AgentUsername string
GranteeUsername string
ActorUsername string
ActorIsAdmin bool
}
ManageInput identifies an agent share-list mutation and its authenticated actor.
type Repository ¶
type Repository interface {
}
Repository is the storage contract required by Service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages per-agent share grants without minting credentials or changing sessions.
func NewService ¶
func NewService(repo Repository, accounts AccountRepository, audit AuditRepository, actorURL func(string) string, logger *zap.Logger) *Service
NewService creates an agent share service.
func (*Service) Grant ¶
func (s *Service) Grant(ctx context.Context, input ManageInput) (*models.AgentShareGrant, error)
Grant creates or refreshes one owner-authorized share grant.
func (*Service) IsActive ¶
func (s *Service) IsActive(ctx context.Context, agentUsername, granteeUsername string) (bool, error)
IsActive performs the repository's uncached direct membership check.
func (*Service) ListByAgent ¶
func (s *Service) ListByAgent(ctx context.Context, agentUsername, actorUsername string, actorIsAdmin bool) ([]*models.AgentShareGrant, error)
ListByAgent returns an owner/admin view including revoked audit history.
func (*Service) ListSharedWith ¶
func (s *Service) ListSharedWith(ctx context.Context, granteeUsername string) ([]*models.AgentShareGrant, error)
ListSharedWith returns active agents shared with the authenticated local account.
func (*Service) Revoke ¶
func (s *Service) Revoke(ctx context.Context, input ManageInput) (*models.AgentShareGrant, error)
Revoke immediately marks one grant inactive and removes it from discovery.