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 ¶
- Variables
- func DefaultSettings() adminapi.Settings
- func ETag(version int64) string
- type CertificateRevoker
- type CredentialsRewrapper
- type RayRuntime
- type RayTunnel
- type Reader
- func (r Reader) GetApplication(ctx context.Context, id string) (adminapi.Application, error)
- func (r Reader) GetRay(ctx context.Context, id string) (adminapi.Ray, error)
- func (r Reader) GetRayGroup(ctx context.Context, id string) (adminapi.RayGroup, error)
- func (r Reader) GetSettings(ctx context.Context) (adminapi.Settings, error)
- func (r Reader) ListApplications(ctx context.Context, opts contracts.ListOptions) (contracts.Page[adminapi.Application], error)
- func (r Reader) ListRayGroups(ctx context.Context, opts contracts.ListOptions) (contracts.Page[adminapi.RayGroup], error)
- type Server
- func (s *Server) ApplicationCredentials(ctx context.Context, applicationID string) (*tunnelv1.RemoteCredentials, error)
- func (s *Server) AssignApplicationPolicy(ctx context.Context, req adminapi.AssignApplicationPolicyRequestObject) (adminapi.AssignApplicationPolicyResponseObject, error)
- func (s *Server) CreateApplication(ctx context.Context, req adminapi.CreateApplicationRequestObject) (adminapi.CreateApplicationResponseObject, error)
- func (s *Server) CreateRayGroup(ctx context.Context, req adminapi.CreateRayGroupRequestObject) (adminapi.CreateRayGroupResponseObject, error)
- func (s *Server) DeleteApplication(ctx context.Context, req adminapi.DeleteApplicationRequestObject) (adminapi.DeleteApplicationResponseObject, error)
- func (s *Server) DeleteRay(ctx context.Context, req adminapi.DeleteRayRequestObject) (adminapi.DeleteRayResponseObject, error)
- func (s *Server) DeleteRayGroup(ctx context.Context, req adminapi.DeleteRayGroupRequestObject) (adminapi.DeleteRayGroupResponseObject, error)
- func (s *Server) GetApplication(ctx context.Context, req adminapi.GetApplicationRequestObject) (adminapi.GetApplicationResponseObject, error)
- func (s *Server) GetRay(ctx context.Context, req adminapi.GetRayRequestObject) (adminapi.GetRayResponseObject, error)
- func (s *Server) GetRayGroup(ctx context.Context, req adminapi.GetRayGroupRequestObject) (adminapi.GetRayGroupResponseObject, error)
- func (s *Server) GetSettings(ctx context.Context, _ adminapi.GetSettingsRequestObject) (adminapi.GetSettingsResponseObject, error)
- func (s *Server) GetSettingsValue(ctx context.Context) (adminapi.Settings, error)
- func (s *Server) Handler() (http.Handler, error)
- func (s *Server) ListApplications(ctx context.Context, req adminapi.ListApplicationsRequestObject) (adminapi.ListApplicationsResponseObject, error)
- func (s *Server) ListRayGroups(ctx context.Context, req adminapi.ListRayGroupsRequestObject) (adminapi.ListRayGroupsResponseObject, error)
- func (s *Server) ListRays(ctx context.Context, req adminapi.ListRaysRequestObject) (adminapi.ListRaysResponseObject, error)
- func (s *Server) RevokeRay(ctx context.Context, req adminapi.RevokeRayRequestObject) (adminapi.RevokeRayResponseObject, error)
- func (s *Server) UpdateApplication(ctx context.Context, req adminapi.UpdateApplicationRequestObject) (adminapi.UpdateApplicationResponseObject, error)
- func (s *Server) UpdateRay(ctx context.Context, req adminapi.UpdateRayRequestObject) (adminapi.UpdateRayResponseObject, error)
- func (s *Server) UpdateRayGroup(ctx context.Context, req adminapi.UpdateRayGroupRequestObject) (adminapi.UpdateRayGroupResponseObject, error)
- func (s *Server) UpdateSettings(ctx context.Context, req adminapi.UpdateSettingsRequestObject) (adminapi.UpdateSettingsResponseObject, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
DefaultSettings returns the documented defaults of admin.yaml.
Types ¶
type CertificateRevoker ¶
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 ¶
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 ¶
func (CredentialsRewrapper) Name() string
Name implements contracts.SealedRewrapper.
func (CredentialsRewrapper) RewrapSealed ¶
func (r CredentialsRewrapper) RewrapSealed(ctx context.Context, req contracts.RewrapRequest) (contracts.RewrapResult, error)
RewrapSealed implements contracts.SealedRewrapper.
type RayRuntime ¶
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 ¶
GetApplication implements contracts.ApplicationReader.
func (Reader) GetRayGroup ¶
GetRayGroup implements contracts.RayReader.
func (Reader) GetSettings ¶
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.
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 ¶
func (s *Server) AssignApplicationPolicy(ctx context.Context, req adminapi.AssignApplicationPolicyRequestObject) (adminapi.AssignApplicationPolicyResponseObject, error)
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 ¶
func (s *Server) CreateApplication(ctx context.Context, req adminapi.CreateApplicationRequestObject) (adminapi.CreateApplicationResponseObject, error)
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 ¶
func (s *Server) CreateRayGroup(ctx context.Context, req adminapi.CreateRayGroupRequestObject) (adminapi.CreateRayGroupResponseObject, error)
CreateRayGroup implements POST /ray-groups.
func (*Server) DeleteApplication ¶
func (s *Server) DeleteApplication(ctx context.Context, req adminapi.DeleteApplicationRequestObject) (adminapi.DeleteApplicationResponseObject, error)
DeleteApplication implements DELETE /applications/{id}.
func (*Server) DeleteRay ¶
func (s *Server) DeleteRay(ctx context.Context, req adminapi.DeleteRayRequestObject) (adminapi.DeleteRayResponseObject, error)
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):
- 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.
- 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.
- The row is deleted and audited.
Without a certificate revoker a ray with a certificate cannot be deleted.
func (*Server) DeleteRayGroup ¶
func (s *Server) DeleteRayGroup(ctx context.Context, req adminapi.DeleteRayGroupRequestObject) (adminapi.DeleteRayGroupResponseObject, error)
DeleteRayGroup implements DELETE /ray-groups/{id}; 409 while rays or applications are assigned.
func (*Server) GetApplication ¶
func (s *Server) GetApplication(ctx context.Context, req adminapi.GetApplicationRequestObject) (adminapi.GetApplicationResponseObject, error)
GetApplication implements GET /applications/{id}.
func (*Server) GetRay ¶
func (s *Server) GetRay(ctx context.Context, req adminapi.GetRayRequestObject) (adminapi.GetRayResponseObject, error)
GetRay implements GET /rays/{id}.
func (*Server) GetRayGroup ¶
func (s *Server) GetRayGroup(ctx context.Context, req adminapi.GetRayGroupRequestObject) (adminapi.GetRayGroupResponseObject, error)
GetRayGroup implements GET /ray-groups/{id}.
func (*Server) GetSettings ¶
func (s *Server) GetSettings(ctx context.Context, _ adminapi.GetSettingsRequestObject) (adminapi.GetSettingsResponseObject, error)
GetSettings implements GET /settings.
func (*Server) GetSettingsValue ¶
GetSettingsValue returns the current settings.
func (*Server) ListApplications ¶
func (s *Server) ListApplications(ctx context.Context, req adminapi.ListApplicationsRequestObject) (adminapi.ListApplicationsResponseObject, error)
ListApplications implements GET /applications.
func (*Server) ListRayGroups ¶
func (s *Server) ListRayGroups(ctx context.Context, req adminapi.ListRayGroupsRequestObject) (adminapi.ListRayGroupsResponseObject, error)
ListRayGroups implements GET /ray-groups.
func (*Server) ListRays ¶
func (s *Server) ListRays(ctx context.Context, req adminapi.ListRaysRequestObject) (adminapi.ListRaysResponseObject, error)
ListRays implements GET /rays.
func (*Server) RevokeRay ¶
func (s *Server) RevokeRay(ctx context.Context, req adminapi.RevokeRayRequestObject) (adminapi.RevokeRayResponseObject, error)
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 ¶
func (s *Server) UpdateApplication(ctx context.Context, req adminapi.UpdateApplicationRequestObject) (adminapi.UpdateApplicationResponseObject, error)
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 ¶
func (s *Server) UpdateRay(ctx context.Context, req adminapi.UpdateRayRequestObject) (adminapi.UpdateRayResponseObject, error)
UpdateRay implements PATCH /rays/{id} (name, description).
func (*Server) UpdateRayGroup ¶
func (s *Server) UpdateRayGroup(ctx context.Context, req adminapi.UpdateRayGroupRequestObject) (adminapi.UpdateRayGroupResponseObject, error)
UpdateRayGroup implements PATCH /ray-groups/{id}.
func (*Server) UpdateSettings ¶
func (s *Server) UpdateSettings(ctx context.Context, req adminapi.UpdateSettingsRequestObject) (adminapi.UpdateSettingsResponseObject, error)
UpdateSettings implements PATCH /settings (JSON merge patch).