domain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package domain holds the leaf vocabulary shared by the authorization package, the store, and the service layer: tenant identifiers, capability atoms, scopes, and the canonical error sentinels. It imports nothing from this module so every layer can depend on it without cycles.

Index

Constants

View Source
const MaxRuleItems = 500

MaxRuleItems bounds one rule's selector items (projects, environments and keys together), below the rule audit events' list bounds so an oversized rule is refused by name rather than failing at its audit write.

View Source
const SubjectSourceExternalID = "externalId"

SubjectSourceExternalID is the ordinary subject source.

View Source
const SubjectSourceUserName = "userName"

SubjectSourceUserName is the one spelling the ADR refuses by name.

Variables

View Source
var (
	ErrNoSuchTemplate = errors.New("no such role template")
	ErrTemplateScope  = errors.New("this role template does not apply at this scope")
)

ErrNoSuchTemplate names an unknown template; ErrTemplateScope names a template applied at a level its ADR row does not admit.

View Source
var ErrAmbiguousProviderSlug = fmt.Errorf("%w: ambiguous provider slug", ErrInvalid)

ErrAmbiguousProviderSlug refuses a bare slug that names providers of more than one kind.

View Source
var ErrConflict = errors.New("conflict")

ErrConflict is the uniform outcome for a request the caller IS authorized to make but the current state refuses: a name already in use among live siblings, or a parent that still has children (v1 deletes never cascade — see the hierarchy handoff). It is reached only after authorization succeeded, so it discloses nothing a caller could not already read; the fixed message per code means it names no specific row either way.

View Source
var ErrEmailIDNA = fmt.Errorf("%w: internationalized email domains are not supported", ErrInvalid)

ErrEmailIDNA refuses an internationalized domain: v1 admits ASCII domains only (social-signin spec 2.5, a named refusal).

View Source
var ErrEmailMalformed = fmt.Errorf("%w: malformed email address", ErrInvalid)

ErrEmailMalformed refuses an address that is not a bare canonical addr-spec.

View Source
var ErrInvalid = errors.New("invalid request")

ErrInvalid is a malformed request the contract could not reject on shape alone — a name outside the grammar, a reorder list that does not name the project's environments. It is decided before or independently of any tenant resolution and therefore discloses nothing about what exists.

View Source
var ErrLimitExceeded = errors.New("limit exceeded")

ErrLimitExceeded is a structural bound refusing an operation by name — the ops spec's environment-count cap being the first. Distinct from ErrConflict so the fixed-per-code message can state the bound, which is what "loud refusal naming the budget" requires of a response body that may not carry anything derived from the request.

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is the canonical "no such row" — and, per the permission-model ADR's unauthorized ≡ nonexistent rule, also the uniform outcome for every tenant-scoped request the principal may not perform. Callers must not be able to distinguish the two.

View Source
var ErrPKICertificateRetention error = pkiCertificateRetentionError{}

ErrPKICertificateRetention retains issuance and revocation evidence, including expired and failed records. Deleting a parent is not a PKI retention policy.

View Source
var ErrSubjectSourceCore = errors.New(
	"domain: a core-schema attribute path is not a SCIM subject source; use externalId or an extension schema")

ErrSubjectSourceCore refuses a core-schema URN as a subject source.

View Source
var ErrSubjectSourceEmpty = errors.New("domain: a SCIM binding must declare a subject source")

ErrSubjectSourceEmpty refuses a binding with no declared subject source.

View Source
var ErrSubjectSourceShape = errors.New(
	"domain: a SCIM subject source must be externalId or a urn:-qualified extension attribute path")

ErrSubjectSourceShape refuses a subject source that is neither `externalId` nor a schema-qualified extension path.

View Source
var ErrSubjectSourceUserName = errors.New("domain: userName is refused as a SCIM subject source")

ErrSubjectSourceUserName refuses `userName` as a binding's subject source BY NAME (§5.1). RFC 7643 defines `userName` as `caseExact: false` and server-unique, which contradicts byte-exact identity material; it keeps its RFC semantics as a lookup attribute and nothing more.

View Source
var ErrUnauthenticated = errors.New("unauthenticated")

ErrUnauthenticated is the uniform outcome when no usable authentication artifact was presented. Absent, malformed, unknown, expired, revoked, generation-superseded and epoch-superseded artifacts all answer this, so presentation reveals nothing about which artifacts exist — the same indistinguishability rule as unauthorized ≡ nonexistent, one layer earlier.

