Documentation
¶
Overview ¶
Package privctx propagates the visibility tier of the caller through a Go context. The ent privacy policy (see ent/schema/poc_policy.go) reads the tier via TierFrom and admits the visibility values that Tier.AdmittedVisibilities returns for it.
Tier is set by the HTTP middleware (internal/middleware.PrivacyTier) at the edge of every HTTP request, and — starting v1.15 — by the OAuth callback. The sync worker does NOT use this package; it bypasses the policy via privacy.DecisionContext at worker entry.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tier ¶
type Tier int
Tier identifies the visibility scope of the caller. TierPublic is the zero value so any un-stamped context defaults to the most restrictive (safest) tier — fail-safe-closed.
const ( // TierPublic is the zero-value tier. Anonymous callers see rows whose // upstream visibility is "Public" only. TierPublic Tier = iota // TierUsers is the signed-in / env-elevated tier. It sees rows whose // upstream visibility is "Public" or "Users", the same rows that an // authenticated PeeringDB user who is not a member of the owning // organization sees. It never sees "Private" rows: upstream shows // them only to members of the owning organization, and the mirror // has no organization membership. TierUsers )
func TierFrom ¶
TierFrom returns the tier stored in ctx, or TierPublic if none was set or the value under the key is not a Tier. Never panics; the fallback is the most restrictive tier, so mis-wired callers default to locked-down behaviour rather than leaking Users-visibility rows.
func (Tier) AdmittedVisibilities ¶ added in v1.28.0
AdmittedVisibilities returns the upstream visibility values ("Public", "Users", "Private") that tier t may read. It is the single mapping from tier to visibility. The row gates (the poc privacy policy and the pdbcompat traversal gate) and the field gate (privfield.Redact) all use it, so they cannot disagree.
- TierPublic: Public.
- TierUsers: Public and Users.
No tier admits "Private" (upstream 2.83.0 permissions.py:336-339 and signals.py:343-347 grant it only to the owning organization's groups). Each call returns a new slice, so the caller can change it.