columnauth

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package columnauth contains the feature-off B2 control-plane contract. The execution gate is intentionally deferred to S3/S4.

Index

Constants

View Source
const (
	MetadataProtocol  = 2
	ExecutionProtocol = 3
)

Variables

This section is empty.

Functions

func InScope

func InScope(statement model.StmtType) bool

InScope is deliberately exact: B2 column authorization applies only to a SELECT. DML continues through the pre-existing table/profile path and must never be labelled as B2 column protected.

Types

type BoundColumnUse

type BoundColumnUse struct {
	Column       ColumnIdentity
	Usage        Usage
	Site         string
	OutputIndex  int
	BindingAlias string
	ViewPath     string
}

BoundColumnUse is the S3 output/reference fact consumed by S4. OutputIndex is zero based and is ignored for reference-only sites.

type ColumnIdentity

type ColumnIdentity struct {
	Relation   RelationIdentity
	Ordinal    int
	Name       string
	TypeDigest string
}

type Input

type Input struct {
	Agent                 model.Agent
	DatasourceID          string
	Statement             model.StmtType
	PreliminaryAllowed    bool
	DatasourceSupported   bool
	CatalogConsistent     bool
	BinderDigest          string
	CatalogDigest         string
	ControlRevisionDigest string
	Relations             []RelationIdentity
	Uses                  []BoundColumnUse
	Policies              []model.Policy
	Masks                 []MaskCandidate
	Nonce                 []byte
	Now                   time.Time
}

Input is an immutable request snapshot assembled from authenticated caller state, the S3 locked manifest/catalog frame, and the control snapshot.

type MaskCandidate

type MaskCandidate struct {
	OutputIndex int
	Column      ColumnIdentity
	Identity    MaskIdentity
	Capable     bool
}

type MaskIdentity

type MaskIdentity struct {
	AlgorithmID         string
	SemanticVersion     string
	KeyID               string
	KeyVersion          int
	CanonicalParameters string
	InputType           string
	OutputType          string
}

MaskIdentity deliberately contains only immutable transform identity and type/capability facts. It never contains a value, result sample, predicate, or other data-derived input.

type OutputMask

type OutputMask struct {
	OutputIndex int
	Identity    MaskIdentity
}

type ProtectionPlan

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

ProtectionPlan is request-bound. The proof material remains unexported; callers can only verify it against the original request facts and consume the already-decided mask positions.

func Authorize

func Authorize(input Input) ProtectionPlan

Authorize applies the frozen priority order. Every failure is represented by a stable enum and never includes an unauthorized identifier.

func (ProtectionPlan) Allowed

func (plan ProtectionPlan) Allowed() bool

func (ProtectionPlan) Digest

func (plan ProtectionPlan) Digest() string

func (ProtectionPlan) Masks

func (plan ProtectionPlan) Masks() []OutputMask

func (ProtectionPlan) Reason

func (plan ProtectionPlan) Reason() Reason

func (ProtectionPlan) Verify

func (plan ProtectionPlan) Verify(input Input) bool

Verify proves that a plan belongs to the same request nonce and immutable binding/control/catalog facts. It is intentionally impossible to validate a copied plan with only its public digest.

type Reason

type Reason string

Reason is a stable, identity-only authorization result. It is safe to put in a public error envelope: none of the values contains a relation or column name supplied by the database.

const (
	ReasonAllow                 Reason = "ALLOW"
	ReasonAgentDenied           Reason = "AUTH_AGENT_DENIED"
	ReasonStatementDenied       Reason = "AUTH_STATEMENT_CLASS_DENIED"
	ReasonDatasourceUnsupported Reason = "AUTH_DATASOURCE_UNSUPPORTED"
	ReasonRelationDenied        Reason = "AUTH_RELATION_DENIED"
	ReasonRelationGrantMissing  Reason = "AUTH_RELATION_GRANT_MISSING"
	ReasonIdentityUnproven      Reason = "AUTH_IDENTITY_UNPROVEN"
	ReasonColumnGrantMissing    Reason = "AUTH_COLUMN_GRANT_MISSING"
	ReasonMaskMeetUndefined     Reason = "AUTH_MASK_MEET_UNDEFINED"
	ReasonMaskCapabilityMissing Reason = "AUTH_MASK_CAPABILITY_MISSING"
)

type RelationIdentity

type RelationIdentity struct {
	DatabaseID         string
	StableObjectID     string
	Schema             string
	Name               string
	CatalogFingerprint string
	BindingAlias       string
	ViewPath           string
}

RelationIdentity and ColumnIdentity are the catalog identities used by the authorizer. Names aid exact policy matching, while DatabaseID/StableObjectID and ordinal/type digest are the authority-bearing identities.

type Usage

type Usage string
const (
	UsageOutput    Usage = "output"
	UsageReference Usage = "reference"
)

Jump to

Keyboard shortcuts

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