View Source
var ErrUnauthorized = errors.New("unauthorized")

ErrUnauthorized is the uniform refusal for instance-scoped operations, where there is no tenant object whose nonexistence could be mimicked — the probe contract is grant refusal, not tenancy.

OperatorSet is the encryption-model ADR's instance operator set, in the order the `operator` template seeds it.

Functions

func CanonicalEmail

func CanonicalEmail(raw string) (string, error)

CanonicalEmail returns the stored form of an email address for accounts.email and registration_signups.email (social-signin spec 2.5): exactly one bare addr-spec as net/mail parses it, with no display name, comment, group, angle brackets or surrounding space; an ASCII domain, lowercased, with no trailing dot and no address literal; the local part byte-preserved; at most 254 bytes. Uniqueness and domain-allowlist matching are over this string. Only a verified accounts.email (email_verified_at set) is a login identifier, an existing address for sign-up, or unique; an unverified one is legacy contact data and never an authentication, linking or uniqueness key.

func CheckSubjectSource

func CheckSubjectSource(path string) error

CheckSubjectSource validates a binding's declared subject-source attribute path. The rule is an ALLOWLIST, not "anything but userName": §5.1 admits `externalId` or a declared enterprise/custom extension path, and every other core attribute is mutable display metadata that must never become identity material. `userName` is refused by name and case-insensitively, because SCIM attribute names are case-insensitive and a case-sensitive refusal is a refusal in name only.

func IsCIIssuerType

func IsCIIssuerType(t IssuerType) bool

IsCIIssuerType reports whether t is a CI platform, which is what makes the `event_name` pin mandatory: a CI issuer mints tokens for events an untrusted contributor can trigger, and `pull_request_target` in particular carries the ordinary ref-form subject a production binding names.

func IsCapability

func IsCapability(c Capability) bool

IsCapability reports whether c is in the closed set.

func IsIssuerType

func IsIssuerType(t IssuerType) bool

IsIssuerType reports whether t is one of the three configured platforms.

func IsMachineClass

func IsMachineClass(c PrincipalClass) bool

IsMachineClass reports whether c is one of the machine classes.

func IsMappableTemplate

func IsMappableTemplate(t Template) bool

IsMappableTemplate reports whether a mapping row may target t.

func IsMintableOrigin

func IsMintableOrigin(k OriginKind) bool

IsMintableOrigin reports whether the grant API may write this origin kind.

func IsProviderKind

func IsProviderKind(k ProviderKind) bool

IsProviderKind reports membership of the closed set a SCIM binding may reference (§1): oidc and saml only.

func IsSCIMCause

func IsSCIMCause(c SCIMCause) bool

IsSCIMCause reports membership of the closed set.

func IsServiceAccountKind

func IsServiceAccountKind(c PrincipalClass) bool

IsServiceAccountKind reports whether c may be declared at service-account creation. Kind is immutable afterwards, so this is the only gate.

func IsSystemOrigin

func IsSystemOrigin(k OriginKind) bool

IsSystemOrigin reports whether the SCIM engine may write this origin kind.

func MachineMayHold

func MachineMayHold(c PrincipalClass, cap Capability) bool

MachineMayHold reports whether a principal of machine class c may hold capability cap. Unknown class = false, fail-closed.

func MachineMayHoldRevealByOptIn

func MachineMayHoldRevealByOptIn(c PrincipalClass) bool

MachineMayHoldRevealByOptIn reports whether class c is one the per-project machine-reveal opt-in can admit `reveal` onto.

func MachineMayHoldRevealHistoryByPin

func MachineMayHoldRevealHistoryByPin(c PrincipalClass) bool

MachineMayHoldRevealHistoryByPin reports whether class c may hold `reveal-history` while an active non-current pin requires it. Pins name a workload principal, so the automation condition is currently unsatisfiable.

func SplitExtensionPath

func SplitExtensionPath(path string) (urn, attribute string, ok bool)

SplitExtensionPath splits a subject-source extension path into its schema URN and the attribute it names. It reports false for a path that is not an extension path at all (`externalId`), so callers do not have to re-derive the shape CheckSubjectSource already validated.

func WhereUnionContainsInProject

