Documentation
¶
Index ¶
- Constants
- Variables
- func AdminOperationsUserSearch(filter OperationsFilter) string
- func AuditTimeWhere(alias string, filter OperationsFilter, args *[]any) string
- func GenerateAgentID() (string, error)
- func NewAgentID(now time.Time, entropy []byte) (string, error)
- func NormalizeAgentName(name string) (string, string, error)
- func NormalizeTeamSlug(raw string) string
- func UserActivityWhere(filter OperationsFilter) (string, []any)
- func ValidateTeamNamespace(namespace string) error
- func ValidateTeamSlug(slug string) error
- type APIKeySummary
- type Agent
- type AgentListFilter
- type AgentPage
- type AuditEvent
- type AuditLog
- type ImageActivity
- type OperationsFilter
- type OperationsFilterResponse
- type OperationsSnapshot
- type Principal
- type PrincipalTeam
- type Store
- func (s *Store) AuthenticateJWT(token string) (Principal, bool)
- func (s *Store) AuthenticatePassword(ctx context.Context, email, password string) (User, bool, error)
- func (s *Store) AuthenticateRegistryCredential(ctx context.Context, username, password string) (Principal, bool, error)
- func (s *Store) AuthenticateUserAPIKey(ctx context.Context, rawKey string) (Principal, bool, error)
- func (s *Store) Close() error
- func (s *Store) CreateAccessToken(u User, ttl time.Duration) (string, error)
- func (s *Store) CreateAgent(ctx context.Context, teamSlug, name, createdBy string) (Agent, error)
- func (s *Store) CreatePasswordUser(ctx context.Context, email, password string, role string) (User, error)
- func (s *Store) CreateRegistryCredential(ctx context.Context, userID, name string) (APIKeySummary, string, error)
- func (s *Store) CreateTeam(ctx context.Context, slug, name, createdByUserID string) (Team, error)
- func (s *Store) CreateUserAPIKey(ctx context.Context, userID, name string) (APIKeySummary, string, error)
- func (s *Store) DeleteTeamBySlug(ctx context.Context, slug string) error
- func (s *Store) DeleteTeamMembership(ctx context.Context, teamSlug, userID string) error
- func (s *Store) DeleteUser(ctx context.Context, userID string) error
- func (s *Store) EnsureOIDCUser(ctx context.Context, provider, subject, email, role string) (User, error)
- func (s *Store) EnsurePasswordUser(ctx context.Context, email, password string, role string) (User, error)
- func (s *Store) EnsureTeamPasswordUser(ctx context.Context, email, password string) (User, error)
- func (s *Store) GetAgent(ctx context.Context, id string) (Agent, bool, error)
- func (s *Store) GetNamespace(ctx context.Context, namespace string) (map[string]any, bool, error)
- func (s *Store) GetTeamBySlug(ctx context.Context, slug string) (Team, bool, error)
- func (s *Store) GetUser(ctx context.Context, userID string) (User, bool, error)
- func (s *Store) ListAgents(ctx context.Context, filter AgentListFilter) (AgentPage, error)
- func (s *Store) ListAuditLogs(ctx context.Context, filter OperationsFilter) ([]AuditLog, error)
- func (s *Store) ListImageActivity(ctx context.Context, filter OperationsFilter) ([]ImageActivity, error)
- func (s *Store) ListNamespaces(ctx context.Context) ([]map[string]any, error)
- func (s *Store) ListRegistryCredentials(ctx context.Context, userID string) ([]APIKeySummary, error)
- func (s *Store) ListTeamMemberships(ctx context.Context, teamSlug string) ([]TeamMembership, error)
- func (s *Store) ListTeams(ctx context.Context) ([]Team, error)
- func (s *Store) ListUserAPIKeys(ctx context.Context, userID string) ([]APIKeySummary, error)
- func (s *Store) ListUserActivity(ctx context.Context, filter OperationsFilter) ([]UserActivity, error)
- func (s *Store) ListUserTeams(ctx context.Context, userID string) ([]TeamMembership, error)
- func (s *Store) OperationsSnapshot(ctx context.Context, filter OperationsFilter) (OperationsSnapshot, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PrincipalForUserID(ctx context.Context, userID string) (Principal, error)
- func (s *Store) RenameAgent(ctx context.Context, id, name string) (Agent, error)
- func (s *Store) ResolveTeamIDs(ctx context.Context, ids []string) (map[string]string, error)
- func (s *Store) ResolveUserIDs(ctx context.Context, ids []string) (map[string]string, error)
- func (s *Store) RevokeRegistryCredential(ctx context.Context, userID, id string) (APIKeySummary, error)
- func (s *Store) RevokeUserAPIKey(ctx context.Context, userID, id string) (APIKeySummary, error)
- func (s *Store) SetAgentStatus(ctx context.Context, id, status, actorID string) (Agent, error)
- func (s *Store) UpsertTeamMembership(ctx context.Context, teamSlug, userID, role string) (TeamMembership, error)
- func (s *Store) WriteAudit(ctx context.Context, ev AuditEvent)
- type Team
- type TeamMembership
- type User
- type UserActivity
Constants ¶
const ( // RoleAdmin is the platform-wide administrator role. RoleAdmin = "admin" // RoleUser is the regular signed-in platform user role. RoleUser = "user" )
const ( SharedCatalogNamespace = mcpdefaults.MCPServersNamespace // TeamNamespacePrefix is prepended to normalized team slugs for managed namespaces. TeamNamespacePrefix = "mcp-team-" // TeamRoleOwner grants team administration privileges. TeamRoleOwner = "owner" // TeamRoleMember grants regular team membership privileges. TeamRoleMember = "member" // NamespaceScopeUser marks a namespace owned by a single platform user. NamespaceScopeUser = "user" // NamespaceScopeTeam marks a namespace owned by a platform team. NamespaceScopeTeam = "team" )
const OIDCProviderPrefix = "oidc:"
OIDCProviderPrefix prefixes provider names stored for OIDC identities.
Variables ¶
Functions ¶
func AdminOperationsUserSearch ¶
func AdminOperationsUserSearch(filter OperationsFilter) string
AdminOperationsUserSearch returns a normalized user search string for operations filters.
func AuditTimeWhere ¶
func AuditTimeWhere(alias string, filter OperationsFilter, args *[]any) string
AuditTimeWhere adds audit timestamp predicates to an existing argument list.
func GenerateAgentID ¶
func NewAgentID ¶
NewAgentID returns a platform-generated ID with a lowercase ULID suffix.
func NormalizeAgentName ¶
NormalizeAgentName applies the directory's stable whitespace and case rule.
func NormalizeTeamSlug ¶
NormalizeTeamSlug trims and lowercases a team slug.
func UserActivityWhere ¶
func UserActivityWhere(filter OperationsFilter) (string, []any)
UserActivityWhere builds the SQL WHERE clause and arguments for user activity queries.
func ValidateTeamNamespace ¶
ValidateTeamNamespace validates a managed team namespace name.
func ValidateTeamSlug ¶
ValidateTeamSlug validates the normalized slug used for team URLs and names.
Types ¶
type APIKeySummary ¶
type APIKeySummary struct {
ID string `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
CreatedAt time.Time `json:"created_at"`
Revoked bool `json:"revoked"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
}
APIKeySummary is the non-secret metadata for a user API key or registry credential.
type Agent ¶
type Agent struct {
ID string `json:"id"`
TeamID string `json:"team_id"`
TeamSlug string `json:"team_slug"`
Name string `json:"name"`
Status string `json:"status"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeactivatedAt *time.Time `json:"deactivated_at,omitempty"`
DeactivatedBy string `json:"deactivated_by,omitempty"`
}
Agent is a team-owned governance record for attributing MCP actions.
type AgentListFilter ¶
AgentListFilter bounds and filters an agent directory query.
type AgentPage ¶
type AgentPage struct {
Agents []Agent `json:"agents"`
NextCursor string `json:"next_cursor,omitempty"`
}
AgentPage is a bounded page of agent records.
type AuditEvent ¶
type AuditEvent struct {
UserID string `json:"user_id,omitempty"`
Action string `json:"action"`
Resource string `json:"resource"`
Namespace string `json:"namespace,omitempty"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
ActorIP string `json:"actor_ip,omitempty"`
RequestID string `json:"request_id,omitempty"`
Source string `json:"source,omitempty"`
AuthIdentity string `json:"auth_identity,omitempty"`
ImageRef string `json:"image_ref,omitempty"`
ServerName string `json:"server_name,omitempty"`
DeploymentTarget string `json:"deployment_target,omitempty"`
AgentID string `json:"agent_id,omitempty"`
TeamID string `json:"team_id,omitempty"`
}
AuditEvent is the write-side platform audit envelope.
type AuditLog ¶
type AuditLog struct {
ID int64 `json:"id"`
UserID string `json:"user_id,omitempty"`
Email string `json:"email,omitempty"`
Action string `json:"action"`
Resource string `json:"resource"`
Namespace string `json:"namespace,omitempty"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
ActorIP string `json:"actor_ip,omitempty"`
RequestID string `json:"request_id,omitempty"`
Source string `json:"source,omitempty"`
AuthIdentity string `json:"auth_identity,omitempty"`
ImageRef string `json:"image_ref,omitempty"`
ServerName string `json:"server_name,omitempty"`
DeploymentTarget string `json:"deployment_target,omitempty"`
AgentID string `json:"agent_id,omitempty"`
TeamID string `json:"team_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AuditLog is the read-side platform audit record returned to administrators.
type ImageActivity ¶
type ImageActivity struct {
UserID string `json:"user_id,omitempty"`
Email string `json:"email,omitempty"`
Namespace string `json:"namespace,omitempty"`
ImageRef string `json:"image_ref"`
SourceImage string `json:"source_image,omitempty"`
ServerName string `json:"server_name,omitempty"`
DeploymentTarget string `json:"deployment_target,omitempty"`
Action string `json:"action"`
Status string `json:"status"`
Source string `json:"source,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ImageActivity describes an image publish or deploy-related audit entry.
type OperationsFilter ¶
type OperationsFilter struct {
User string
UserSearch string
Since time.Time
Until time.Time
Limit int
}
OperationsFilter constrains platform operations and activity queries.
type OperationsFilterResponse ¶
type OperationsFilterResponse struct {
User string `json:"user,omitempty"`
Since string `json:"since,omitempty"`
Until string `json:"until,omitempty"`
Limit int `json:"limit"`
}
OperationsFilterResponse is the API echo of an operations filter.
type OperationsSnapshot ¶
type OperationsSnapshot struct {
Users []UserActivity `json:"users"`
AuditLogs []AuditLog `json:"audit_logs"`
Images []ImageActivity `json:"images"`
}
OperationsSnapshot bundles platform activity for internal operations queries.
type Principal ¶
type Principal = platformauth.Principal
type PrincipalTeam ¶
type PrincipalTeam = platformauth.PrincipalTeam
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns platform identity, API key, team, namespace, and audit persistence.
func NewForTest ¶
NewForTest returns an in-memory Store shell for tests that stub persistence.
func (*Store) AuthenticateJWT ¶
AuthenticateJWT validates a platform JWT and resolves it to the current principal.
func (*Store) AuthenticatePassword ¶
func (s *Store) AuthenticatePassword(ctx context.Context, email, password string) (User, bool, error)
AuthenticatePassword validates password-login credentials and returns the matching user.
func (*Store) AuthenticateRegistryCredential ¶
func (s *Store) AuthenticateRegistryCredential(ctx context.Context, username, password string) (Principal, bool, error)
AuthenticateRegistryCredential validates Docker registry basic-auth credentials. It supports both registry-specific API keys (mcpr_ prefix) and regular platform passwords.
func (*Store) AuthenticateUserAPIKey ¶
AuthenticateUserAPIKey validates a user API key and resolves its principal.
func (*Store) CreateAccessToken ¶
CreateAccessToken signs a short-lived platform JWT for a user.
func (*Store) CreateAgent ¶
CreateAgent creates an active, team-owned agent with an immutable platform ID.
func (*Store) CreatePasswordUser ¶
func (s *Store) CreatePasswordUser(ctx context.Context, email, password string, role string) (User, error)
CreatePasswordUser creates a password-login platform account with the requested role.
func (*Store) CreateRegistryCredential ¶
func (s *Store) CreateRegistryCredential(ctx context.Context, userID, name string) (APIKeySummary, string, error)
CreateRegistryCredential creates a registry credential and returns its one-time raw value.
func (*Store) CreateTeam ¶
CreateTeam creates a team, its namespace record, and an owner membership.
func (*Store) CreateUserAPIKey ¶
func (s *Store) CreateUserAPIKey(ctx context.Context, userID, name string) (APIKeySummary, string, error)
CreateUserAPIKey creates a user API key and returns its one-time raw value.
func (*Store) DeleteTeamBySlug ¶
DeleteTeamBySlug soft-deletes a team and its derived namespace/membership records.
func (*Store) DeleteTeamMembership ¶
DeleteTeamMembership soft-deletes a user's active team membership.
func (*Store) DeleteUser ¶
DeleteUser deletes a platform user by id.
func (*Store) EnsureOIDCUser ¶
func (s *Store) EnsureOIDCUser(ctx context.Context, provider, subject, email, role string) (User, error)
EnsureOIDCUser binds an OIDC subject to a platform account, creating it when needed.
func (*Store) EnsurePasswordUser ¶
func (s *Store) EnsurePasswordUser(ctx context.Context, email, password string, role string) (User, error)
EnsurePasswordUser creates or updates a password-login account for a fixed role.
func (*Store) EnsureTeamPasswordUser ¶
EnsureTeamPasswordUser ensures a regular password-login account exists for team membership flows. Existing platform roles are preserved so an admin is not accidentally demoted when they are added to a team.
func (*Store) GetNamespace ¶
GetNamespace returns one platform-managed namespace record by Kubernetes namespace.
func (*Store) GetTeamBySlug ¶
GetTeamBySlug returns one non-deleted team by normalized slug.
func (*Store) ListAgents ¶
ListAgents returns a stable, bounded page of team agents.
func (*Store) ListAuditLogs ¶
ListAuditLogs returns platform audit records matching an operations filter.
func (*Store) ListImageActivity ¶
func (s *Store) ListImageActivity(ctx context.Context, filter OperationsFilter) ([]ImageActivity, error)
ListImageActivity returns audit-derived image publish and deploy activity.
func (*Store) ListNamespaces ¶
ListNamespaces returns platform-managed namespace records for admin views.
func (*Store) ListRegistryCredentials ¶
func (s *Store) ListRegistryCredentials(ctx context.Context, userID string) ([]APIKeySummary, error)
ListRegistryCredentials returns non-secret registry credential metadata for a user.
func (*Store) ListTeamMemberships ¶
ListTeamMemberships returns active memberships for a team slug.
func (*Store) ListUserAPIKeys ¶
ListUserAPIKeys returns non-secret API key metadata for a user.
func (*Store) ListUserActivity ¶
func (s *Store) ListUserActivity(ctx context.Context, filter OperationsFilter) ([]UserActivity, error)
ListUserActivity returns user accounts with login, failure, key, and credential counters.
func (*Store) ListUserTeams ¶
ListUserTeams returns active team memberships for a user.
func (*Store) OperationsSnapshot ¶
func (s *Store) OperationsSnapshot(ctx context.Context, filter OperationsFilter) (OperationsSnapshot, error)
OperationsSnapshot returns user, audit, and image activity for internal consumers.
func (*Store) PrincipalForUserID ¶
PrincipalForUserID returns the platform principal for a non-deleted user.
func (*Store) RenameAgent ¶
func (*Store) ResolveTeamIDs ¶
ResolveTeamIDs returns a map of team UUID → slug for the given IDs. Unknown or deleted team IDs are silently omitted.
func (*Store) ResolveUserIDs ¶
ResolveUserIDs returns a map of user UUID → email for the given IDs. Unknown or deleted user IDs are silently omitted.
func (*Store) RevokeRegistryCredential ¶
func (s *Store) RevokeRegistryCredential(ctx context.Context, userID, id string) (APIKeySummary, error)
RevokeRegistryCredential marks a registry credential as revoked.
func (*Store) RevokeUserAPIKey ¶
RevokeUserAPIKey marks a user API key as revoked.
func (*Store) SetAgentStatus ¶
func (*Store) UpsertTeamMembership ¶
func (s *Store) UpsertTeamMembership(ctx context.Context, teamSlug, userID, role string) (TeamMembership, error)
UpsertTeamMembership creates or updates a user's role in a team.
func (*Store) WriteAudit ¶
func (s *Store) WriteAudit(ctx context.Context, ev AuditEvent)
WriteAudit records a platform audit event and logs failures without interrupting callers.
type Team ¶
type Team struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Namespace string `json:"namespace"`
CreatedAt time.Time `json:"created_at"`
}
Team is a managed platform team and its Kubernetes namespace.
type TeamMembership ¶
type TeamMembership = platform.TeamMembership
TeamMembership is the platform team membership API contract.
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
Namespace string `json:"namespace"`
}
User is the persisted platform account shape returned by identity operations.
type UserActivity ¶
type UserActivity struct {
ID string `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
Namespace string `json:"namespace,omitempty"`
CreatedAt time.Time `json:"created_at"`
LastLoginAt *time.Time `json:"last_login_at,omitempty"`
LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
LoginCount int64 `json:"login_count"`
FailedActionCount int64 `json:"failed_action_count"`
RegistryCredentials int64 `json:"registry_credentials"`
APIKeys int64 `json:"api_keys"`
}
UserActivity summarizes recent platform activity for a user account.