Documentation
¶
Overview ¶
Package model is the policy bundle as data: parsing, validation, and versioning of the authored document (PLAN M3). It knows the closed input and output vocabularies and rejects anything outside them at authoring time, which is what makes an unreachable or contradictory rule a compile error.
Index ¶
- Constants
- Variables
- func Enumerations() map[Code]map[string][]string
- func HostPatternCovers(a, b string) bool
- func MatchAxes() []string
- func MatchesHostPattern(host, pattern string) bool
- func ParameterWords(code Code, param, value string) string
- func Parameters(code Code) []string
- func ValidDeviceFieldName(name string) bool
- func ValidDeviceFieldValue(value string) bool
- func ValidHostPattern(p string) bool
- func ValidScopeName(name string) bool
- func Vocabularies() map[Vocabulary][]string
- type AdditionalContext
- type AlgorithmBans
- type AlgorithmFloor
- type AlgorithmProfile
- type ArgumentKind
- type ArgumentSpec
- type Attestation
- type AuthMethod
- type Basis
- type Bundle
- type CacheHint
- type CacheKeyComponent
- type ChannelType
- type Code
- type CommandForm
- type Concurrency
- type Context
- type ContextMatch
- type CredentialEntry
- type CredentialKind
- type CredentialMethod
- type Day
- type Destination
- type Device
- type DeviceMatch
- type Duration
- type Effect
- type Enforcement
- type ExecMode
- type ExecutionRung
- type ExpiryPosture
- type ExternalReference
- type FilterAction
- type FilterMode
- type FilterPolicy
- type FilterRule
- type ForwardPermissions
- type GlobalRequestPermissions
- type GlobalRequestType
- type Grant
- type GrantContext
- type GrantMatch
- type GrantOrigin
- type GrantScope
- type Input
- type Match
- type MatchAxis
- type MatchedTerm
- type Obligation
- type ObligationKind
- type PortRange
- type ReachRung
- type Rejection
- type Rejections
- type RequestPermissions
- type RequestType
- type RestrictedCommand
- type RestrictedExec
- type Route
- type RouteIntent
- type Rule
- type ScopeDecl
- type Shape
- type Snapshot
- type Subject
- type SubjectMatch
- type Target
- type TargetMatch
- type Tenant
- type TimeWindow
- type Unanswered
- type Username
- type UsernameSource
- type Vocabulary
- type YAMLProblem
Constants ¶
const ( // DeviceFieldMaxNameLen bounds `<name>`. DeviceFieldMaxNameLen = 64 // DeviceFieldMaxValueLen bounds the value, which must also be non-empty. DeviceFieldMaxValueLen = 256 // DeviceFieldMaxPerEntry bounds how many ride on one ladder entry. DeviceFieldMaxPerEntry = 16 // DeviceFieldNamePattern is the name grammar. DeviceFieldNamePattern = `^[a-z0-9_-]{1,64}$` )
The shape rules for a `device_field.<name>` parameter (PLAN §5.2).
They are the whole of what is checked here, and that is the point. The contract enumerates no field names and never will, because customer-written drivers are first-class (proxy D13): a closed list here would make an estate's own driver unauthorable without a release of this server. So shape is checkable and meaning is the driver's — an unrecognised *name* is a capability question this compiler cannot answer (M17, phase 0006) and, on the proxy, a skipped rung rather than an error.
These constants duplicate the ones in internal/contract on purpose: this package does not import the wire types, and contract_agreement_test.go asserts the two agree. A duplicate a test compares is cheaper than an import that makes the compiler inseparable from the transport.
const MaxScopeNameLen = 128
MaxScopeNameLen bounds a grant scope's name, here and wherever a grant is written.
const SchemaVersion = 1
SchemaVersion is the bundle document format this server understands. It is the *document's* version and has nothing to do with the contract's `policy_version`, which governs the wire vocabulary a proxy declares: the two move independently and neither is derived from the other.
Variables ¶
var BanAxes = []string{"key_exchanges", "ciphers", "macs", "host_keys", "public_key_auth"}
BanAxes is every ban axis, in the contract's order and spelling.
Functions ¶
func Enumerations ¶ added in v0.52.0
Enumerations names, for each code with a worded parameter, every value that parameter can take, sorted. The console says each in its own words (an ICU select), and a test holds its catalogue to this list.
func HostPatternCovers ¶
HostPatternCovers reports whether pattern a matches everything pattern b does. It is what the compiler's unreachability check is built from, and it is deliberately conservative: where it cannot prove coverage it says no, so an unreachable rule may go unreported but a reachable one is never refused.
func MatchAxes ¶ added in v0.53.0
func MatchAxes() []string
MatchAxes are the five input axes a rule's match is made of (§5.1), in the order a rule's match is read.
func MatchesHostPattern ¶
MatchesHostPattern reports whether a hostname matches one pattern. Matching is case-insensitive, because DNS is.
func ParameterWords ¶ added in v0.52.0
ParameterWords is the English a worded parameter's value reads as, or the value itself when it is not worded: what Message() substitutes, for a caller that must say one parameter alone — a north-bound client of a version that was sent prose in its place.
func Parameters ¶ added in v0.40.0
Parameters names the parameters a code's message is filled from, sorted and without repeats: the values a client may build its own sentence from. A code with no message names none.
func ValidDeviceFieldName ¶
ValidDeviceFieldName reports whether a device field name has the shape the contract specifies.
func ValidDeviceFieldValue ¶
ValidDeviceFieldValue reports whether a device field value has the shape the contract specifies: non-empty and at most DeviceFieldMaxValueLen bytes.
func ValidHostPattern ¶
ValidHostPattern reports whether a pattern is an exact hostname or a single leading wildcard (`*.prod.example.com`). Anything else — a wildcard in the middle, a bare `*`, an empty string — is refused: a pattern language nobody can predict is a policy nobody can review.
func ValidScopeName ¶
ValidScopeName reports whether name can be a grant scope: what a grant carries and a rule matches with `grant.scopes`. It is trimmed, non-empty, at most MaxScopeNameLen characters, and free of control characters — the rule a grant's scope is held to when it is created (0012).
func Vocabularies ¶ added in v0.53.0
func Vocabularies() map[Vocabulary][]string
Vocabularies is every closed vocabulary a bundle's value can be drawn from, by its identifier, each with its members in declared order.
Types ¶
type AdditionalContext ¶
type AdditionalContext struct {
// Text is set when the value is a string.
Text string
// Fields is set when the value is an object.
Fields map[string]any
}
AdditionalContext is `grant_context.additional_context`: a string or an object. A number, a list or a boolean is a contract violation rather than something to coerce, because this is stored verbatim for an auditor.
func (AdditionalContext) MarshalJSON ¶
func (a AdditionalContext) MarshalJSON() ([]byte, error)
MarshalJSON writes the shape that was read: a string or an object, and nothing else. A number, a list or a boolean never round-trips through this type, which is what keeps a decision record's copy verbatim.
func (*AdditionalContext) UnmarshalJSON ¶
func (a *AdditionalContext) UnmarshalJSON(b []byte) error
UnmarshalJSON accepts exactly the two shapes the contract names.
type AlgorithmBans ¶ added in v0.6.0
type AlgorithmBans struct {
KeyExchanges []string `yaml:"key_exchanges,omitempty"`
Ciphers []string `yaml:"ciphers,omitempty"`
MACs []string `yaml:"macs,omitempty"`
HostKeys []string `yaml:"host_keys,omitempty"`
PublicKeyAuth []string `yaml:"public_key_auth,omitempty"`
}
AlgorithmBans are SSH algorithm identifiers a route's proxy→target leg must not offer, one optional list per axis, each spelled exactly as SSH spells it (Hoplock/proxy#69). A ban only removes: it is subtracted from what the profile and the floor would offer, never from a library's "supported" set, and curve25519-sha256 and curve25519-sha256@libssh.org are one exchange.
func (*AlgorithmBans) Axis ¶ added in v0.6.0
func (b *AlgorithmBans) Axis(axis string) []string
Axis returns the bans on one axis, by its contract name.
func (*AlgorithmBans) Empty ¶ added in v0.6.0
func (b *AlgorithmBans) Empty() bool
Empty reports whether nothing is banned on any axis.
func (*AlgorithmBans) Merge ¶ added in v0.6.0
func (b *AlgorithmBans) Merge(other *AlgorithmBans) *AlgorithmBans
Merge returns the union of two ban sets, axis by axis: this one's names in their order, then the other's that this one lacks. Nil when both are empty. A name repeated across the two is not a repeat: a route may ban what the bundle already bans everywhere.
type AlgorithmFloor ¶ added in v0.6.0
type AlgorithmFloor string
AlgorithmFloor is the minimum key exchange a route's proxy→target leg must negotiate (Hoplock/proxy#69). Unset means no floor. The levels are an ordered ladder compared by rank alone; which exchanges each accepts is each proxy build's to declare, and is never encoded here. An unknown level is refused at authoring time and never coerced.
const ( AlgorithmFloorUnset AlgorithmFloor = "" AlgorithmFloorModernKex AlgorithmFloor = "modern-kex" AlgorithmFloorPQHybridKex AlgorithmFloor = "pq-hybrid-kex" )
func (AlgorithmFloor) Rank ¶ added in v0.6.0
func (f AlgorithmFloor) Rank() int
Rank orders the levels: unset 0, modern-kex 1, pq-hybrid-kex 2. A later level goes above the top, because every exchange a level accepts is accepted by every level below it (the contract's nesting rule).
func (*AlgorithmFloor) UnmarshalYAML ¶ added in v0.6.0
func (f *AlgorithmFloor) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an AlgorithmFloor.
type AlgorithmProfile ¶
type AlgorithmProfile string
AlgorithmProfile is the per-route algorithm profile for targets that speak something x/crypto does not enable by default. Unset means the default profile, which is the only one that is not a weakening.
const ( AlgorithmProfileUnset AlgorithmProfile = "" AlgorithmProfileDefault AlgorithmProfile = "default" AlgorithmProfileLegacyRSASHA1 AlgorithmProfile = "legacy-rsa-sha1" AlgorithmProfileLegacyDevice AlgorithmProfile = "legacy-device" )
func (*AlgorithmProfile) UnmarshalYAML ¶
func (p *AlgorithmProfile) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an AlgorithmProfile.
func (AlgorithmProfile) WidensKeyExchange ¶ added in v0.6.0
func (p AlgorithmProfile) WidensKeyExchange() bool
WidensKeyExchange reports whether a profile widens the key-exchange axis a floor narrows. The proxy refuses such a profile with any floor; the rule is the axis and not the word "legacy" — legacy-rsa-sha1 changes only signatures and takes a floor.
type ArgumentKind ¶
type ArgumentKind string
ArgumentKind is the permitted shape of one argument position. `any` is named rather than smuggled in as an empty prefix, so every unconstrained position is greppable.
const ( ArgumentKindUnset ArgumentKind = "" ArgumentKindLiteral ArgumentKind = "literal" ArgumentKindPrefix ArgumentKind = "prefix" ArgumentKindOneOf ArgumentKind = "oneof" ArgumentKindAny ArgumentKind = "any" )
func (*ArgumentKind) UnmarshalYAML ¶
func (k *ArgumentKind) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an ArgumentKind.
type ArgumentSpec ¶
type ArgumentSpec struct {
Kind ArgumentKind `yaml:"kind"`
Value string `yaml:"value,omitempty"`
Values []string `yaml:"values,omitempty"`
Optional bool `yaml:"optional,omitempty"`
}
ArgumentSpec is the permitted shape of one argument position.
type Attestation ¶
type Attestation struct {
AssertedBy string `yaml:"asserted_by"`
Reference string `yaml:"reference"`
AssertedAt string `yaml:"asserted_at,omitempty"`
}
Attestation is the source of an attested enforcement rung.
type AuthMethod ¶
type AuthMethod string
AuthMethod is how the identity authenticated to the proxy.
const ( AuthMethodUnset AuthMethod = "" AuthMethodCert AuthMethod = "cert" AuthMethodPasswordMFA AuthMethod = "password-mfa" )
func (*AuthMethod) UnmarshalYAML ¶
func (m *AuthMethod) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an AuthMethod.
type Basis ¶
type Basis string
Basis is why a decision came out the way it did: a rule matched, or nothing did and the always-present default-deny fired (PLAN §5.3).
type Bundle ¶
type Bundle struct {
// SchemaVersion must equal SchemaVersion. An unknown version is
// refused rather than best-guessed: a document this server does not
// understand is one whose omissions it would be inventing.
SchemaVersion int `yaml:"schema_version"`
// Tenant owns this bundle.
Tenant Tenant `yaml:"tenant"`
// Description is free text for whoever reads the bundle next.
Description string `yaml:"description,omitempty"`
// Timezone is the IANA location that a rule's `days` and `time_of_day`
// are read in. Empty means UTC. It is resolved at parse time, so
// evaluation stays pure.
Timezone string `yaml:"timezone,omitempty"`
// Labels is the declared label vocabulary: which label keys exist and
// which values each may take. A rule matching a label outside it is a
// compile error, which is what turns a typo into a message instead of a
// rule that silently never fires.
Labels map[string][]string `yaml:"labels,omitempty"`
// Groups is the declared group vocabulary, for the same reason.
Groups []string `yaml:"groups,omitempty"`
// Scopes says what the policy holds about a grant scope beyond the rules
// that match it (M16): whether access in it is privileged, and what a
// decision does when the probe confirming an external window for it
// cannot answer. A scope declared nowhere is not privileged and takes the
// deployment's default. Nothing here is a match axis — the engine reads
// grants exactly as before — so declaring a scope changes no decision
// that did not involve an external window.
Scopes map[string]ScopeDecl `yaml:"scopes,omitempty"`
// AlgorithmBans is a ban EVERYWHERE: added to every allow route's own
// bans at compile time (Hoplock/proxy#69). A ban is per route on the
// wire and no proxy setting can apply or lift one, so "everywhere" is
// this server putting it on every route it serves. It is the first step
// of the emergency runbook: publish it, then `cache_invalidate` with
// `all`, then `session_kill` for the sessions that negotiated it.
AlgorithmBans *AlgorithmBans `yaml:"algorithm_bans,omitempty"`
// Rules are evaluated in order, first match wins. The default-deny at
// the end is not authored and cannot be removed.
Rules []Rule `yaml:"rules"`
// contains filtered or unexported fields
}
Bundle is a policy bundle as authored: a declarative YAML document over a closed vocabulary (M3).
The bundle names its tenant, because tenancy selects which compiled program is served (M18) — one bundle, one program, one tenant.
func Parse ¶
Parse reads a policy bundle, rejecting anything outside the closed vocabulary. It returns Rejections — every reason at once, in source order, because an author who has to compile five times to find five mistakes stops trusting the compiler.
Parse establishes only that the *document* decoded: valid YAML, no unknown key, no value outside an enum. It fails only where there is no usable bundle to go on with. Everything else — the document's own shape (Validate) and everything semantic: an unreachable rule, a contradiction, a reference to something that does not exist, an unconstrained axis — belongs to the compiler, so that an author sees the whole list in one compile rather than one class of mistake at a time.
func (*Bundle) Location ¶
Location is the location a rule's day and time-of-day terms are read in. It is never nil on a parsed bundle.
func (*Bundle) Validate ¶
func (b *Bundle) Validate() Rejections
Validate checks the document's shape: that the version is one this server understands, that the bundle names a tenant and its vocabularies, and that every rule has a unique id and an effect it can act on. The compiler calls it, so a bundle built in Go rather than parsed gets exactly the same checks.
type CacheHint ¶
type CacheHint struct {
// Key is the components the sharing scope is derived from. It must
// include CacheKeySubject: a key shared across identities serves one
// user another user's policy.
Key []CacheKeyComponent `yaml:"key"`
// TTLSeconds is the lifetime, which is this server's to set.
TTLSeconds int32 `yaml:"ttl_seconds"`
}
CacheHint is this server authorising the proxy to reuse a decision (PLAN §5.4). It is authored per rule, not globally: the lifetime is policy, so omitting it for anything sensitive is how every connection stays re-decided.
type CacheKeyComponent ¶
type CacheKeyComponent string
CacheKeyComponent is one input a cache hint's key is derived from (PLAN §5.4). The key selects the sharing scope, so the set is closed and named rather than a format string: a key shared across identities serves one user another user's policy, and that has to be a compile error rather than a typo.
const ( // CacheKeySubject is the authenticated subject id. A key without it is // shared across identities and is rejected. CacheKeySubject CacheKeyComponent = "subject" // CacheKeyTarget is the target hostname. CacheKeyTarget CacheKeyComponent = "target" // CacheKeyTargetPort is the target port. CacheKeyTargetPort CacheKeyComponent = "target-port" // CacheKeyProxy is the proxy that asked (conn.proxy_id). CacheKeyProxy CacheKeyComponent = "proxy" // CacheKeyAuthMethod is how the identity authenticated. CacheKeyAuthMethod CacheKeyComponent = "auth-method" // CacheKeyRule is the rule that matched, so a bundle change that moves // a session to a different rule cannot be served from an old entry. CacheKeyRule CacheKeyComponent = "rule" )
func (*CacheKeyComponent) UnmarshalYAML ¶
func (c *CacheKeyComponent) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a CacheKeyComponent.
type ChannelType ¶
type ChannelType string
ChannelType is an SSH channel a session may open, in either direction — the coarsest of the proxy's three policy axes (proxy D5a).
const ( // ChannelSession carries scp, sftp, an interactive shell and a one-shot // command alike, which is why permitting it says very little on its own. ChannelSession ChannelType = "session" // ChannelDirectTCPIP is a local forward. Its whole meaning is the // destination in its payload, so permitting it without a destination // list is a compile error rather than a wildcard. ChannelDirectTCPIP ChannelType = "direct-tcpip" // ChannelForwardedTCPIP is a connection arriving on a remote forward. ChannelForwardedTCPIP ChannelType = "forwarded-tcpip" // ChannelX11 is an X11 forwarding channel. ChannelX11 ChannelType = "x11" // ChannelAuthAgent is agent forwarding. ChannelAuthAgent ChannelType = "auth-agent@openssh.com" )
func (*ChannelType) UnmarshalYAML ¶
func (c *ChannelType) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a ChannelType.
type Code ¶
type Code string
Code identifies a rejection. Every member has a message template in `messages`, and the `exhaustive` linter's map check is what keeps that true: adding a code without a message fails the build rather than producing a rejection nobody can read.
const ( CodeDocumentMalformed Code = "policy.document_malformed" CodeKeyUnknown Code = "policy.key_unknown" CodeKeyDuplicate Code = "policy.key_duplicate" CodeValueWrongType Code = "policy.value_wrong_type" CodeValueUnknown Code = "policy.value_unknown" CodeDurationMalformed Code = "policy.duration_malformed" CodeSchemaVersionUnsupported Code = "policy.schema_version_unsupported" CodeTenantMissing Code = "policy.tenant_missing" CodeNoRules Code = "policy.no_rules" CodeTimezoneUnknown Code = "policy.timezone_unknown" CodeLabelVocabularyMalformed Code = "policy.label_vocabulary_malformed" CodeGroupVocabularyMalformed Code = "policy.group_vocabulary_malformed" )
Document-scope codes: the bundle as a whole, and the document as YAML.
The first six are the document failing to decode, each with its position (the rejection's Line) and typed parameters rather than the YAML library's sentence (0065): the problem a document that is not YAML at all has, a key the schema does not know or that is given twice, a value of the wrong shape, a value outside a closed vocabulary, and a duration that does not parse.
const ( CodeRuleIDMissing Code = "rule.id_missing" CodeRuleIDDuplicate Code = "rule.id_duplicate" CodeRuleUnreachable Code = "rule.unreachable" CodeRuleEffectMissing Code = "rule.effect_missing" CodeRuleDenyCarriesRoute Code = "rule.deny_carries_route" CodeRuleAllowNeedsRoute Code = "rule.allow_needs_route" CodeRuleDenyNeedsReason Code = "rule.deny_needs_reason" )
Rule-scope codes: the shape of one rule.
const ( CodeMatchUnknownGroup Code = "match.unknown_group" CodeMatchUnknownLabelKey Code = "match.unknown_label_key" CodeMatchUnknownLabel Code = "match.unknown_label_value" CodeMatchInvalidCIDR Code = "match.invalid_cidr" CodeMatchInvalidHostname Code = "match.invalid_hostname_pattern" CodeMatchEmptyTerm Code = "match.empty_term" CodeMatchInvalidWindow Code = "match.invalid_time_window" )
Match-scope codes: a rule's inputs.
const ( CodeRouteIntentMissing Code = "route.intent_missing" CodeRouteChannelsMissing Code = "route.channels_missing" CodeRouteFilterModeMissing Code = "route.filter_mode_missing" CodeRouteForwardsUnconstrained Code = "route.forward_destinations_missing" CodeRouteSubsystemsMissing Code = "route.subsystems_missing" CodeRouteFilterBothTiers Code = "route.filter_policy_both_tiers" CodeRouteRestrictedExecEmpty Code = "route.restricted_exec_empty" CodeRouteInvalidDestination Code = "route.invalid_destination" CodeRouteLadderEmpty Code = "route.ladder_empty" CodeRouteExecModeMismatch Code = "route.exec_mode_mismatch" CodeRouteFilterRuleInvalid Code = "route.filter_rule_invalid" CodeRouteRestrictedCmdInvalid Code = "route.restricted_command_invalid" CodeRouteRestrictedCmdField Code = "route.restricted_command_field_unexpected" CodeRouteRestrictedArgInvalid Code = "route.restricted_argument_invalid" CodeRouteRestrictedArgField Code = "route.restricted_argument_field_unexpected" CodeRouteDeadlineInvalid Code = "route.session_deadline_invalid" CodeRouteConcurrencyInvalid Code = "route.concurrency_invalid" CodeRouteFloorProfileConflict Code = "route.algorithm_floor_profile_conflict" CodeRouteBanIdentifierEmpty Code = "route.algorithm_ban_empty" CodeRouteBanIdentifierRepeated Code = "route.algorithm_ban_repeated" )
Route-scope codes: the snapshot a rule emits.
const ( CodeCacheKeyEmpty Code = "cache.key_empty" CodeCacheKeyNotIdentityBound Code = "cache.key_not_identity_bound" CodeCacheTTLInvalid Code = "cache.ttl_invalid" CodeCacheKeyDuplicate Code = "cache.key_component_duplicate" CodeCacheOnDeny Code = "cache.hint_on_deny" )
Cache-scope codes (PLAN §5.4).
const ( CodeCredentialMethodMissing Code = "credential.method_missing" CodeCredentialUsernameMissing Code = "credential.username_missing" CodeCredentialUsernameEmpty Code = "credential.username_empty" CodeCredentialParamWrongMethod Code = "credential.param_wrong_method" CodeCredentialPlatformMissing Code = "credential.platform_missing" CodeCredentialKindMissing Code = "credential.credential_kind_missing" CodeCredentialPostureMissing Code = "credential.expiry_posture_missing" CodeCredentialLifetimeMissing Code = "credential.lifetime_missing" CodeCredentialLifetimeInvalid Code = "credential.lifetime_invalid" CodeDeviceFieldName Code = "credential.device_field_name_invalid" CodeDeviceFieldValue Code = "credential.device_field_value_invalid" CodeDeviceFieldCount Code = "credential.device_field_too_many" CodeDeviceFieldWrongMethod Code = "credential.device_field_wrong_method" )
Credential-scope codes: one entry of the target-auth ladder.
const ( CodeEnforcementShellPermitted Code = "enforcement.interactive_shell_permitted" CodeEnforcementRequestsMissing Code = "enforcement.permitted_requests_missing" CodeEnforcementExecModeRequired Code = "enforcement.restricted_exec_required" CodeEnforcementRoleMissing Code = "enforcement.platform_role_missing" CodeEnforcementRoleUnexpected Code = "enforcement.platform_role_unexpected" CodeEnforcementDestsRequired Code = "enforcement.destinations_required" CodeEnforcementAttestationMissing Code = "enforcement.attestation_missing" CodeEnforcementAttestationUnexpected Code = "enforcement.attestation_unexpected" CodeEnforcementAppliedUnprovisioned Code = "enforcement.applied_rung_unprovisioned" )
Enforcement-scope codes: the rung must agree with the rest of the rule.
const ( CodeScopeNameInvalid Code = "scope.name_invalid" CodeScopePrivilegedFailOpen Code = "scope.privileged_fails_open" )
Scope-declaration codes: the `scopes` section (M16).
const ( CodeObligationKindMissing Code = "obligation.kind_missing" CodeObligationDuplicate Code = "obligation.duplicate" CodeObligationOnDeny Code = "obligation.on_deny" CodeObligationContradicts Code = "obligation.contradicts_route" CodeObligationApprovers Code = "obligation.approvers_unexpected" )
Obligation-scope codes.
type CommandForm ¶
type CommandForm string
CommandForm is how a restricted-exec command's arguments are specified.
const ( CommandFormUnset CommandForm = "" // CommandFormExact names the whole argv, position by position. CommandFormExact CommandForm = "exact" // CommandFormPositional names the shape of each argument position. CommandFormPositional CommandForm = "positional" )
func (*CommandForm) UnmarshalYAML ¶
func (f *CommandForm) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a CommandForm.
type Concurrency ¶
type Concurrency struct {
MaxSessionsPerSubject int32 `yaml:"max_sessions_per_subject,omitempty"`
MaxSessionsPerTarget int32 `yaml:"max_sessions_per_target,omitempty"`
}
Concurrency caps live sessions. Zero on either scope is uncapped.
type Context ¶
type Context struct {
// SourceAddr is the client address. An invalid Addr means none was
// supplied, and a rule constraining the source network cannot match it.
SourceAddr netip.Addr
// ProxyID is the proxy asking — the entry proxy on a user's first hop,
// an inner hop on a chained one (M6). Each hop asks for itself, so the
// same login and target legitimately answer differently at the edge and
// behind it.
ProxyID string
}
Context is where and when the connection is being made from.
type ContextMatch ¶
type ContextMatch struct {
// Days are the days of the week the rule applies on, read in the
// bundle's location.
Days []Day `yaml:"days,omitempty"`
// TimeOfDay is the window the rule applies in, read in the bundle's
// location. A window whose end is before its start wraps midnight.
TimeOfDay *TimeWindow `yaml:"time_of_day,omitempty"`
// SourceCIDRs are the client networks the rule applies to.
SourceCIDRs []string `yaml:"source_cidrs,omitempty"`
// ProxyIDs are the proxies the rule applies to — the proxy *asking*,
// which on a chained session is an inner hop rather than the user's
// entry proxy.
ProxyIDs []string `yaml:"proxy_ids,omitempty"`
}
ContextMatch constrains when and where the connection is made from.
type CredentialEntry ¶
type CredentialEntry struct {
// Method is which credential method this rung uses.
Method CredentialMethod `yaml:"method"`
// Username names the account to log in as. Required on every method the
// contract defines, and never derived from the identity's `login`.
Username Username `yaml:"username"`
// KeyType is the algorithm of the key the proxy generates — for
// `ephemeral-user` and `brokered-certificate`; empty leaves the proxy's
// default.
KeyType string `yaml:"key_type,omitempty"`
// CredentialRef is `brokered-key`'s opaque handle for local material on
// the proxy. No credential material travels on this API.
CredentialRef string `yaml:"credential_ref,omitempty"`
// Platform is `ephemeral-account`'s driver. Required, and never
// inferred: guessing wrong runs configuration commands against the
// wrong parser.
Platform string `yaml:"platform,omitempty"`
// CredentialKind is `ephemeral-account`'s credential kind. Required.
CredentialKind CredentialKind `yaml:"credential_kind,omitempty"`
// ExpiryPosture is `ephemeral-account`'s expiry posture. Required.
ExpiryPosture ExpiryPosture `yaml:"expiry_posture,omitempty"`
// LifetimeSeconds bounds the provisioned credential's life on
// `ephemeral-user` and `ephemeral-account` (required on the latter unless
// the posture is `accepted-risk`), and on `brokered-certificate` is an
// UPPER BOUND on the certificate's validity: this server may shorten it
// and never lengthens a certificate to it.
LifetimeSeconds int32 `yaml:"lifetime_seconds,omitempty"`
// DeviceFields is the open `device_field.<name>` namespace that sits
// beside the named `ephemeral-account` parameters. It is policy
// metadata and never credential material: nothing here brokers one as a
// secret, and nothing reads one back as an authorisation input. This
// engine is entirely opaque to their meaning — it checks the shape, and
// meaning is the driver's.
DeviceFields map[string]string `yaml:"device_fields,omitempty"`
}
CredentialEntry is one rung of the target-credential ladder: a method, the account it logs in as, and that method's parameters.
The documented parameters are fields rather than an open map, because the contract documents exactly these and a typo in an open map is a route that fails at connect time in front of a user. The one namespace that stays open is DeviceFields, and it is open for the opposite reason: the contract refuses to enumerate it because customer-written drivers are first-class, so a closed list here would make an estate's own driver unauthorable without a release of this server.
type CredentialKind ¶
type CredentialKind string
CredentialKind is the `credential_kind` parameter of an ephemeral-account entry. It has no absent-value default: defaulting hands out the weaker of two materially different exposures to a policy that never said so.
const ( CredentialKindUnset CredentialKind = "" CredentialKindPassword CredentialKind = "password" CredentialKindPublicKey CredentialKind = "publickey" )
func (*CredentialKind) UnmarshalYAML ¶
func (k *CredentialKind) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a CredentialKind.
type CredentialMethod ¶
type CredentialMethod string
CredentialMethod is how the proxy authenticates to the target (proxy D6a, D14). A route names an ordered ladder of these.
const ( // CredentialEphemeralUser creates an OS user on the target for the // session and removes it afterwards. CredentialEphemeralUser CredentialMethod = "ephemeral-user" // CredentialEphemeralAccount creates an account on a device the proxy // cannot administer as a host — a firewall, a filer, a hypervisor. CredentialEphemeralAccount CredentialMethod = "ephemeral-account" // CredentialBrokeredKey hands the proxy a per-target credential for the // session's duration only. CredentialBrokeredKey CredentialMethod = "brokered-key" // CredentialStaticKey uses material the proxy already holds. CredentialStaticKey CredentialMethod = "static-key" // CredentialBrokeredCertificate has the proxy generate a key pair for // the session and present a user certificate this server signs over its // public half (proxy D6a, Hoplock/proxy#68). The entry is policy only — // the certificate is minted per session at POST // /v1/credentials/certificate and is never a parameter. It needs policy // vocabulary 5. CredentialBrokeredCertificate CredentialMethod = "brokered-certificate" )
func (CredentialMethod) Provisions ¶
func (m CredentialMethod) Provisions() bool
Provisions reports whether this method has the proxy administer the account on the target. Only those two methods can carry an *applied* enforcement rung, because only they create the account the rung is rendered onto (PLAN §5.2).
func (*CredentialMethod) UnmarshalYAML ¶
func (m *CredentialMethod) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a CredentialMethod.
type Day ¶
type Day string
Day is a day of the week, as a rule's context match names it.
func (*Day) UnmarshalYAML ¶
UnmarshalYAML decodes a Day.
type Destination ¶
type Destination struct {
Host string `yaml:"host"`
Port int32 `yaml:"port,omitempty"`
PortRange *PortRange `yaml:"port_range,omitempty"`
}
Destination is one permitted forwarding destination: a host pattern (exact, single leading wildcard, or CIDR prefix) and at most one port constraint.
func (Destination) String ¶
func (d Destination) String() string
String renders a destination the way a rejection names it.
type Device ¶
type Device struct {
// Posture is the attributes the endpoint asserted.
Posture map[string]string
}
Device is endpoint posture, when an endpoint supplies any.
type DeviceMatch ¶
type DeviceMatch struct {
// Required demands that the endpoint supplied posture at all. Without
// it, a posture constraint on an endpoint that supplied none does not
// match — absence is never read as compliance.
Required bool `yaml:"required,omitempty"`
// Posture is attribute to permitted values.
Posture map[string][]string `yaml:"posture,omitempty"`
}
DeviceMatch constrains endpoint posture, which may be absent entirely.
type Duration ¶
Duration is a time.Duration authored as a YAML string (`8h`, `45m`).
type Enforcement ¶
type Enforcement struct {
Execution ExecutionRung `yaml:"execution,omitempty"`
Reach ReachRung `yaml:"reach,omitempty"`
// PlatformRole is the authorization `platform-authorized` claims.
PlatformRole string `yaml:"platform_role,omitempty"`
// PermittedDestinations is what `account-egress-restricted` is made of.
PermittedDestinations []Destination `yaml:"permitted_destinations,omitempty"`
// Attestation names who asserts an attested rung. This system does not
// verify the claim; it makes it attributable.
Attestation *Attestation `yaml:"attestation,omitempty"`
}
Enforcement is where a route's claim is actually enforced, on two independent axes. The absent value on either axis is proxy-side enforcement only, which is exactly what a rule that says nothing about enforcement emits — the engine never synthesises a weaker rung as a fallback.
func (Enforcement) Stated ¶
func (e Enforcement) Stated() bool
Stated reports whether this route stands anywhere other than proxy-side enforcement. Where it does not, 0008 emits no enforcement object at all: an emitted default is noise in an audit record.
type ExecMode ¶
type ExecMode string
ExecMode is which of the two tiers decides an exec request (proxy D12). The two are alternatives, never layers, which is why a route carrying both a rule list and a restricted-exec allow-list is a compile error.
const ( // ExecModeUnset is the absent value and means ExecModeFiltered. ExecModeUnset ExecMode = "" // ExecModeFiltered is the guardrail tier: an ordered rule list. ExecModeFiltered ExecMode = "filtered" // ExecModeRestricted is the boundary tier: a default-deny allow-list of // executables and permitted argument shapes. ExecModeRestricted ExecMode = "restricted" )
type ExecutionRung ¶
type ExecutionRung string
ExecutionRung is where the limit on what a session may EXECUTE is enforced.
ExecutionRungUnset is the zero value and means proxy-side enforcement only — exactly what a server that had never heard of the axis produced. It is a member of the enum rather than a hole in it, so every switch has to say what it does about "the author said nothing", and the engine never synthesises a weaker rung as a fallback: a silent downgrade is what the vocabulary exists to prevent.
const ( ExecutionRungUnset ExecutionRung = "" ExecutionProxyInspected ExecutionRung = "proxy-inspected" ExecutionNoInteractiveShell ExecutionRung = "no-interactive-shell" ExecutionAccountRestricted ExecutionRung = "account-restricted" ExecutionAccountConfined ExecutionRung = "account-confined" ExecutionPlatformAuthorized ExecutionRung = "platform-authorized" ExecutionPlatformAttested ExecutionRung = "platform-attested" )
func (ExecutionRung) Applied ¶
func (r ExecutionRung) Applied() bool
Applied reports whether this rung is one the proxy configures per session onto an account it administers. An applied rung on a route whose every ladder entry is brokered-key or static-key is refused outright by the proxy, so the compiler refuses it here (PLAN §5.2).
func (ExecutionRung) Attested ¶
func (r ExecutionRung) Attested() bool
Attested reports whether the target already enforces this rung and the proxy configures nothing. An attested rung requires an attestation; every other rung forbids one.
func (*ExecutionRung) UnmarshalYAML ¶
func (r *ExecutionRung) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an ExecutionRung.
type ExpiryPosture ¶
type ExpiryPosture string
ExpiryPosture is the `expiry_posture` parameter of an ephemeral-account entry. No absent-value default either: "the risk was accepted" is a sentence somebody writes down, never one inferred from an omission.
const ( ExpiryPostureUnset ExpiryPosture = "" ExpiryPostureTargetEnforced ExpiryPosture = "target-enforced" ExpiryPostureProxyEnforced ExpiryPosture = "proxy-enforced" ExpiryPostureAcceptedRisk ExpiryPosture = "accepted-risk" )
func (*ExpiryPosture) UnmarshalYAML ¶
func (p *ExpiryPosture) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an ExpiryPosture.
type ExternalReference ¶
type ExternalReference struct {
System string
Reference string
// WindowStart and WindowEnd are what the external system asserted. They
// are recorded, not enforced.
WindowStart time.Time
WindowEnd time.Time
// AdditionalContext is a string or an object, carried verbatim.
AdditionalContext *AdditionalContext
}
ExternalReference is the outside system behind a confirmed window (M16).
type FilterAction ¶
type FilterAction string
FilterAction is what a matched filter rule does.
const ( FilterActionAllowAndLog FilterAction = "allow_and_log" FilterActionBlockCommand FilterAction = "block_command" FilterActionWarnAndContinue FilterAction = "warn_and_continue" FilterActionKillSession FilterAction = "kill_session" )
func (*FilterAction) UnmarshalYAML ¶
func (a *FilterAction) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a FilterAction.
type FilterMode ¶
type FilterMode string
FilterMode is what happens to a command no filter rule matched. It is required on every route: a policy with no defined default is one that can fail open by omission.
const ( FilterModeUnset FilterMode = "" FilterModeWhitelist FilterMode = "whitelist" FilterModeBlacklist FilterMode = "blacklist" )
func (*FilterMode) UnmarshalYAML ¶
func (m *FilterMode) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a FilterMode.
type FilterPolicy ¶
type FilterPolicy struct {
// Mode is what happens to a command no rule matched. It is required.
Mode FilterMode `yaml:"mode"`
// Rules is the guardrail tier: an ordered rule list.
Rules []FilterRule `yaml:"rules,omitempty"`
// ExecMode names which tier decides an exec request.
ExecMode ExecMode `yaml:"exec_mode,omitempty"`
// RestrictedExec is the boundary tier: a default-deny allow-list of
// executables and the shape of their permitted arguments.
RestrictedExec *RestrictedExec `yaml:"restricted_exec,omitempty"`
}
FilterPolicy is the command filter policy for a connection. The two exec tiers are alternatives, never layers (proxy D12).
type FilterRule ¶
type FilterRule struct {
Match string `yaml:"match"`
Action FilterAction `yaml:"action"`
Message string `yaml:"message,omitempty"`
}
FilterRule is one command pattern and what happens when it matches.
type ForwardPermissions ¶
type ForwardPermissions struct {
// DirectTCPIP constrains local forwards.
DirectTCPIP []Destination `yaml:"direct_tcpip,omitempty"`
// ForwardedTCPIP constrains connections arriving on a remote forward.
ForwardedTCPIP []Destination `yaml:"forwarded_tcpip,omitempty"`
}
ForwardPermissions is which forwarding destinations a session may reach.
type GlobalRequestPermissions ¶
type GlobalRequestPermissions struct {
Types []GlobalRequestType `yaml:"types,omitempty"`
}
GlobalRequestPermissions is which connection-level global requests are relayed.
Types stays a plain named string rather than a closed enum, and the reason is the contract's: a global request is matched exactly against the name on the wire, and that name space is open — `tcpip-forward` sits beside `streamlocal-forward@openssh.com` and beside whatever a vendor ships next. Closing it here would make an estate's own request unauthorable without a release of this server, which is the same mistake as enumerating device fields. What is checked is the shape.
type GlobalRequestType ¶
type GlobalRequestType string
GlobalRequestType is a connection-level global request name.
const ( GlobalRequestTCPIPForward GlobalRequestType = "tcpip-forward" GlobalRequestCancelTCPIPForward GlobalRequestType = "cancel-tcpip-forward" GlobalRequestStreamLocalForward GlobalRequestType = "streamlocal-forward@openssh.com" GlobalRequestCancelStreamLocalForward GlobalRequestType = "cancel-streamlocal-forward@openssh.com" )
The global requests SSH and OpenSSH define today. They are named so that a bundle can be grepped for them, not to close the set.
type Grant ¶
type Grant struct {
// ID is the grant, as an explanation and an audit record name it.
ID string
// Subject is who the grant is for.
Subject string
// Origin is how the grant came to exist.
Origin GrantOrigin
// Scope is what the grant covers.
Scope GrantScope
// NotBefore and ExpiresAt bound the grant. A zero NotBefore means "from
// creation"; ExpiresAt is required of a real grant, and a zero one is
// treated as expired rather than as forever.
NotBefore time.Time
ExpiresAt time.Time
// Approvers are who approved it.
Approvers []string
// RequestRef is the request that produced it.
RequestRef string
// External is the outside system that asserted the window, when one
// did (M16).
External *ExternalReference
}
Grant is one live just-in-time grant (M10).
Its origin varies and is recorded: an administrator created it by hand, an approval workflow produced it (Enterprise E8), or an external system asserted a window and a provider confirmed it (M16). All three are the same object to the engine — that is the point — but the record carries which one it was and, where it applies, the external reference and the window that was asserted.
func (Grant) Context ¶
func (g Grant) Context() *GrantContext
Context renders the grant as the GrantContext a snapshot carries.
type GrantContext ¶
type GrantContext struct {
// GrantID is the grant this came from.
GrantID string
// Origin is how the grant came to exist.
Origin GrantOrigin
// System and Reference name the external system and its ticket, scan,
// or incident. "Explain why" that cannot name the ticket is not an
// explanation.
System string
Reference string
// WindowStart and WindowEnd are what the external system asserted. They
// are recorded, not enforced: the bound the proxy enforces is the
// session deadline, which this server set having weighed the window.
WindowStart time.Time
WindowEnd time.Time
// AdditionalContext is a JSON string or a JSON object, and nothing else.
AdditionalContext *AdditionalContext
}
GrantContext is why access was granted, carried from the grant that supplied it (M10, M16) rather than authored.
It is recorded, never read: the proxy copies all of it into every log record for the session and never parses it, matches on it, or decides from it — and neither does anything here. The decision was made before the snapshot was written.
type GrantMatch ¶
type GrantMatch struct {
// Required demands that some live grant covers this target. It is what
// "this route exists only while somebody has been granted it" is
// written as.
Required bool `yaml:"required,omitempty"`
// Scopes are the grant scope names that satisfy the rule.
Scopes []string `yaml:"scopes,omitempty"`
// Origins are the grant origins that satisfy the rule — an
// administrator's grant and an external system's confirmed window are
// the same object, and a policy may still care which.
Origins []GrantOrigin `yaml:"origins,omitempty"`
}
GrantMatch constrains the live just-in-time grants for this subject (M10).
func (*GrantMatch) Constrained ¶
func (g *GrantMatch) Constrained() bool
Constrained reports whether this grant match demands a grant at all.
type GrantOrigin ¶
type GrantOrigin string
GrantOrigin is where a live grant came from (M10, M16). All three are the same object to the engine — that is the point — but the record carries which one it was, because "explain why" that cannot name the ticket is not an explanation.
const ( // GrantOriginAdministrator is a grant an administrator created by hand. GrantOriginAdministrator GrantOrigin = "administrator" // GrantOriginWorkflow is a grant an approval workflow produced. GrantOriginWorkflow GrantOrigin = "workflow" // GrantOriginExternal is a window an external system asserted and a // provider confirmed (M16). GrantOriginExternal GrantOrigin = "external" )
func (*GrantOrigin) UnmarshalYAML ¶
func (o *GrantOrigin) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a GrantOrigin.
type GrantScope ¶
type GrantScope struct {
// Name is the scope a rule matches on, e.g. "prod-dba".
Name string
// Targets are the hostnames the grant covers, exact or with a single
// leading wildcard. Empty means every target the rule already matched.
Targets []string
// Labels are label constraints the target must satisfy.
Labels map[string]string
// Zones are the zones the grant covers. Empty means any.
Zones []string
}
GrantScope is what a grant covers.
type Input ¶
type Input struct {
// Now is the instant the decision is being made for. Day-of-week and
// time-of-day matching read it in the bundle's declared location.
Now time.Time
Subject Subject
// Device is endpoint posture, and it is a pointer because it is
// genuinely optional: plenty of endpoints supply none, and a rule that
// requires posture must not match one that has none.
Device *Device
Context Context
Target Target
// Grants are the live just-in-time grants for this subject (M10),
// including windows confirmed from external context (M16). They are an
// input like any other — not a special case bypassing the engine, which
// would be invisible to simulation and to "explain why".
Grants []Grant
}
Input is one whole evaluation's inputs. Time is a field rather than a call to time.Now(): an engine with its own clock cannot be simulated over historical traffic (0019) and cannot be tested without flakiness.
type Match ¶
type Match struct {
Subject *SubjectMatch `yaml:"subject,omitempty"`
Device *DeviceMatch `yaml:"device,omitempty"`
Context *ContextMatch `yaml:"context,omitempty"`
Target *TargetMatch `yaml:"target,omitempty"`
Grant *GrantMatch `yaml:"grant,omitempty"`
}
Match is the closed set of input axes a rule may constrain (PLAN §5.1). A nil axis is unconstrained; a constrained axis must be satisfied. All axes are ANDed, and within an axis a list of values is ORed.
func (Match) Unconstrained ¶
Unconstrained reports whether this match accepts every input — the catch-all shape.
type MatchAxis ¶
type MatchAxis string
MatchAxis names the input axis a matched term came from, so an explanation can say "the target's labels", not just "labels".
const ( // AxisSubject is the authenticated principal: id, source, groups, // claims, authentication method, MFA. AxisSubject MatchAxis = "subject" // AxisDevice is endpoint posture, which may be absent entirely. AxisDevice MatchAxis = "device" // AxisContext is time, day, source network, and the proxy asking. AxisContext MatchAxis = "context" // AxisTarget is the hostname, labels, and zone being reached. AxisTarget MatchAxis = "target" // AxisGrant is the live just-in-time grants for this subject (M10). AxisGrant MatchAxis = "grant" )
type MatchedTerm ¶
type MatchedTerm struct {
// Axis is which input axis the term came from.
Axis MatchAxis
// Term is the name of the constraint, e.g. "groups" or "labels.env".
Term string
// Value is the input value that satisfied it.
Value string
}
MatchedTerm is one input value that made a rule match.
An explanation is a first-class output of this engine, not a log line (M4): the proxy tells a user "access denied" and a session id, deliberately vague, and the operator resolves that id here into the whole story. Vague to the user, total to the auditor — and that pair only works if this side is genuinely total, which means the terms are recorded as values rather than rendered into a sentence somebody has to parse back.
func (MatchedTerm) String ¶
func (t MatchedTerm) String() string
String renders the term the way an operator reads it.
type Obligation ¶
type Obligation struct {
Kind ObligationKind `yaml:"kind"`
// ApproverGroups names who may approve, on a require-approval
// obligation. The names are checked against the bundle's declared
// groups like any other group reference.
ApproverGroups []string `yaml:"approver_groups,omitempty"`
// Message is shown to the user when the obligation is raised.
Message string `yaml:"message,omitempty"`
}
Obligation is something a matching rule requires in addition to its route.
type ObligationKind ¶
type ObligationKind string
ObligationKind is something a matching rule requires in addition to the route it serves (PLAN §5.2).
const ( // ObligationRecordSession requires the session to be captured. ObligationRecordSession ObligationKind = "record-session" // ObligationRequireApproval requires a human to approve before the // session proceeds. ObligationRequireApproval ObligationKind = "require-approval" // ObligationRequireStepUp requires a second factor beyond the one the // identity already presented. ObligationRequireStepUp ObligationKind = "require-step-up" )
func (*ObligationKind) UnmarshalYAML ¶
func (k *ObligationKind) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an ObligationKind.
type ReachRung ¶
type ReachRung string
ReachRung is where the limit on what a session may REACH is enforced. As on the execution axis, the zero value means proxy-side enforcement only.
func (ReachRung) Applied ¶
Applied reports whether this rung is rendered onto an account the proxy creates.
type Rejection ¶
type Rejection struct {
// Code is the stable identifier. It never changes meaning.
Code Code
// Rule is the id of the rule this is about, empty at document scope.
Rule string
// Line is the 1-based line in the authored source, 0 when the
// rejection is about the document rather than a place in it.
Line int
// Params are the typed values that filled the message in. They are the
// localisable payload: the console reads these, not the English.
Params map[string]string
}
Rejection is one reason a bundle was refused. It is a value, not a sentence: Code and Params are what the console renders, Message is what a terminal prints, and neither is derived from the other after the fact.
func Reject ¶
Reject builds a Rejection. Params arrive as alternating key/value pairs, which keeps call sites to one line; an odd count is a programming error and panics in tests long before it reaches an author.
func UnknownDay ¶ added in v0.52.0
UnknownDay is the rejection for a day outside the vocabulary, for a bundle built in Go rather than parsed: Parse refuses one at the enum, with the same code.
type Rejections ¶
type Rejections []Rejection
Rejections is every reason a bundle was refused, in source order.
The whole list is returned rather than the first one: an author fixing a bundle one compile at a time is an author who stops trusting the compiler.
func (Rejections) Codes ¶
func (rs Rejections) Codes() []Code
Codes lists the codes present, in order and without repeats.
func (Rejections) Error ¶
func (rs Rejections) Error() string
Error renders every rejection, one per line.
func (Rejections) Has ¶
func (rs Rejections) Has(code Code) bool
Has reports whether any rejection carries this code. It is what tests and the console's "did this specific thing go wrong" checks read.
func (Rejections) Sorted ¶
func (rs Rejections) Sorted() Rejections
Sorted returns the rejections in a deterministic order — by line, then by code, then by rule. The same bundle must be refused with the same text every time, or a CI diff of two compiles is unreadable.
type RequestPermissions ¶
type RequestPermissions struct {
// Types is the permitted request types.
Types []RequestType `yaml:"types,omitempty"`
// Subsystems are permitted by name, so `sftp` is deniable on its own.
// The pointer tells "no subsystems are permitted" (absent) from "the
// author opened the subsystem axis and named nothing", which is the
// unconstrained axis the compiler refuses.
Subsystems *[]string `yaml:"subsystems,omitempty"`
}
RequestPermissions is which in-channel requests a session may make.
func (*RequestPermissions) Permits ¶
func (p *RequestPermissions) Permits(t RequestType) bool
Permits reports whether this allow-list permits a request type.
type RequestType ¶
type RequestType string
RequestType is an in-channel request (proxy D5a axis 2). `subsystem` is deliberately absent: subsystems are permitted by name so that sftp can be denied while a shell stays.
const ( RequestPTYReq RequestType = "pty-req" RequestShell RequestType = "shell" RequestExec RequestType = "exec" RequestEnv RequestType = "env" RequestX11Req RequestType = "x11-req" RequestAuthAgentReq RequestType = "auth-agent-req" )
func (RequestType) Interactive ¶
func (r RequestType) Interactive() bool
Interactive reports whether permitting this request gives the session an interactive shell, which is what `no-interactive-shell` claims it does not have (PLAN §5.2).
func (*RequestType) UnmarshalYAML ¶
func (r *RequestType) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a RequestType.
type RestrictedCommand ¶
type RestrictedCommand struct {
Executable string `yaml:"executable"`
Form CommandForm `yaml:"form"`
Argv []string `yaml:"argv,omitempty"`
Args []ArgumentSpec `yaml:"args,omitempty"`
}
RestrictedCommand is one permitted executable and the shape of its arguments.
type RestrictedExec ¶
type RestrictedExec struct {
Commands []RestrictedCommand `yaml:"commands"`
}
RestrictedExec is the restricted tier's allow-list.
type Route ¶
type Route struct {
// Intent is whether the path may traverse hops (PLAN §5.2). Which hop
// is next is computed from the fleet graph, not authored here.
Intent RouteIntent `yaml:"intent"`
// Target overrides the requested hostname. Empty means the target the
// proxy asked about.
Target string `yaml:"target,omitempty"`
// Port overrides the requested port. Zero means the one asked about.
Port int32 `yaml:"port,omitempty"`
// Channels is the channel-type allow-list. The key is required and the
// pointer is how absence is told from `channels: []`, which denies
// every channel and is a policy an author may well mean.
Channels *[]ChannelType `yaml:"channels"`
// Requests is the in-channel request allow-list. Absent means the axis
// is not policed; present means an allow-list, and an empty one denies
// every request.
Requests *RequestPermissions `yaml:"requests,omitempty"`
// Forwards is the permitted forwarding destinations. Absent means no
// forwarding is described, which is a compile error on a route that
// permits a forwarding channel.
Forwards *ForwardPermissions `yaml:"forwards,omitempty"`
// GlobalRequests is the connection-level global request allow-list.
// Absent means they are relayed unpoliced.
GlobalRequests *GlobalRequestPermissions `yaml:"global_requests,omitempty"`
// Filter is the command filter policy: a rule list or a restricted-exec
// allow-list, never both (proxy D12).
Filter FilterPolicy `yaml:"filter"`
// Credentials is the ordered target-credential ladder (proxy D14). Nil
// leaves the proxy its locally configured method; a declared but empty
// ladder is a compile error, because an empty ladder on the wire is a
// denial written as a list.
Credentials []CredentialEntry `yaml:"credentials,omitempty"`
// AlgorithmProfile is the per-route algorithm profile, for targets that
// speak something x/crypto does not enable by default.
AlgorithmProfile AlgorithmProfile `yaml:"algorithm_profile,omitempty"`
// AlgorithmFloor is the minimum key exchange the proxy→target leg must
// negotiate: a sibling of the profile, never a value inside it, because
// a profile only weakens and a floor is a minimum (Hoplock/proxy#69).
AlgorithmFloor AlgorithmFloor `yaml:"algorithm_floor,omitempty"`
// AlgorithmBans are identifiers the proxy must not offer on the leg, per
// axis, applied last: a ban always wins. A bundle's own top-level
// `algorithm_bans` is added to every allow route's at compile time,
// which is how a ban "everywhere" is stated — no proxy setting can apply
// or lift one.
AlgorithmBans *AlgorithmBans `yaml:"algorithm_bans,omitempty"`
// Enforcement is where this route's claim is actually enforced, on each
// of two independent axes. It is a property of the route, never of a
// ladder entry: one policy stating two guarantees would leave the audit
// record unable to say which was in force.
Enforcement Enforcement `yaml:"enforcement,omitempty"`
// MaxSessionDuration bounds the session's life. Evaluation turns it
// into Snapshot.SessionDeadline, an absolute instant.
MaxSessionDuration Duration `yaml:"max_session_duration,omitempty"`
// RequireSessionCapture makes the route run only if the session is
// recorded. The pointer distinguishes "said nothing" from an explicit
// `false`, which is what makes the contradiction with a record-session
// obligation detectable.
RequireSessionCapture *bool `yaml:"require_session_capture,omitempty"`
// Concurrency caps live sessions per subject and per target. Only the
// proxy can count them; exceeding one is a policy denial, not an outage.
Concurrency Concurrency `yaml:"concurrency,omitempty"`
}
Route is the whole-connection snapshot an allow rule emits, as authored.
type RouteIntent ¶
type RouteIntent string
RouteIntent is what a rule says about the path to the target: whether the session must reach it directly or may traverse hops. Which hop is actually next is computed from the fleet graph (M6, phase 0006) and is not a policy statement, so this enum stops short of `direct`/`nexthop` on the wire.
const ( // RouteIntentDirect permits the target only where the enforcing proxy // reaches it without another hop. RouteIntentDirect RouteIntent = "direct" // RouteIntentHopsPermitted permits a path that traverses hops. RouteIntentHopsPermitted RouteIntent = "hops-permitted" )
func (*RouteIntent) UnmarshalYAML ¶
func (r *RouteIntent) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a RouteIntent.
type Rule ¶
type Rule struct {
// ID identifies the rule in every explanation and audit record, so it
// is required and unique.
ID string `yaml:"id"`
// Description is free text.
Description string `yaml:"description,omitempty"`
// Match is what the rule matches on. An empty match matches everything,
// which is how a catch-all is written — and why the compiler reports
// every later rule as unreachable.
Match Match `yaml:"match,omitempty"`
// Effect is allow or deny.
Effect Effect `yaml:"effect"`
// Reason is what an operator reads when they resolve a denied
// decision's id. Required on a deny.
Reason string `yaml:"reason,omitempty"`
// Route is the snapshot an allow serves. Required on an allow,
// forbidden on a deny.
Route *Route `yaml:"route,omitempty"`
// Obligations are what a permitted session must also do.
Obligations []Obligation `yaml:"obligations,omitempty"`
// Cache is this rule's cache hint, authored per rule rather than
// globally (PLAN §5.4): omit it for anything sensitive and every
// connection is re-decided.
Cache *CacheHint `yaml:"cache,omitempty"`
// contains filtered or unexported fields
}
Rule is one ordered rule: what it matches, and what it does when it matches.
type ScopeDecl ¶
type ScopeDecl struct {
// Description is free text for whoever reads the bundle next.
Description string `yaml:"description,omitempty"`
// Privileged marks access the policy treats as privileged. An external
// window in this scope falls closed when its probe cannot answer, never
// open, and an integration may push one only if its scope binding is
// permitted privileged access at all (M16).
Privileged bool `yaml:"privileged,omitempty"`
// Unanswered is what an unanswered probe means for a window in this
// scope. Unset takes the deployment's default — closed, for a privileged
// scope, whatever that default is.
Unanswered Unanswered `yaml:"unanswered,omitempty"`
// contains filtered or unexported fields
}
ScopeDecl is one grant scope's declaration.
type Shape ¶ added in v0.52.0
type Shape string
Shape is what a YAML value is, or what the schema expects one to be: the `found` and `expected` of CodeValueWrongType.
const ( ShapeString Shape = "string" ShapeInteger Shape = "integer" ShapeNumber Shape = "number" ShapeBoolean Shape = "boolean" ShapeList Shape = "list" ShapeMapping Shape = "mapping" ShapeNull Shape = "null" ShapeTimestamp Shape = "timestamp" // ShapeOther is a shape outside the ones above: a binary value, a // custom tag, a Go type the schema does not name. ShapeOther Shape = "other" )
The shapes a value can take.
type Snapshot ¶
type Snapshot struct {
// Rule is the id of the rule that produced this snapshot. It is on the
// snapshot as well as the explanation because a decision record read
// back years later is one object, not two.
Rule string
Intent RouteIntent
Target string
Port int32
// Channels is the channel-type allow-list. A non-nil empty slice denies
// every channel; it is never nil on a snapshot, because the contract
// requires the field.
Channels []ChannelType
Requests *RequestPermissions
Forwards *ForwardPermissions
GlobalRequests *GlobalRequestPermissions
Filter FilterPolicy
Credentials []CredentialEntry
AlgorithmProfile AlgorithmProfile
AlgorithmFloor AlgorithmFloor
// AlgorithmBans is the route's bans merged with the bundle's; nil when
// nothing is banned.
AlgorithmBans *AlgorithmBans
Enforcement Enforcement
// SessionDeadline is the absolute instant the session ends. The zero
// time means the route sets no deadline.
SessionDeadline time.Time
// RequireSessionCapture is resolved: a record-session obligation makes
// it true whatever the route said, and the compiler has already refused
// the rule that said both.
RequireSessionCapture bool
Concurrency Concurrency
// GrantContext is carried from the grant that supplied the access, when
// one did.
GrantContext *GrantContext
Cache *CacheHint
Obligations []Obligation
}
Snapshot is what an evaluation produces: the whole-connection policy, with the route's authored bounds resolved against the evaluation's time input.
type Subject ¶
type Subject struct {
// ID is the subject id this server established. It is not the client
// typed `login`.
ID string
// Source is the identity provider the subject came from.
Source string
// Groups are the groups the mapping resolved (M7).
Groups []string
// Claims are the mapped IdP claims, never raw token claim names.
Claims map[string]string
// AuthMethod is how the identity authenticated to the proxy.
AuthMethod AuthMethod
// MFA reports whether a second factor was used.
MFA bool
}
Subject is the authenticated principal.
type SubjectMatch ¶
type SubjectMatch struct {
IDs []string `yaml:"ids,omitempty"`
Sources []string `yaml:"sources,omitempty"`
Groups []string `yaml:"groups,omitempty"`
// Claims is key to permitted values. All listed keys must match.
Claims map[string][]string `yaml:"claims,omitempty"`
AuthMethods []AuthMethod `yaml:"auth_methods,omitempty"`
// MFA constrains whether a second factor was used. Nil is
// unconstrained, which is not the same as `mfa: false`.
MFA *bool `yaml:"mfa,omitempty"`
}
SubjectMatch constrains the authenticated principal.
type Target ¶
type Target struct {
Hostname string
Port int32
Zone string
// Labels are the target's labels, e.g. env=prod, kind=appliance.
Labels map[string]string
}
Target is the host being reached.
type TargetMatch ¶
type TargetMatch struct {
// Hostnames are exact names or a single leading wildcard.
Hostnames []string `yaml:"hostnames,omitempty"`
// Labels is key to permitted values, checked against the bundle's
// declared vocabulary.
Labels map[string][]string `yaml:"labels,omitempty"`
Zones []string `yaml:"zones,omitempty"`
}
TargetMatch constrains the host being reached.
type Tenant ¶
type Tenant string
Tenant owns a bundle, and therefore a compiled program. It is part of the lookup key a caller uses to obtain a program, never something this package reads from ambient state.
type TimeWindow ¶
type TimeWindow struct {
// FromMinutes and ToMinutes are minutes since midnight, [0, 1440).
FromMinutes int
ToMinutes int
}
TimeWindow is a time-of-day window, authored as `HH:MM-HH:MM` in 24-hour form. A window whose end is not after its start wraps midnight, which is how an out-of-hours rule is written.
func (TimeWindow) Contains ¶
func (w TimeWindow) Contains(minute int) bool
Contains reports whether a minute-of-day falls in the window, wrapping midnight where the window does.
func (TimeWindow) String ¶
func (w TimeWindow) String() string
String renders the window the way it was authored.
func (*TimeWindow) UnmarshalYAML ¶
func (w *TimeWindow) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes a TimeWindow.
type Unanswered ¶
type Unanswered string
Unanswered is what a decision does with an external window whose probe could not answer — timed out, unreachable, or answered nonsense (M16). The probe is the authoritative direction, so a window it could not confirm is neither confirmed nor refuted, and the policy says which way that falls rather than a provider or a default nobody chose. The decision record says which way it fell.
const ( // UnansweredUnset is the zero value: the deployment's default applies // (`access_context.unanswered`) — and a privileged scope falls closed // whatever that default is. UnansweredUnset Unanswered = "" // UnansweredClosed means the window does not count, and the decision is // made without it. For access only that window could grant, that is a // denial whose record says the probe did not answer. UnansweredClosed Unanswered = "closed" // UnansweredOutage means that when the decision depends on the window, // the call answers as an outage (M11) rather than as a decision either // way: nobody is told "access denied" because a scanner's API was slow. UnansweredOutage Unanswered = "outage" // UnansweredOpen means the pushed window counts although its probe could // not confirm it — the push is the only direction that works when the // external system cannot be reached. Never for a privileged scope: the // access this exists to gate is the access least safe to grant on a stale // assertion. UnansweredOpen Unanswered = "open" )
func (*Unanswered) UnmarshalYAML ¶
func (u *Unanswered) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML decodes an Unanswered.
type Username ¶
type Username struct {
Source UsernameSource
Value string
}
Username is the account a ladder entry logs in as.
It is a closed source plus an optional literal rather than a string or a template, so that the one derivation the contract closed off — the identity's client-typed `login` — is not expressible. There is no syntax in which to write it.
type UsernameSource ¶
type UsernameSource string
UsernameSource is where a ladder entry's target account name comes from.
The contract requires `params.username` on every method it defines and the proxy refuses a route that omits it, so a ladder entry always names one. The enum exists so that the one source the contract closed off — the identity's client-typed `login` — cannot be named at all: it is not a member, and there is no free-form expression language in which to spell it.
const ( // UsernameUnset is the zero value: no username authored. It is a // compile error, never a thing to fill in. UsernameUnset UsernameSource = "" // UsernameLiteral is a fixed account name written in the bundle. UsernameLiteral UsernameSource = "literal" // UsernameSubject is the authenticated subject id, which this server // established and no client typed. UsernameSubject UsernameSource = "subject" // UsernameSubjectLocalPart is the subject id up to the first `@`, for // estates whose subject ids are email-shaped and whose targets will not // take an `@` in a user name. UsernameSubjectLocalPart UsernameSource = "subject-local-part" )
type Vocabulary ¶ added in v0.52.0
type Vocabulary string
Vocabulary names a closed vocabulary of the bundle: the `vocabulary` of CodeValueUnknown. Each is one of the kinds in kind.go, or the derivations a username has.
const ( VocabularyEffect Vocabulary = "effect" VocabularyRouteIntent Vocabulary = "route_intent" VocabularyChannelType Vocabulary = "channel_type" VocabularyRequestType Vocabulary = "request_type" VocabularyCredentialMethod Vocabulary = "credential_method" VocabularyCredentialKind Vocabulary = "credential_kind" VocabularyExpiryPosture Vocabulary = "expiry_posture" VocabularyAlgorithmProfile Vocabulary = "algorithm_profile" VocabularyAlgorithmFloor Vocabulary = "algorithm_floor" VocabularyFilterMode Vocabulary = "filter_mode" VocabularyExecMode Vocabulary = "exec_mode" VocabularyFilterAction Vocabulary = "filter_action" VocabularyCommandForm Vocabulary = "command_form" VocabularyArgumentKind Vocabulary = "argument_kind" VocabularyExecutionRung Vocabulary = "execution_rung" VocabularyReachRung Vocabulary = "reach_rung" VocabularyObligationKind Vocabulary = "obligation_kind" VocabularyGrantOrigin Vocabulary = "grant_origin" VocabularyUnanswered Vocabulary = "unanswered" VocabularyCacheKeyComponent Vocabulary = "cache_key_component" VocabularyAuthMethod Vocabulary = "auth_method" VocabularyDay Vocabulary = "day" VocabularyUsernameSource Vocabulary = "username_source" )
The vocabularies a value can fall outside of.
type YAMLProblem ¶ added in v0.52.0
type YAMLProblem string
YAMLProblem is why a document is not YAML: the `problem` of CodeDocumentMalformed. It is classified from the YAML library's own message (yamlProblemOf), so an author reads what to do rather than the parser's vocabulary.
const ( // YAMLTabIndentation is a tab where YAML indents with spaces. YAMLTabIndentation YAMLProblem = "tab_indentation" // YAMLStructure is a key, a list item or a value that is not where its // indentation puts it: the commonest mistake, and the parser's least // readable message. YAMLStructure YAMLProblem = "structure" // YAMLUnterminated is a quoted string, a flow list or a flow mapping // opened and never closed. YAMLUnterminated YAMLProblem = "unterminated" // YAMLCharacter is a character that cannot stand where it is unquoted, // or an escape that does not exist. YAMLCharacter YAMLProblem = "character" // YAMLEncoding is text that is not UTF-8, or holds a control character. YAMLEncoding YAMLProblem = "encoding" // YAMLTag is a malformed `!tag` or `%directive`; a bundle needs neither. YAMLTag YAMLProblem = "tag" // YAMLAlias is an anchor or an alias that is undefined, contains itself // or expands too far. YAMLAlias YAMLProblem = "alias" // YAMLUnreadable is any other problem the parser reports. YAMLUnreadable YAMLProblem = "unreadable" )
The problems a document that is not YAML can have.