func WhereUnionContainsInProject(outers []Where, inner Where, project ProjectID, keyFolders map[string]string) bool

WhereUnionContainsInProject checks the additive union, including selectors whose exceptions complement one another. The finite witnesses partition the symbolic selector space, rather than enumerating the current catalogue: an unnamed environment and unnamed keys in every folder region represent future objects too.

Types

type AxisMode

type AxisMode string

AxisMode reads an axis's items: exceptions under AxisAll, the complete list under AxisOnly.

const (
	AxisAll  AxisMode = "all"
	AxisOnly AxisMode = "only"
)

type Capability

type Capability string

Capability is one atom from the permission-model ADR's CLOSED set. The whole set is declared below (#55); Capabilities() is the closed enumeration the grant API validates against, so a capability string that is not an atom is refused rather than stored as an unreachable row.

const (
	// Environment atoms.
	CapRead          Capability = "read"
	CapReveal        Capability = "reveal"
	CapRevealHistory Capability = "reveal-history"
	CapEdit          Capability = "edit"
	CapPublish       Capability = "publish"
	CapPin           Capability = "pin"

	// Project atoms.
	CapDefinitionsEdit  Capability = "definitions-edit"
	CapProjectSettings  Capability = "project-settings"
	CapManageIdentities Capability = "manage-identities"
	CapManageAdapters   Capability = "manage-adapters"

	// Org / project.
	CapManageMembers Capability = "manage-members"
	// Org.
	CapManageProjects Capability = "manage-projects"

	// The instance operator set (encryption-model ADR #14).
	CapBackupExport     Capability = "backup-export"
	CapRestore          Capability = "restore"
	CapRotateRootKey    Capability = "rotate-root-key"
	CapRotateMasterKey  Capability = "rotate-master-key"
	CapRotateDEK        Capability = "rotate-dek"
	CapReencrypt        Capability = "reencrypt"
	CapInstanceConfig   Capability = "instance-config"
	CapInstanceDirector Capability = "instance-directory"

	// CapSCIMProvision is the scim-provisioning amendment (c): org scope,
	// machine-only, never grantable to a human, system-created with the
	// provisioning binding and refused through the grant API (#73 mints it).
	CapSCIMProvision Capability = "scim-provision"

	// CapAuditRead is the audit-model ADR's amendment part 1: reading the
	// trail is surveillance power over colleagues — its own capability, an
	// ordinary additive downward-inheriting grant, never bundled into
	// manage-members.
	CapAuditRead Capability = "audit-read"

	// CapCredentialReset is the human-auth ADR's administrator-issued reset
	// authority (#54), valid at org and instance scope.
	CapCredentialReset Capability = "credential-reset"

	// CapReportDeliveryStatus is the condition-reporting ADR's D1(b) atom: one
	// value-free, closed-vocabulary delivery-target status report for an
	// environment. Workload-only, never implied by `read`.
	CapReportDeliveryStatus Capability = "report-delivery-status"

	// CapCryptoUse and CapCryptoManage are the transit ADR's two atoms (#156,
	// permission-model declared amendment 2026-09-26). crypto-use authorizes
	// the transit data plane at environment scope and is on the workload and
	// automation allowlists; crypto-manage authorizes key management at
	// project scope and is human-only. Neither is implied by any other atom
	// and neither is seeded by a template.
	CapCryptoUse    Capability = "crypto-use"
	CapCryptoManage Capability = "crypto-manage"
	// CapIssueCertificate is the private-PKI amendment's atom (#154, pki ADR
	// D4): request, renew and revoke X.509 leaf certificates through an
	// instance certificate profile bound to the environment. It reads and
	// writes no value, definition or grant, and is never implied by `read`.
	CapIssueCertificate Capability = "issue-certificate"
)

func Capabilities

func Capabilities() []Capability

Capabilities returns the closed atom set, sorted, for enumeration surfaces and the registry-completeness tests.

func ExpandTemplate

func ExpandTemplate(t Template, at Level) ([]Capability, error)

ExpandTemplate returns the capability list a template creates at the given level, in a stable order. It refuses an unknown template and a level the template's ADR row does not admit — the expansion is the only place the template name exists, so a wrong level must fail here rather than silently seed a shorter list.

type CollectedRevisionError

type CollectedRevisionError struct {
	Revision int64
	Policy   string
}

