openbaoapply

package
v0.1.0-c02.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 23 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 openbaoapply executes the fail-closed OpenBao Kubernetes-auth plan. Credentials are accepted only through the bounded stdin request and are retained in memory. Reports contain fixed policy facts only.

Index

Constants

View Source
const SupervisorSchemaVersion = "cloudring.openbao-kubernetes-auth-supervise/v1"

Variables

This section is empty.

Functions

func BindingSHA256

func BindingSHA256(request Request) (string, error)

BindingSHA256 binds non-secret target identity and seed content without ever emitting that fingerprint in Report. Callers use it only inside the request.

Types

type Approval

type Approval struct {
	ChangeAuthorized bool   `json:"changeAuthorized"`
	BindingSHA256    string `json:"bindingSHA256"`
}

Approval is an execution-consistency assertion made by an already-authorized protected supervisor. It is not a standalone authorization receipt.

type Connection

type Connection struct {
	Address             string `json:"address"`
	ServerName          string `json:"serverName"`
	CACertificateBase64 string `json:"caCertificateBase64"`
	BearerTokenBase64   string `json:"bearerTokenBase64,omitempty"`
}

Connection pins one HTTPS API authority and its trust material.

type KubernetesClient

type KubernetesClient interface {
	GetLease(context.Context, LeaseTarget) (Lease, error)
	UpdateLease(context.Context, LeaseTarget, Lease) (Lease, error)
	ReviewSelf(context.Context) (SubjectFacts, error)
	ReviewAccess(context.Context, ResourceAccess) (bool, error)
	GetServiceAccount(context.Context, string, string) (ServiceAccountFacts, error)
	RequestServiceAccountToken(context.Context, string, string, string, int64) (ServiceAccountToken, error)
}

KubernetesClient is intentionally narrower than client-go.

func NewKubernetesClient

func NewKubernetesClient(connection Connection) (KubernetesClient, error)

type Lease

type Lease struct {
	Name             string
	Namespace        string
	UID              string
	ResourceVersion  string
	HolderIdentity   string
	LeaseDurationSec int32
	AcquireTime      time.Time
	RenewTime        time.Time
	Raw              json.RawMessage
}

Lease is the narrow representation required for resourceVersion-guarded coordination. Unknown API fields are preserved by the concrete REST client.

type LeaseTarget

type LeaseTarget struct {
	Namespace      string `json:"namespace"`
	Name           string `json:"name"`
	HolderIdentity string `json:"holderIdentity"`
}

LeaseTarget identifies a pre-created coordination.k8s.io/v1 Lease. The executor never creates, deletes, patches, or automatically takes over it.

type NegativeIdentities

type NegativeIdentities struct {
	WrongServiceAccount WorkloadIdentity `json:"wrongServiceAccount"`
	WrongNamespace      WorkloadIdentity `json:"wrongNamespace"`
}

NegativeIdentities are pre-created, token-request-capable identities used to prove that the role is bound to both the exact ServiceAccount and namespace.

type OpenBaoClient

type OpenBaoClient interface {
	Unwrap(context.Context, string) (string, error)
	LookupSelf(context.Context, string) (TokenFacts, error)
	CapabilitiesSelf(context.Context, string, []string) (map[string][]string, error)
	Read(context.Context, string, string) (ReadResult, error)
	List(context.Context, string, string) (ReadResult, error)
	Write(context.Context, string, string, any) (ReadResult, error)
	Delete(context.Context, string, string) error
	Health(context.Context) error
	ExpectForbidden(context.Context, string, string, string, any) error
}

OpenBaoClient is intentionally expressed as exact operations, not a generic path client available to the state machine.

func NewOpenBaoClient

func NewOpenBaoClient(connection Connection) (OpenBaoClient, error)

type ReadResult

type ReadResult struct {
	Found bool
	Data  map[string]any
	Auth  map[string]any
}

type Report

type Report struct {
	SchemaVersion       string   `json:"schemaVersion"`
	Status              Status   `json:"status"`
	MutationPerformed   bool     `json:"mutationPerformed"`
	RollbackAttempted   bool     `json:"rollbackAttempted"`
	InputMaterialEchoed bool     `json:"inputMaterialEchoed"`
	CompletedGates      []string `json:"completedGates,omitempty"`
	FailedGate          string   `json:"failedGate,omitempty"`
	NonClaims           []string `json:"nonClaims"`
}

Report never contains identifiers, endpoints, fingerprints, or dynamic provider errors. Gate IDs are fixed public vocabulary.

func Apply

func Apply(ctx context.Context, reader interface{ Read([]byte) (int, error) }) (Report, error)

Apply parses one request, creates hardened clients, and executes the complete dedicated workload-identity plus one-secret vertical slice.

func Execute

func Execute(ctx context.Context, request Request, kubernetes KubernetesClient, openBao OpenBaoClient) Report

Execute is exported inside the internal package boundary for deterministic state-machine tests with exact fake clients.

func Supervise

