Documentation
¶
Overview ¶
Package admin implements the platform-admin surface mounted at /api/admin/* and surfaced in the portal's gated /bonkers area. It lets a platform admin see all users / organizations / providers / root identities. It is read-only: provider provisioning (workspace + ServiceAccount + kubeconfig) is driven declaratively by the Provider CR reconciler (pkg/hub/providers/provider_controller.go), not by an admin HTTP action.
Index ¶
- func Middleware(resolver UserResolver, checker AdminChecker) func(http.Handler) http.Handler
- type AdminChecker
- type AdminCheckerFunc
- type Handler
- type OnboardedWorkspace
- type OrgWorkspace
- type RootIdentity
- type Service
- func (s *Service) CreateProvider(ctx context.Context, name, displayName string) error
- func (s *Service) DeleteProvider(ctx context.Context, name string) error
- func (s *Service) GetProviderKubeconfig(ctx context.Context, name string) ([]byte, error)
- func (s *Service) ListOnboardedWorkspaces(ctx context.Context) ([]OnboardedWorkspace, error)
- func (s *Service) ListOrgWorkspaces(ctx context.Context, orgUUID string) ([]OrgWorkspace, error)
- func (s *Service) ListRootIdentities(ctx context.Context) ([]RootIdentity, error)
- type UserResolver
- type UserResolverFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(resolver UserResolver, checker AdminChecker) func(http.Handler) http.Handler
Middleware gates a subrouter so only platform admins reach it: 401 when no identity resolves, 403 when the caller is authenticated but not an admin.
Types ¶
type AdminChecker ¶
AdminChecker decides whether a resolved caller is a platform admin. The hub supplies an implementation that matches the User CR's name / email / rbacIdentity against the --admin-users allowlist.
type AdminCheckerFunc ¶
AdminCheckerFunc adapts a function to AdminChecker.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the /api/admin/* endpoints.
func NewHandler ¶
func NewHandler(svc *Service, userClient *farosclient.Client, registry *providers.Registry) *Handler
NewHandler builds an admin Handler.
type OnboardedWorkspace ¶
OnboardedWorkspace mirrors providers.OnboardedWorkspace for the admin API.
type OrgWorkspace ¶
type OrgWorkspace struct {
UUID string `json:"uuid"`
DisplayName string `json:"displayName"`
ClusterName string `json:"clusterName"`
Providers []string `json:"providers"`
DeletionRequestedAt *time.Time `json:"deletionRequestedAt,omitempty"`
}
OrgWorkspace is a child Workspace of an organization together with the provider names enabled in it (derived from the workspace's provider APIBindings).
type RootIdentity ¶
type RootIdentity struct {
Group string `json:"group"`
Resource string `json:"resource"`
IdentityHash string `json:"identityHash"`
Export string `json:"export"`
Path string `json:"path"`
}
RootIdentity is one (group, resource) served by a first-party APIExport, together with the identityHash kcp minted for it. The admin copies the hash a provider needs (e.g. edges.faros.sh for kuery) into that provider's Helm values so its `init` can stamp it onto the APIExport's permissionClaim.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs read-only admin queries against kcp.
func NewService ¶
NewService returns an admin Service. hubExternalURL/providerInternalURL are accepted for call-site compatibility but no longer used now that provider provisioning (which baked a server URL into minted kubeconfigs) moved to the Provider CR reconciler.
func (*Service) CreateProvider ¶
CreateProvider create-or-updates a Provider object in root:faros:system:providers. name drives the provisioned sub-workspace (root:faros:providers:<name>); displayName is informational. Idempotent.
func (*Service) DeleteProvider ¶
DeleteProvider removes a Provider object from root:faros:system:providers. The reconciler's finalizer then tears down the sub-workspace. Idempotent.
func (*Service) GetProviderKubeconfig ¶
GetProviderKubeconfig returns the minted kubeconfig the Provider controller wrote into a Secret in root:faros:system:providers. It reads the Provider's status.secretRef to locate the Secret (falling back to the "<name>-kubeconfig" / "default" / "kubeconfig" conventions). Returns a nil slice + nil error when the Provider exists but hasn't been provisioned yet (no Secret), so callers can surface "not ready".
func (*Service) ListOnboardedWorkspaces ¶
func (s *Service) ListOnboardedWorkspaces(ctx context.Context) ([]OnboardedWorkspace, error)
ListOnboardedWorkspaces returns the provider sub-workspaces created by onboarding, so the admin UI can show providers that have been onboarded but whose Helm chart (and CatalogEntry) is not yet installed.
func (*Service) ListOrgWorkspaces ¶
ListOrgWorkspaces returns every child Workspace under the org at root:faros:tenants:{orgUUID}, enriched with display name, cluster name, soft-delete timestamp and the set of enabled provider names. Reads run with kcp-admin credentials, so the admin surface sees all workspaces regardless of per-user RBAC. Per-workspace lookups are best-effort: a workspace that hasn't reached Ready (no cluster) or whose provider listing fails still appears with whatever fields resolved.
func (*Service) ListRootIdentities ¶
func (s *Service) ListRootIdentities(ctx context.Context) ([]RootIdentity, error)
ListRootIdentities returns the (group, resource → identityHash) tuples served by the APIExports in the providers parent workspace. An empty identityHash means kcp has not minted the export's identity yet.
type UserResolver ¶
UserResolver maps an inbound request to the caller's User CR name, or returns an error if no identity can be resolved. Mirrors tenant.UserResolver so the hub can reuse the same OIDC IdentifyUser plumbing.
type UserResolverFunc ¶
UserResolverFunc adapts a function to UserResolver.
func (UserResolverFunc) ResolveUser ¶
func (f UserResolverFunc) ResolveUser(r *http.Request) (string, error)
ResolveUser implements UserResolver.