CollectedRevisionError is the loud post-authorization refusal for a lineage row whose value-bearing payload has been collected. The revision and stored policy are safe detail: the caller named the former and is authorized to read the latter's scope.

func (*CollectedRevisionError) Error

func (e *CollectedRevisionError) Error() string

func (*CollectedRevisionError) SafeDetail

func (e *CollectedRevisionError) SafeDetail() string

func (*CollectedRevisionError) Unwrap

func (e *CollectedRevisionError) Unwrap() error

type CredentialKind

type CredentialKind string

CredentialKind discriminates HOW a credential authenticates its service account. The ADR requires the discriminator to exist before a second kind does: "the API and schema MUST NOT assume the bearer token is the only kind". #61 shipped the discriminator with one value; #62 shipped the second as a row type, exactly as the ADR predicted — no change to the grant model, no re-granting, no principal churn.

const (
	// CredentialHikyoToken is the hikyo-issued opaque bearer token: something
	// at rest on the workload's host.
	CredentialHikyoToken CredentialKind = "hikyo-token"
	// CredentialOIDCFederation is a standing permission for an externally
	// issued OIDC identity to authenticate as one service account. NOTHING is
	// at rest: the row holds no secret, which is why a restore may re-activate
	// it where a bearer verifier is permanently dead.
	CredentialOIDCFederation CredentialKind = "oidc-federation"
)

type CredentialLifetime

type CredentialLifetime string

CredentialLifetime is the ADR's typed lifetime. `indefinite` is a VALUE, not a large number: it is unreachable by raising any ceiling, which is the whole point of typing it rather than encoding it as a distant instant.

const (
	LifetimeFinite     CredentialLifetime = "finite"
	LifetimeIndefinite CredentialLifetime = "indefinite"
)

type EnvID

type EnvID string

Tenant identifiers. Distinct types so the proof-signature analyzer can ban them from store-method signatures: a caller-supplied tenant id must never be able to reach a chain predicate (tenant-isolation ADR).

type Grant

type Grant struct {
	Capability Capability
	Scope      Scope
}

Grant is the permission-model ADR's triple: (principal, capability, scope). The principal is implied by the lookup; a zero Scope is an instance-scope grant. Grants are purely additive — absence is denial, there are no deny rules.

type IssuerType

type IssuerType string

IssuerType is the closed set of federation issuer platforms. It is declared at configuration time rather than inferred from the issuer URL, because the per-platform binding rules differ — a Forgejo or GitHub Actions binding MUST pin `event_name`, a Kubernetes one has no such claim — and inferring the type from a URL would let renaming a deployment change the security rules that apply to it.

const (
	IssuerKubernetes    IssuerType = "kubernetes"
	IssuerForgejo       IssuerType = "forgejo"
	IssuerGitHubActions IssuerType = "github-actions"
)

type JWKSMode

type JWKSMode string

JWKSMode is the API/database compatibility encoding of an issuer key source. Runtime models use a closed key-source value so mode and static material cannot drift.

const (
	// JWKSDiscovery is the default: the issuer's discovery document names a
	// JWKS endpoint, and keys are fetched and cached with a bounded staleness
	// window.
	JWKSDiscovery JWKSMode = "discovery"
	// JWKSStatic is the configured alternative for air-gapped installations
	// and deployments whose issuer discovery endpoint Hikyo cannot reach. It
	// is deliberately not the default: a static-only installation breaks
	// silently on the day someone rotates the issuer's keys.
	JWKSStatic JWKSMode = "static"
)

type Level

type Level int

Level is the depth a Scope addresses.

const (
	LevelNone Level = iota
	LevelOrg
	LevelProject
	LevelEnv
)

func DeepestLevel

func DeepestLevel(c Capability) (Level, bool)

DeepestLevel returns the deepest scope level an atom may be granted at.

func MachineScopeDepth

func MachineScopeDepth(c PrincipalClass) (Level, bool)

MachineScopeDepth returns the shallowest level a machine class may be granted at; a grant shallower than it is refused. Unknown class = LevelEnv with ok=false, fail-closed.

type OrgID

type OrgID string

Tenant identifiers. Distinct types so the proof-signature analyzer can ban them from store-method signatures: a caller-supplied tenant id must never be able to reach a chain predicate (tenant-isolation ADR).