func Supervise(ctx context.Context, reader io.Reader) (Report, error)

Supervise creates one exact temporary delegation, invokes the apply state machine in-process, and removes the temporary authority before returning.

type Request

type Request struct {
	SchemaVersion             string               `json:"schemaVersion"`
	Contract                  openbaoauth.Contract `json:"contract"`
	OpenBao                   Connection           `json:"openBao"`
	Kubernetes                Connection           `json:"kubernetes"`
	Lease                     LeaseTarget          `json:"lease"`
	ExecutorIdentity          WorkloadIdentity     `json:"executorIdentity"`
	ManagementPolicyName      string               `json:"managementPolicyName"`
	ManagementAccessor        string               `json:"managementAccessor"`
	WrappingTokenBase64       string               `json:"wrappingTokenBase64"`
	Seed                      Seed                 `json:"seed"`
	NegativeIdentities        NegativeIdentities   `json:"negativeIdentities"`
	Approval                  Approval             `json:"approval"`
	ExecutorServiceAccountUID string               `json:"-"`
}

Request is the complete one-shot apply input. All *Base64 fields may contain credentials and must never be copied to reports, errors, argv, environment, files, or logs.

func Parse

func Parse(reader io.Reader) (Request, string, error)

Parse reads and strictly validates one request. It returns only fixed error codes so credentials and provider identifiers cannot enter evidence.

type ResourceAccess

type ResourceAccess struct {
	Verb        string
	Group       string
	Resource    string
	Subresource string
	Namespace   string
	Name        string
}

type SecretEntry

type SecretEntry struct {
	Key         string `json:"key"`
	ValueBase64 string `json:"valueBase64"`
}

SecretEntry keeps secret bytes encoded while crossing the JSON boundary.

type Seed

type Seed struct {
	RelativePath string        `json:"relativePath"`
	Entries      []SecretEntry `json:"entries"`
}

Seed is one create-only KV-v2 value below Contract.DataPrefix.

type ServiceAccountFacts

type ServiceAccountFacts struct {
	UID string
}

type ServiceAccountToken

type ServiceAccountToken struct {
	JWT                 string
	ExpirationTimestamp time.Time
}

type Status

type Status string

Status is deliberately a closed, evidence-safe result set.

const (
	SchemaVersion = "cloudring.openbao-kubernetes-auth-apply/v1"
	MaxInputBytes = 512 * 1024

	StatusBlockedPreflight                  Status = "blocked_preflight"
	StatusApplied                           Status = "applied"
	StatusRolledBack                        Status = "rolled_back"
	StatusPartialManualInterventionRequired Status = "partial_manual_intervention_required"
)

type SubjectFacts

type SubjectFacts struct {
	Username string
	UID      string
	Groups   []string
}

type SupervisorOpenBaoClient

type SupervisorOpenBaoClient interface {
	ApplyClient() OpenBaoClient
	Health(context.Context) error
	LookupInitialRoot(context.Context, string) (TokenFacts, error)
	ReadTemporaryPolicy(context.Context, string, string) (ReadResult, error)
	CreateTemporaryPolicy(context.Context, string, string, string) error
	DeleteTemporaryPolicy(context.Context, string, string) error
	CreateWrappedManagementToken(context.Context, string, string, string) (WrappedToken, error)
	RevokeAccessorAndProve(context.Context, string, string) bool
}

type SupervisorRequest

type SupervisorRequest struct {
	SchemaVersion        string               `json:"schemaVersion"`
	Contract             openbaoauth.Contract `json:"contract"`
	OpenBao              Connection           `json:"openBao"`
	Kubernetes           Connection           `json:"kubernetes"`
	Lease                LeaseTarget          `json:"lease"`
	ExecutorIdentity     WorkloadIdentity     `json:"executorIdentity"`
	RootCredentialBase64 string               `json:"rootCredentialBase64"`
	Seed                 Seed                 `json:"seed"`
	NegativeIdentities   NegativeIdentities   `json:"negativeIdentities"`
	ChangeAuthorized     bool                 `json:"changeAuthorized"`
	// contains filtered or unexported fields
}

SupervisorRequest is the single pipe-only input for the protected root delegation boundary. The temporary policy, wrapped child credential, and apply binding are generated inside the process.

type TokenFacts

type TokenFacts struct {
	Policies                  []string
	Accessor                  string
	IdentityPolicies          []string
	ExternalNamespacePolicies int
	EntityID                  string
	Path                      string
	TTL                       int64
	ExplicitMaxTTL            int64
	NumUses                   int64
	MetadataEntries           int
	Renewable                 bool
	RenewableKnown            bool
	Orphan                    bool
	TokenType                 string
}

type WorkloadIdentity

type WorkloadIdentity struct {
	Namespace      string `json:"namespace"`
	ServiceAccount string `json:"serviceAccount"`
}

type WrappedToken

type WrappedToken struct {
	Value           string
	Accessor        string
	WrappedAccessor string
	CreationPath    string
}

Jump to

Keyboard shortcuts

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