Documentation
¶
Overview ¶
Package viewerpolicy fences authorization snapshots against durable policy writes.
Index ¶
- Constants
- Variables
- func AddInputs(ctx context.Context, db *sql.DB, tx *sql.Tx, source string, in Inputs) error
- func Bump(ctx context.Context, db *sql.DB) error
- func CheckSharedConfigVersion(ctx context.Context, tx *sql.Tx, expected int64) error
- func Fence(ctx context.Context, db *sql.DB, tx *sql.Tx, expected int64) error
- func PublishConfig(ctx context.Context, db *sql.DB, in Inputs) error
- func Read(ctx context.Context, db *sql.DB) (int64, error)
- func RebuildInputs(ctx context.Context, db *sql.DB, sources ...Rebuild) error
- func RulesInputs(in Inputs, specs []core.LibraryExclusion)
- type Inputs
- type Rebuild
Constants ¶
const ( SourceConfig = "config" SourceSafety = "safety" SourceRules = "rules" )
Input sources.
Variables ¶
var ErrChanged = errors.New("viewer policy changed")
Functions ¶
func AddInputs ¶
AddInputs records in for source inside the caller's transaction, which must also be the one that makes the policy durable. It never removes rows.
func CheckSharedConfigVersion ¶
CheckSharedConfigVersion rechecks the exact version captured by a held config policy lease using the same transaction that already fenced the durable viewer-policy epoch. A clustered caller must not substitute a separate pooled connection or silently ignore missing schema/errors. The epoch trigger on clusterconfig_shared prevents a writer from committing a new shared version while that fence is held. This is not authorization.
func Fence ¶
Fence locks the epoch until commit. PostgreSQL policy triggers update this same row. SQLite explicitly obtains the write lock even on connections that use deferred transactions; it must not rely on a particular DSN.
func PublishConfig ¶
PublishConfig records the inputs of a newly published configuration and advances the epoch in one transaction (the config store's policy bump).
func RebuildInputs ¶
RebuildInputs replaces each given source from durable state. Once every source has been rebuilt, the conservative seed rows the migration wrote go.
func RulesInputs ¶
func RulesInputs(in Inputs, specs []core.LibraryExclusion)
RulesInputs records what library rules (global or one viewer's) read. contentRating is always policy and needs no row.
Types ¶
type Inputs ¶
type Inputs map[[2]string]struct{}
Inputs is a set of (field, value) rows for one source.