Help us shape the future of Go! Take the 2026 Go Developer Survey

permissions

package
v0.0.103 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package permissions defines recipe grants independently of JobDB's token format.

Index

Constants

View Source
const Version = 1

Variables

This section is empty.

Functions

func RepositoryIdentity added in v0.0.103

func RepositoryIdentity(source string) string

RepositoryIdentity is computed only while loading sources, never by replay. Unknown origins cannot establish trust. Local paths follow symlinks to the actual checkout; URL comparison deliberately does not alias SSH with HTTPS.

func ResolveInputs added in v0.0.103

func ResolveInputs(ctx context.Context, names, authorized []string) (jobdb.SecretResolveResult, error)

func ValidateInclude added in v0.0.103

func ValidateInclude(spec *Spec, boundary bool) error

func WithAccess

func WithAccess(ctx context.Context, access *Access) context.Context

func WithInputResolver added in v0.0.103

func WithInputResolver(ctx context.Context, resolve ResolveFunc) context.Context

WithInputResolver installs a driver-only resolver. Operation helpers continue to use Access.Resolve and its delegated grant.

Types

type Access

type Access struct {
	// contains filtered or unexported fields
}

Access checks every use before consulting a resolver, including cached ones. Callbacks belong to the controller and are never serialized into task input.

func FromContext

func FromContext(ctx context.Context) *Access

func NewAccess

func NewAccess(ctx context.Context, grant JobDB, resolve ResolveFunc, submit SubmitFunc) *Access

func (*Access) CheckSecrets

func (a *Access) CheckSecrets(names []string) error

func (*Access) Context

func (a *Access) Context() context.Context

func (*Access) Grant

func (a *Access) Grant() JobDB

func (*Access) LimitDeadline

func (a *Access) LimitDeadline(deadline time.Time) context.CancelFunc

LimitDeadline narrows helper calls as soon as an operation-local timeout is known. Already issued credentials stay private to the trusted helper; later calls use a credential bounded by the narrower deadline.

func (*Access) Resolve

func (a *Access) Resolve(ctx context.Context, names []string) (jobdb.SecretResolveResult, error)

func (*Access) Submit

func (a *Access) Submit(ctx context.Context, job jobdb.SubmitJob) (jobref.Ref, error)

type InputPolicy added in v0.0.103

type InputPolicy struct {
	RootRepository string   `json:"root_repository,omitempty"`
	Foreign        bool     `json:"foreign,omitempty"`
	Allowed        []string `json:"allowed,omitempty"`
}

InputPolicy authorizes driver materialization, never delegated lease authority. RootRepository is fixed for the entire recipe, including nested includes.

type Issuer

type Issuer interface {
	IssueRestrictedLease(context.Context, TaskDelegator, JobDB, time.Time) (jobdb.ExecutionLease, error)
}

Issuer is the single integration boundary for credential creation. The deadline is an optional operation limit; JobDB supplies execution bounds.

type JobDB

type JobDB struct {
	Secrets SecretPermissions `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	Jobs    JobPermissions    `yaml:"jobs,omitempty" json:"jobs,omitempty"`
}

func (JobDB) Validate

func (p JobDB) Validate() error

type JobDBIssuer

type JobDBIssuer struct{}

JobDBIssuer uses task-scoped local attenuation. The caller context controls cancellation only; its request timeout must not become a credential deadline.

func (JobDBIssuer) IssueRestrictedLease

func (i JobDBIssuer) IssueRestrictedLease(ctx context.Context, task TaskDelegator, grant JobDB, deadline time.Time) (jobdb.ExecutionLease, error)

type JobPermissions

type JobPermissions struct {
	Submit bool `yaml:"submit,omitempty" json:"submit,omitempty"`
}

type Limit

type Limit struct {
	JobDB *JobDB `yaml:"jobdb,omitempty" json:"jobdb,omitempty"`
}

type ResolveFunc

type ResolveFunc func(context.Context, []string) (jobdb.SecretResolveResult, error)

type SecretPermissions

type SecretPermissions struct {
	Resolve []string `yaml:"resolve,omitempty" json:"resolve,omitempty"`
}

type Spec

type Spec struct {
	JobDB *JobDB `yaml:"jobdb,omitempty" json:"jobdb,omitempty"`
	Limit *Limit `yaml:"limit,omitempty" json:"limit,omitempty"`
}

Spec is common node metadata. On ordinary nodes JobDB replaces the delegated grant; on includes it authorizes callee inputs and bounds callee grants.

func (Spec) JSONSchema

func (Spec) JSONSchema() *jsonschema.Schema

func (*Spec) UnmarshalYAML

func (p *Spec) UnmarshalYAML(n *yaml.Node) error

Reject unknown fields, nulls, aliases and merges rather than silently ignoring an intended restriction. This strictness is local to the permission subtree.

func (*Spec) Validate

func (p *Spec) Validate() error

type State

type State struct {
	Version int          `json:"version"`
	Grant   *JobDB       `json:"grant,omitempty"`
	Limit   *JobDB       `json:"limit,omitempty"`
	Inputs  *InputPolicy `json:"inputs,omitempty"`
}

State is immutable lexical policy, serialized with each task invocation. Input authorization is independent of grants and automatic Git defaults.

func (State) CheckInput added in v0.0.103

func (s State) CheckInput(name string) error

func (State) Enter

func (s State) Enter(spec *Spec, boundary bool) (State, error)

func (State) EnterInclude added in v0.0.103

func (s State) EnterInclude(spec *Spec, boundary, trusted bool) (State, error)

EnterInclude interprets the callsite grant as authority entrusted to the included recipe. It does not put those secrets on descendant lease tokens.

func (State) Resolve

func (s State) Resolve(gitSecrets []string) (JobDB, error)

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(raw []byte) error

type SubmitFunc

type SubmitFunc func(context.Context, jobdb.SubmitJob) (jobref.Ref, error)

type TaskDelegator

type TaskDelegator interface {
	CreateDelegation(context.Context, jobdb.CreateDelegationRequest) (jobdb.RenewableExecutionLease, error)
}

TaskDelegator is the live task's engine-owned delegation capability. A copy of workflow.TaskContext preserves it; a reconstructed context does not.

Jump to

Keyboard shortcuts

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