Documentation
¶
Overview ¶
Package resultcredentials binds delivery to an operation's first Pod. It never grants Kubernetes API access or permission to SQL.
Index ¶
- Constants
- Variables
- func EnrollmentData(clientCA, serverTrust []byte) map[string]string
- func MatchesPodBinding(record *api.PtahResultRecord, identity resultdelivery.Identity) bool
- func StoredRecordIdentity(record *api.PtahResultRecord) (resultdelivery.Identity, error)
- func ValidateDelete(ctx context.Context, reader client.Reader, secret *corev1.Secret) error
- func ValidateRecordUpdate(old, next *api.PtahResultRecord) error
- func ValidateUpdate(old, next *corev1.Secret) error
- type Credential
- type EnrollmentPolicy
- type Issuer
- func (i *Issuer) AuthorizePublication(ctx context.Context, b resultstore.Binding) (resultdelivery.Identity, error)
- func (i *Issuer) CheckEnrollment(ctx context.Context) error
- func (i *Issuer) Ensure(ctx context.Context, identity resultdelivery.Identity) (Credential, error)
- func (i *Issuer) ValidateCreate(ctx context.Context, secret *corev1.Secret) error
- func (i *Issuer) ValidateRecordCreate(ctx context.Context, record *api.PtahResultRecord) error
- func (i *Issuer) WithEnrollmentPolicy(policy *EnrollmentPolicy) *Issuer
- type PodBindings
- func (p PodBindings) AuthorizePublication(ctx context.Context, binding resultstore.Binding) (resultdelivery.Identity, error)
- func (p PodBindings) Ensure(ctx context.Context, identity resultdelivery.Identity) (Credential, error)
- func (p PodBindings) ValidateRecordCreate(ctx context.Context, record *api.PtahResultRecord) error
Constants ¶
const ( AnnotationPodUID = binding.PodUID AnnotationPodName = binding.PodName AnnotationJobUID = binding.JobUID AnnotationOperationID = binding.OperationID )
const MaxCredentialLifetime = 24*time.Hour + 12*time.Minute
MaxCredentialLifetime includes the longest supported Job, delivery grace, and issuance backdating. CA retirement must wait at least this long after enrollment is fenced, plus the installation's clock-skew allowance.
Variables ¶
var ErrCredential = errors.New("result delivery credential is absent, invalid, or bound to another attempt")
Functions ¶
func EnrollmentData ¶
EnrollmentData is the public policy contract. clientCA is the selected signer's DER certificate; serverTrust is the exact PEM bundle new runners pin. Comparing whole certificates, not just key IDs, also binds their validity.
func MatchesPodBinding ¶
func MatchesPodBinding(record *api.PtahResultRecord, identity resultdelivery.Identity) bool
MatchesPodBinding recognizes an exact persisted public pin. It grants no publication authority; each delivery must still pass AuthorizePublication.
func StoredRecordIdentity ¶
func StoredRecordIdentity(record *api.PtahResultRecord) (resultdelivery.Identity, error)
StoredRecordIdentity reads the immutable binding without granting delivery authority. Cleanup uses it after certificate or CA expiry. The caller must read the persisted, admission-protected record directly from the API.
func ValidateDelete ¶
ValidateDelete retains the attempt's first-Pod pin until the owning resource retires that operation or disappears. Pod/Job loss, expiry, spec changes and lease loss alone must never permit deleting and reminting this credential. Reader must bypass the cache. The owner may be terminating: active work still needs its pin, while a retired operation must not obstruct foreground GC.
func ValidateRecordUpdate ¶
func ValidateRecordUpdate(old, next *api.PtahResultRecord) error
ValidateRecordUpdate freezes metadata as well as the CRD's immutable spec.
func ValidateUpdate ¶
ValidateUpdate protects the public binding and owner as well as the key. Kubernetes' immutable Secret flag protects data only, not this metadata.
Types ¶
type Credential ¶
Credential carries no private key. UID identifies the authoritative record, read back through the direct API reader while authority still held. Creating its immutable Secret projection never grants Secret read permission. Success is not proof that a kubelet has mounted the projection.
type EnrollmentPolicy ¶
type EnrollmentPolicy struct {
// contains filtered or unexported fields
}
EnrollmentPolicy fences new credential issuance across replicas. The exact ConfigMap contains public digests only and is owned by the installation's certificate rotator. Its Reader must bypass informer caches. An old mounted signer cannot authorize a new credential after this policy changes. Existing canonical credentials are validated separately against overlap trust.
func NewEnrollmentPolicy ¶
func NewEnrollmentPolicy(reader client.Reader, namespace, name string) (*EnrollmentPolicy, error)
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
func New ¶
func New(writer client.Client, reader client.Reader, ca tls.Certificate, clientTrust *x509.CertPool, serverTrust []byte) (*Issuer, error)
New requires a direct API reader, a dedicated client signer, the complete currently trusted client CA pool, and the server CA bundle mounted by runners. The trust pool may include a previous client signer during rotation overlap. Server trust is pinned per credential; changing it needs an installation transition that preserves old runners' trust, not replacement of their Secret.
func (*Issuer) AuthorizePublication ¶
func (i *Issuer) AuthorizePublication(ctx context.Context, b resultstore.Binding) (resultdelivery.Identity, error)
AuthorizePublication binds a publication to the canonical issued credential and current operation. A claimed identity in record bytes is not authority. Reader is the issuer's direct API reader; no Secret is read.
func (*Issuer) CheckEnrollment ¶
CheckEnrollment reports whether this snapshot may issue new credentials. It reads the public policy directly and grants no permission to execute SQL.
func (*Issuer) Ensure ¶
func (i *Issuer) Ensure(ctx context.Context, identity resultdelivery.Identity) (Credential, error)
func (*Issuer) ValidateCreate ¶
ValidateCreate checks the submitted bytes using the issuer's trust, without signing or writing anything. The caller must authenticate the manager and check the admission request's namespace/name. A missing issuer fails closed.
func (*Issuer) ValidateRecordCreate ¶
ValidateRecordCreate authenticates the canonical credential before it exists. The caller checks the manager identity and exact admission resource binding.
func (*Issuer) WithEnrollmentPolicy ¶
func (i *Issuer) WithEnrollmentPolicy(policy *EnrollmentPolicy) *Issuer
WithEnrollmentPolicy returns an independent issuer. Its signing material is immutable; installing a policy never changes another replica's issuer object.
type PodBindings ¶
PodBindings preserves the first Pod authorized for an operation. Its immutable record contains public identity only: no token, certificate, or private key. TokenReview authenticates requests separately. Neither operation can replace this pin, and deleting the original Pod cannot enroll a replacement.
func (PodBindings) AuthorizePublication ¶
func (p PodBindings) AuthorizePublication(ctx context.Context, binding resultstore.Binding) (resultdelivery.Identity, error)
func (PodBindings) Ensure ¶
func (p PodBindings) Ensure(ctx context.Context, identity resultdelivery.Identity) (Credential, error)
func (PodBindings) ValidateRecordCreate ¶
func (p PodBindings) ValidateRecordCreate(ctx context.Context, record *api.PtahResultRecord) error