type OriginKind

type OriginKind string

OriginKind is one kind of grant origin (scim-provisioning amendment (a)): a grant row exists while at least one origin holds it, and is revoked — with the session-generation advance — when its last origin is released.

const (
	// OriginManual is the only mintable kind today: an ordinary human grant,
	// carrying the granting principal.
	OriginManual OriginKind = "manual"
	// OriginBreakGlass is the local-host recovery grant. It is NOT manual:
	// manual(granted_by) names a granting principal whose own authority was
	// evaluated, and break-glass is by the ADR's own words "the only
	// authorization path in the system not evaluated against a grant" — it
	// has no granting principal to name. See the handoff for the reading.
	OriginBreakGlass OriginKind = "break-glass"
	// OriginSCIM, OriginStructural and OriginLockoutRetention arrive with
	// #73; declared here so the closed enumeration is the ADR's, not a
	// subset that a later ticket has to widen silently.
	OriginSCIM             OriginKind = "scim"
	OriginStructural       OriginKind = "structural"
	OriginLockoutRetention OriginKind = "lockout-retention"
	// OriginRegistration holds the template grant a registration policy
	// applied at sign-up (social-signin spec 2.2); its subject is the policy's
	// authority principal. Its writer is the sign-up transaction (#607); the
	// grant API takes no origin parameter, so it cannot be forged there.
	OriginRegistration OriginKind = "registration"
)

type PrincipalClass

type PrincipalClass string

PrincipalClass discriminates a principal for the normative machine allowlists. Humans are one class; machines carry the credential class the machine-identities ADR fixes.

const (
	ClassHuman     PrincipalClass = "human"
	ClassDeveloper PrincipalClass = "developer"
	// ClassWorkload — delivery credentials: read, plus the value-free
	// delivery-target status report.
	ClassWorkload PrincipalClass = "workload"
	// ClassAutomation — CI `apply` credentials.
	ClassAutomation PrincipalClass = "automation"
	// ClassProvisioning — the SCIM provisioning connection (#73).
	ClassProvisioning PrincipalClass = "provisioning-connection"
	// ClassInstanceConn — the instance-connection principal of the
	// multi-instance directory tier (#71).
	ClassInstanceConn PrincipalClass = "instance-connection"
)

func MachineClasses

func MachineClasses() []PrincipalClass

MachineClasses returns the closed machine class set, sorted.

type PrincipalID

type PrincipalID string

PrincipalID identifies a principal (human or machine) in the grant table.

type ProjectID

type ProjectID string

Tenant identifiers. Distinct types so the proof-signature analyzer can ban them from store-method signatures: a caller-supplied tenant id must never be able to reach a chain predicate (tenant-isolation ADR).

type ProviderKind

type ProviderKind string

ProviderKind is the identity-protocol family of a federated provider and of its external identities, the single source of the kind spellings (the service's OIDCKind, SAMLKind and OAuth2Kind are these values).

const (
	ProviderOIDC   ProviderKind = "oidc"
	ProviderSAML   ProviderKind = "saml"
	ProviderOAuth2 ProviderKind = "oauth2" // social sign-in (#605); never a SCIM binding kind
)

type ProviderRef

type ProviderRef struct {
	Kind ProviderKind
	Slug string
}

ProviderRef names a federated provider on every request, response and flag (social-signin spec 2.6). Slugs are unique per provider table only, so the kind is part of the name. An empty Kind is a bare slug awaiting resolution.

func ParseProviderRef

func ParseProviderRef(s string) (ProviderRef, error)

ParseProviderRef reads `<kind>:<slug>` or a bare `<slug>`.

func ResolveProviderRef

func ResolveProviderRef(ref ProviderRef, enabled []ProviderRef) (ProviderRef, error)

ResolveProviderRef finds ref among the enabled providers. A bare slug resolves only when exactly one kind carries it.

func (ProviderRef) String

func (r ProviderRef) String() string

String renders the `<kind>:<slug>` form.

type Rule

type Rule struct {
	ID         string
	Principal  PrincipalID
	Capability Capability
	Org        OrgID
	Where      Where
}

Rule is one stored rule row with its selector.

func (Rule) Reaches

func (r Rule) Reaches(c Capability, at Level, s Scope, key *RuleKey) bool

Reaches reports whether the rule satisfies one formula atom (capability c evaluated at level `at`) against the resolved chain s, optionally for one key. The caller has already validated the rule.

  • Org and instance atoms are never satisfied: rules cover listed projects only.
  • A project atom needs every environment of the project (all, with no exception in that project).
  • An environment atom needs the environment on the axis.
  • A key-narrowed rule satisfies an atom ONLY when the operation passed a key and that key matches; every operation that passes no key (bulk reveal, export, delivery, ...) is out of its reach. Publish proves its complete changed-key selection before materializing a snapshot.
  • manage-members never satisfies an ordinary atom: rule creation and revocation use selector containment at the chokepoint, so narrowed management cannot escape through a legacy scope-wide grant operation.

func (Rule) Validate

func (r Rule) Validate() error

Validate is the shape authority for a rule, applied on every write AND on every read: a stored row that does not validate reaches nothing.

type RuleKey

type RuleKey struct {
	ID     string
	Folder string
}

RuleKey is the key a key-aware authorization addresses, resolved from the database inside the authorizing transaction. ID is empty for a key being created, which only folder items can match.

type RuleKeyItem

type RuleKeyItem struct {
	Folder   string
	KeyID    string
	IsFolder bool
}

RuleKeyItem is one key-axis item: a folder path (exact match on a key's folder, "" being the catalogue root) or a single key by its stable id.

type RuleShape

type RuleShape int

RuleShape is the narrowest Where a capability may sit on (ADR D2, D5).

const (
	// ShapeKey may be narrowed by environment and by key.
	ShapeKey RuleShape = iota
	// ShapeEnv may be narrowed by environment, never by key.
	ShapeEnv
	// ShapeProject needs every environment and every key of its projects.
	ShapeProject
)

func RuleShapeOf

func RuleShapeOf(c Capability) (RuleShape, bool)

RuleShapeOf reports the shape a capability may take on a rule, and whether a rule may carry it at all.

type SCIMAttention

type SCIMAttention string

SCIMAttention is one enumerated attention state on a binding (§9). Each is audited on entry and on exit and names a cause and a remediation.

const (
	// AttentionProviderUnavailable — the referenced provider is disabled or
	// removed; the binding's entire wire surface fails closed (§1).
	AttentionProviderUnavailable SCIMAttention = "provider_unavailable"
	// AttentionLockoutRetention — a `lockout-retention` origin is holding a
	// grant the IdP withdrew (§2.4).
	AttentionLockoutRetention SCIMAttention = "lockout_retention"
	// AttentionManualGrantsRemain — the IdP deprovisioned a user who still
	// holds manual grants in this org (§5.3).
	AttentionManualGrantsRemain SCIMAttention = "manual_grants_remain"
	// AttentionInertMapping — a mapping row names a group that no longer
	// exists (§5.4, Group DELETE).
	AttentionInertMapping SCIMAttention = "inert_mapping"
	// AttentionStale — no IdP contact past the staleness threshold (§9).
	AttentionStale SCIMAttention = "stale"
	// AttentionPostRestore — from restore until re-mint plus the first
	// completed re-assertion cycle (§9.1).
	AttentionPostRestore SCIMAttention = "post_restore"
)

func SCIMAttentionStates

func SCIMAttentionStates() []SCIMAttention

SCIMAttentionStates returns the closed enumeration, sorted.

type SCIMCause

type SCIMCause string

SCIMCause is the triggering operation recorded on a `lockout-retention` origin and on the attention state it raises (§10's closed `cause` enum).

const (
	CauseDeprovision   SCIMCause = "deprovision"
	CauseUserDeleted   SCIMCause = "user_deleted"
	CauseMemberRemoved SCIMCause = "member_removed"
	CauseGroupDeleted  SCIMCause = "group_deleted"
	CauseMappingDelete SCIMCause = "mapping_deleted"
	CauseBindingDelete SCIMCause = "binding_deleted"
	// CauseReactivation is an EXIT cause only: the identity provider set
	// `active` back to true, which ends the deprovisioned-with-remainder
	// condition. No retention is ever created under it.
	CauseReactivation SCIMCause = "reactivation"
)

func SCIMCauses

func SCIMCauses() []SCIMCause

SCIMCauses returns the closed enumeration, sorted.

type SCIMOriginKey

type SCIMOriginKey struct {
	Binding    string
	MappingRow string
	Group      string
}

SCIMOriginKey is the identity half of a `scim(binding, mapping_row, group)` origin (§2). The three parts are encoded into `grant_origins.subject`, which is one column, so the encoding is here rather than spread across writers.

Why all three when the mapping row id alone determines the other two: an origin chip must be readable on the membership line WITHOUT a join into the SCIM tables, because the membership surface authorizes `manage-members` and the SCIM tables answer to `scim-provision` — different proofs, different operations. A self-describing subject is what lets "why can they?" be answered on the line the ADR says it must be answered on.

func ParseSCIMOriginSubject

func ParseSCIMOriginSubject(s string) (SCIMOriginKey, bool)

ParseSCIMOriginSubject is the exact inverse. It reports false for anything this package did not write — a malformed subject is a storage defect, and a caller that guesses at it would release the wrong origin.

func (SCIMOriginKey) Subject

func (k SCIMOriginKey) Subject() string

Subject renders the key into the origin's `subject` column.

type SCIMRetentionKey

type SCIMRetentionKey struct {
	Binding string
	Cause   SCIMCause
}

SCIMRetentionKey is the identity of a `lockout-retention` origin: which binding's release caused the conversion, and which operation triggered it.

Both are encoded into the origin's `subject` column, for the same reason the `scim` origin encodes three parts: a retention origin SURVIVES its binding (§6 step 2), so by the time it is cured the binding row may be gone and no join could recover the id §10 requires the cure event to carry. Recording it on the origin makes the pair joinable after the fact, which is the only time anyone reads it.

func ParseSCIMRetentionSubject

func ParseSCIMRetentionSubject(s string) (SCIMRetentionKey, bool)

ParseSCIMRetentionSubject is the exact inverse.

func (SCIMRetentionKey) Subject

func (k SCIMRetentionKey) Subject() string

Subject renders the key into the origin's `subject` column.

type Scope

type Scope struct {
	Org     OrgID
	Project ProjectID
	Env     EnvID
}

Scope addresses a node in the tenant chain as the request names it: org, org+project, or org+project+env. The zero value addresses nothing.

func (Scope) Level

func (s Scope) Level() (Level, error)

Level derives the addressed depth and rejects gaps (an env without a project is not an address, it is a bug).

type SingletonTopology

type SingletonTopology struct {
	HA     bool   `json:"ha"`
	NodeID string `json:"node_id"`
}

SingletonTopology is an enrolled process identity, not a replica count.

type SingletonTopologyChange

type SingletonTopologyChange struct {
	Before SingletonTopology `json:"before"`
	After  SingletonTopology `json:"after"`
}

SingletonTopologyChange retains preparation and installation identities. The existing configuration generation fences each committed assignment.

type Template

type Template string

Template names one role template from the closed v1 set.

const (
	TemplateViewer     Template = "viewer"
	TemplateEditor     Template = "editor"
	TemplatePublisher  Template = "publisher"
	TemplateRevealer   Template = "revealer"
	TemplateHistorian  Template = "historian"
	TemplateMaintainer Template = "maintainer"
	TemplateAdmin      Template = "admin"
	TemplateOperator   Template = "operator"
)

func Templates

func Templates() []Template

Templates returns the closed template name set, sorted.

type Where

type Where struct {
	Projects []ProjectID
	EnvMode  AxisMode
	Envs     map[ProjectID][]EnvID
	KeyMode  AxisMode
	Keys     map[ProjectID][]RuleKeyItem
}

Where is a rule's reach. Items are bound per project: an environment or key item belongs to exactly one of the rule's projects, and a project with no items on an `all` axis is unnarrowed on it.

func (Where) ContainsWhereInProject

func (outer Where) ContainsWhereInProject(inner Where, project ProjectID, keyFolders map[string]string) bool

ContainsWhereInProject compares selectors symbolically, including future environments and keys. keyFolders must come from the current transaction; missing key metadata refuses containment instead of assuming a folder.

func (Where) EnvNarrowed

func (w Where) EnvNarrowed() bool

EnvNarrowed reports whether the Where narrows environments anywhere.

func (Where) KeyNarrowed

func (w Where) KeyNarrowed() bool

KeyNarrowed reports whether the Where narrows keys anywhere.

Jump to

Keyboard shortcuts

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