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

access

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package access resolves access profiles (spec.AccessProfile) into what a seat may do from its sandbox, through plugins. A plugin owns one part of a profile: it validates that part and contributes to the seat's resolved SeatAccess, which every enforcement point reads:

  • the seat runtime renders the Pod and NetworkPolicy from PodPart;
  • the seat runner checks binaries and wires the proxy, credential helpers and browser;
  • the platform answers the egress gateway and issues credentials from the live parts.

Parts that need a new Pod (binaries, network rules, browser, credential wiring) are in PodPart and so in the config revision. Egress hosts and repository grants apply live, without restarting the seat.

Index

Constants

View Source
const (
	DeliveryPlatform = "platform"
	DeliverySandbox  = "sandbox"
)

Delivery modes of a credential grant.

Variables

View Source
var GitHubHosts = []string{"github.com", "api.github.com", "codeload.github.com", "*.githubusercontent.com"}

GitHubHosts are allowed through the egress gateway for sandbox delivery to github.com.

View Source
var GitHubPermissions = []string{"contents", "pull_requests", "issues", "metadata"}

GitHubPermissions are the permission names a grant may set.

Functions

func GitHost

func GitHost(c spec.Connection) string

GitHost is the host git uses for a github connection.

func GitHubOperations

func GitHubOperations(perms map[string]string) []string

GitHubOperations maps permissions to the connection operations a platform-delivered grant allows.

func MatchHost

func MatchHost(pattern, host string) bool

MatchHost matches host against a pattern: an exact name, or *.suffix for any subdomain of suffix (not suffix itself).

func ParseHost

func ParseHost(entry string) (host string, ports []int, err error)

ParseHost parses an egress host entry: name, *.name, or either with :port.

func Register

func Register(p Plugin)

Register adds a plugin. Built-in plugins register themselves.

Types

type Browser

type Browser struct {
	SessionConnection string `json:"session_connection,omitempty"`
	Source            string `json:"source"`
}

Browser is the seat's browser tool.

type Context

type Context struct {
	Connections map[string]spec.Connection
}

Context is what plugins validate against.

type EgressRule

type EgressRule struct {
	Host   string `json:"host"`
	Ports  []int  `json:"ports"`
	Source string `json:"source"`
}

EgressRule allows a host (or *.suffix) on ports through the gateway.

type FieldError

type FieldError struct {
	Path, Message string
}

FieldError is a validation error at a spec path.

func Check

func Check(ctx Context, path string, p spec.AccessProfile) []FieldError

Check validates a profile with every plugin.

type GitHubGrant

type GitHubGrant struct {
	Connection  string            `json:"connection"`
	Repos       []string          `json:"repos,omitempty"`
	Permissions map[string]string `json:"permissions,omitempty"`
	Delivery    string            `json:"delivery"`
	// Host is the git host of the connection: github.com, or the
	// connection's endpoint host (GitHub Enterprise, a test server).
	Host   string `json:"host"`
	Source string `json:"source"`
}

GitHubGrant is repository access through a github connection.

type NetworkRule

type NetworkRule struct {
	CIDR     string  `json:"cidr"`
	Ports    []int64 `json:"ports,omitempty"`
	Protocol string  `json:"protocol"`
	Source   string  `json:"source"`
}

NetworkRule allows direct egress to a CIDR.

type Plugin

type Plugin interface {
	// Name is the profile field the plugin owns.
	Name() string
	// Check validates the plugin's part of profile p at path.
	Check(ctx Context, path string, p spec.AccessProfile) []FieldError
	// Apply adds the part's contribution to a seat's access.
	Apply(ctx Context, p spec.AccessProfile, source string, a *SeatAccess)
}

Plugin is one part of an access profile.

func Plugins

func Plugins() []Plugin

Plugins lists the registered plugins.

type SeatAccess

type SeatAccess struct {
	Profiles []string      `json:"profiles,omitempty"`
	Binaries []string      `json:"binaries,omitempty"`
	Network  []NetworkRule `json:"network,omitempty"`
	Browser  *Browser      `json:"browser,omitempty"`
	GitHub   []GitHubGrant `json:"github,omitempty"`
	Egress   []EgressRule  `json:"egress,omitempty"`
}

SeatAccess is a seat's resolved access: the union of its profiles.

func Resolve

func Resolve(ctx Context, profiles map[string]spec.AccessProfile, names []string) *SeatAccess

Resolve combines the named profiles into a seat's access. Names must exist.

func (*SeatAccess) Allows

func (a *SeatAccess) Allows(host string, port int) (EgressRule, bool)

Allows reports the rule that permits host:port, if any.

func (*SeatAccess) Empty

func (a *SeatAccess) Empty() bool

Empty reports whether the seat has no access beyond the platform.

func (*SeatAccess) GitHubFor

func (a *SeatAccess) GitHubFor(connection string) *GitHubGrant

GitHubFor returns the seat's grant on a github connection.

func (*SeatAccess) PodPart

func (a *SeatAccess) PodPart() *SeatAccess

PodPart is the part of the access that needs a new Pod to change: it is what the config revision covers. Egress hosts and repository grants are left out because they apply live.

func (*SeatAccess) UsesGateway

func (a *SeatAccess) UsesGateway() bool

UsesGateway reports whether the seat's traffic goes through the egress gateway.

Jump to

Keyboard shortcuts

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