Documentation
¶
Overview ¶
Package grants defines the independently verifiable management-v1 grant envelope. It is separate from display tickets and session authentication. It does not establish enrollment, mTLS, policy, recording or process admission.
Index ¶
- Constants
- Variables
- func Digest(data []byte) string
- func KeyID(public ed25519.PublicKey) string
- func NewChallenge() (string, error)
- type Binding
- type BindingQGA
- type Claims
- type ClaimsQGA
- type Signer
- func (s *Signer) Issue(binding Binding, now time.Time, lifetime time.Duration) (string, error)
- func (s *Signer) IssueQGA(binding BindingQGA, now time.Time, lifetime time.Duration) (string, error)
- func (s *Signer) KeyID() string
- func (s *Signer) PublicKey() ed25519.PublicKey
- func (s *Signer) String() string
- type Verifier
Constants ¶
const ( Audience = "kube-workspaces/management/v1" Issuer = "kube-workspaces-api/management/v1" MaxLifetime = 60 * time.Second )
const ( // QGAAudience/QGAIssuer identify the QGA pilot transport separately from // the mTLS management endpoint so one transport can never accept the // other's grants. QGAAudience = "kube-workspaces/management-qga/v1" QGAIssuer = "kube-workspaces-api/management-qga/v1" // TransportQGAPodExec names the approved pilot transport: Kubernetes- // authenticated pod exec into the current virt-launcher, invoking the // fixed installed runner via the QEMU guest agent. TransportQGAPodExec = "qga-pod-exec/v1" // QGAMaxLifetime bounds one pilot grant. The confirmed pilot deadline is // 20 seconds; the grant lifetime covers staging, exec and polling. QGAMaxLifetime = 60 * time.Second )
Variables ¶
var ( ErrInvalid = errors.New("invalid management grant") ErrExpired = errors.New("management grant expired or not yet valid") ErrBinding = errors.New("management grant binding mismatch") ErrReplay = errors.New("management grant already consumed") ErrCapacity = errors.New("management grant replay cache at capacity") )
Functions ¶
func Digest ¶
Digest binds exact request bytes (or a certificate DER encoding). The protocol caller must define the request framing before issuance and guest verification.
func NewChallenge ¶
NewChallenge produces a 256-bit, connection-specific challenge.
Types ¶
type Binding ¶
type Binding struct {
ActorUID string `json:"actor_uid"`
Namespace string `json:"namespace"`
WorkspaceName string `json:"workspace_name"`
WorkspaceUID string `json:"workspace_uid"`
ProvisioningGeneration string `json:"provisioning_generation"`
ExecutionID string `json:"execution_id"`
RecordingID string `json:"recording_id"`
Operation string `json:"operation"`
OSIdentity string `json:"os_identity"`
Elevated bool `json:"elevated"`
PolicyVersion string `json:"policy_version"`
RevocationEpoch uint64 `json:"revocation_epoch"`
Challenge string `json:"challenge"`
PeerCertificateSHA256 string `json:"peer_certificate_sha256"`
RequestSHA256 string `json:"request_sha256"`
}
Binding describes one authorized operation on one authenticated connection. Expected values must come from guest identity, the mTLS peer, the connection's fresh challenge and the actual request, never from the grant being verified.
type BindingQGA ¶
type BindingQGA struct {
ActorUID string `json:"actor_uid"`
Namespace string `json:"namespace"`
WorkspaceName string `json:"workspace_name"`
WorkspaceUID string `json:"workspace_uid"`
ProvisioningGeneration string `json:"provisioning_generation"`
ExecutionID string `json:"execution_id"`
RecordingID string `json:"recording_id"`
Operation string `json:"operation"`
OSIdentity string `json:"os_identity"`
Elevated bool `json:"elevated"`
PolicyVersion string `json:"policy_version"`
RevocationEpoch uint64 `json:"revocation_epoch"`
Challenge string `json:"challenge"`
Transport string `json:"transport"`
TransportTargetSHA256 string `json:"transport_target_sha256"`
RequestSHA256 string `json:"request_sha256"`
}
BindingQGA is the QGA pilot transport binding. It replaces the mTLS peer certificate digest with the fixed transport name plus a digest of the server-resolved target identity (namespace/VM UID/launcher pod UID). The guest cannot independently know the launcher pod UID; the trust anchors for the pilot are the API signature, the authenticated Kubernetes exec path and single-use consumption. The guest does independently check workspace_uid against its enrolled identity.
type ClaimsQGA ¶
type ClaimsQGA struct {
Version int `json:"version"`
Issuer string `json:"iss"`
Audience string `json:"aud"`
ID string `json:"jti"`
IssuedAt int64 `json:"iat"`
ExpiresAt int64 `json:"exp"`
Binding BindingQGA `json:"binding"`
}
ClaimsQGA is the signed QGA grant payload.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer owns only the management signing key. Callers must independently check current user grants, platform policy, guest capability and recording admission.
func (*Signer) IssueQGA ¶
func (s *Signer) IssueQGA(binding BindingQGA, now time.Time, lifetime time.Duration) (string, error)
IssueQGA creates one compact EdDSA JWS bound to the QGA pilot transport.
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier is a bounded one-time-consumption reference verifier for one guest connection. Guests get only public keys. A disconnect must discard its random challenge; recreating a verifier for the same challenge would permit replay.
func NewVerifier ¶
func (*Verifier) Consume ¶
Consume verifies signature, time, full request/connection binding, and single use before returning claims. A full replay cache denies rather than evicting unexpired entries. Failed verification never consumes a valid grant.
func (*Verifier) ConsumeQGA ¶
ConsumeQGA verifies a QGA pilot grant against the expected binding and enforces single use on the same bounded replay state as the mTLS verifier.