adminapi

package
v0.1.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package adminapi serves the Admin API (IF-1, api/openapi/admin.yaml) of the control plane: the generated strict chi server with the RBAC middleware (section 5.9), request validation against the contract, optimistic concurrency (ETag and If-Match) and RFC 9457 problem details.

WS1 implements the Applications, Ray groups, Rays and Settings areas here (FR-ADM-03). The other areas are implemented by WS2, WS3, WS9, WS10 and WS11 and plugged in through contracts.AdminHandlers; an area that is not plugged in yet answers 501 after authorization.

Index

Constants

This section is empty.

Variables

View Source
var ReservedSlugs = map[string]bool{"portal": true, "tunnel": true}

ReservedSlugs are the hostname labels of the portal and the tunnel endpoint under the base domain (section 5.4); an application using one would take over that origin.

Functions

func DefaultSettings

func DefaultSettings() adminapi.Settings

DefaultSettings returns the documented defaults of admin.yaml.

func ETag

func ETag(version int64) string

ETag returns the entity tag of a row version.

Types

type CertificateRevoker

type CertificateRevoker interface {
	RevokeRay(ctx context.Context, rayID, reason string) error
}

CertificateRevoker revokes the certificates of a ray: they enter the trust bundle's revocation list and cannot be renewed (FR-CON-05). It is implemented by WS11's pki.Service and wired inside the control plane binary, so it is not a contract (issue #37). It returns contracts.ErrNotFound for a ray without certificates.

type CredentialsRewrapper

type CredentialsRewrapper struct {
	Store    *store.Store
	Envelope *envelope.Envelope
}

CredentialsRewrapper re-wraps the sealed target credentials of applications under a new master key during master key rotation (FR-CRT-04, NFR-SEC-04, #131, ADR-0046). It implements contracts.SealedRewrapper for WS11's re-wrap job: rows are walked by application ID, each value is resealed with its own associated data, a row changes only if it still holds the value that was read, and the row version and ETag stay as they are because the plaintext does not change.

func (CredentialsRewrapper) Name

Name implements contracts.SealedRewrapper.

func (CredentialsRewrapper) RewrapSealed

RewrapSealed implements contracts.SealedRewrapper.

type RayRuntime

type RayRuntime interface {
	RayTunnels(rayID string) []RayTunnel
}

RayRuntime reports the live state of rays from the tunnel map (section 5.4); nil means every ray is offline.

type RayTunnel

type RayTunnel struct {
	ReplicaID   string
	Since       int64 // Unix seconds
	Draining    bool
	OpenStreams int
}

RayTunnel is one tunnel a data plane replica holds to a ray.

type Reader

type Reader struct{ S *Server }

Reader implements the contracts readers over the WS1 tables for other workstreams (section 7.1). It returns the Admin API representation, which holds no secret values.

func (Reader) GetApplication

func (r Reader) GetApplication(ctx context.Context, id string) (adminapi.Application, error)

GetApplication implements contracts.ApplicationReader.

func (Reader) GetRay

func (r Reader) GetRay(ctx context.Context, id string) (adminapi.Ray, error)

GetRay implements contracts.RayReader.

func (Reader) GetRayGroup

func (r Reader) GetRayGroup(ctx context.Context, id string) (adminapi.RayGroup, error)

GetRayGroup implements contracts.RayReader.

func (Reader) GetSettings

func (r Reader) GetSettings(ctx context.Context) (adminapi.Settings, error)

GetSettings implements contracts.SettingsReader.

func (Reader) ListApplications

func (r Reader) ListApplications(ctx context.Context, opts contracts.ListOptions) (contracts.Page[adminapi.Application], error)

ListApplications implements contracts.ApplicationReader.

func (Reader) ListRayGroups

ListRayGroups implements contracts.RayReader.

type Server

type Server struct {
	Store  *store.Store
	Matrix *rbac.Matrix
	Auth   rbac.Authenticator
	// Envelope seals stored target credentials (NFR-SEC-04); nil refuses
	// stored credentials.
	Envelope *envelope.Envelope
	// BaseDomain forms application hostnames `<slug>.<base-domain>`.
	BaseDomain string
	// Hosted holds the areas of other workstreams; the WS1 areas are set by
	// Handler and must be left nil here.
	Hosted contracts.AdminHandlers
	// Revoker revokes the grants of a revoked ray (WS3); nil skips it.
	Revoker contracts.GrantRevoker
	// Certificates revokes the certificates of a revoked ray (WS11);
	// nil skips it.
	Certificates CertificateRevoker
	// RevocationQueued, when set, is called after a transaction queued an
	// application grant revocation, to wake the revocation job (ADR-0024).
	RevocationQueued func()
	// Policies validates policy assignments (WS3); nil skips the check.
	Policies contracts.PolicyReader
	// Runtime supplies the online state of rays; may be nil.
	Runtime RayRuntime
	Logger  *slog.Logger
	// contains filtered or unexported fields
}

Server implements the WS1 Admin API areas and assembles the full server.

func (*Server) ApplicationCredentials

func (s *Server) ApplicationCredentials(ctx context.Context, applicationID string) (*tunnelv1.RemoteCredentials, error)

ApplicationCredentials implements contracts.ApplicationCredentialSource for WS3's credential sealing (FR-ACC-06, ADR-0003 decision 9).

func (*Server) AssignApplicationPolicy

AssignApplicationPolicy implements PUT /applications/{id}/policy, the Policy Administrator's half of the section 5.9 split. It takes effect on data planes with the next configuration revision (FR-POL-07).

func (*Server) CreateApplication

CreateApplication implements POST /applications. The application starts without a policy, so it is unreachable until a Policy Administrator assigns one (FR-POL-01, section 5.9).

func (*Server) CreateRayGroup

CreateRayGroup implements POST /ray-groups.

func (*Server) DeleteApplication

DeleteApplication implements DELETE /applications/{id}.

func (*Server) DeleteRay

DeleteRay implements DELETE /rays/{id}: only a revoked ray, or one that never connected, can be removed (IF-1).

Deleting must never leave a valid certificate behind (FR-CON-05):

  1. A ray that is not revoked yet is marked revoked (reason "deleted") and audited in its own transaction, as the revoke action does, so WS11's ray observer finds nothing left to change.
  2. WS11 revokes its certificates. The call is idempotent and is made for every ray with a certificate, revoked or not, so a certificate revocation that failed earlier is retried here. A failure answers 503 and keeps the row, so the call can be repeated.
  3. The row is deleted and audited.

Without a certificate revoker a ray with a certificate cannot be deleted.

func (*Server) DeleteRayGroup

DeleteRayGroup implements DELETE /ray-groups/{id}; 409 while rays or applications are assigned.

func (*Server) GetApplication

GetApplication implements GET /applications/{id}.

func (*Server) GetRay

GetRay implements GET /rays/{id}.

func (*Server) GetRayGroup

GetRayGroup implements GET /ray-groups/{id}.

func (*Server) GetSettings

GetSettings implements GET /settings.

func (*Server) GetSettingsValue

func (s *Server) GetSettingsValue(ctx context.Context) (adminapi.Settings, error)

GetSettingsValue returns the current settings.

func (*Server) Handler

func (s *Server) Handler() (http.Handler, error)

Handler returns the Admin API handler, mounted at rbac.BasePath.

func (*Server) ListApplications

ListApplications implements GET /applications.

func (*Server) ListRayGroups

ListRayGroups implements GET /ray-groups.

func (*Server) ListRays

ListRays implements GET /rays.

func (*Server) RevokeRay

RevokeRay implements POST /rays/{id}:revoke (FR-CON-05). The state change and its audit entry commit together; the new configuration revision marks the ray revoked in every group configuration (IF-2: its tunnels are closed and refused), and WS3's GrantRevoker closes its tunnels and grants. WS11 puts its certificates on the revocation list and refuses their renewal. The action is idempotent, so repeating it retries a failed certificate or grant revocation.

func (*Server) UpdateApplication

UpdateApplication implements PATCH /applications/{id} (JSON merge patch). Target and TLS verification changes are recorded with before and after values (FR-AUD-02, FR-ACC-07).

func (*Server) UpdateRay

UpdateRay implements PATCH /rays/{id} (name, description).

func (*Server) UpdateRayGroup

UpdateRayGroup implements PATCH /ray-groups/{id}.

func (*Server) UpdateSettings

UpdateSettings implements PATCH /settings (JSON merge patch).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL