Documentation
¶
Index ¶
- Constants
- func CapabilityGateErr(object, verb string) error
- func DefinersSQL(defs []GenFn) string
- func MintClaimsValues(contract []string, values map[string]string) (string, error)
- func MintClaimsValuesWithExtra(contract []string, values, extra map[string]string) (string, error)
- func Validate(s *Spec) error
- func ZookieNowSQL() string
- type Admit
- type Affordance
- type AffordanceHint
- type AffordanceSource
- type AppCheck
- type AppCheckSurface
- type AppObjectSurface
- func (o AppObjectSurface) CheckEditSQL() string
- func (o AppObjectSurface) CheckManySQL() string
- func (o AppObjectSurface) CheckSQL() string
- func (o AppObjectSurface) CheckVerbSQL(verb string) string
- func (o AppObjectSurface) ListResourcesFastSQL() string
- func (o AppObjectSurface) ListResourcesSQL() string
- type ArgSrc
- type AsyncIndex
- type ChangelogTrigger
- type ClaimEntry
- type ClaimsAccessor
- type ClosureTrigger
- type Column
- type Consistency
- type ConsistencyLevel
- type CostClass
- type Decision
- type DelegationCap
- type EffectivePerms
- type EffectiveRoles
- type ExportParameter
- type External
- type ExternalArg
- type FieldAccess
- type FieldAccessRule
- type FieldRule
- type FieldScopeEntry
- type FieldScopes
- type ForeignKey
- type Freshness
- type Gate
- type GenFn
- type Grant
- type GrantGranularity
- type GrantScope
- type GrantSurface
- type GrantUse
- type GroupTrigger
- type Guard
- type HoldsResolver
- func (r *HoldsResolver) AssignmentsSQL() string
- func (r *HoldsResolver) GlobalAssignmentsSQL() string
- func (r *HoldsResolver) Resolve(assignments []RoleAssignment, scope []string) (EffectivePerms, error)
- func (r *HoldsResolver) SelectedScopeCols() []string
- func (r *HoldsResolver) Vocabulary() *Vocabulary
- type Implication
- type Level
- type MaterializedFlat
- func (m MaterializedFlat) FunctionSQL() string
- func (m MaterializedFlat) HasReverse() bool
- func (m MaterializedFlat) IndexesSQL() string
- func (m MaterializedFlat) MemberDefiner() GenFn
- func (m MaterializedFlat) ReconcileSQL() string
- func (m MaterializedFlat) ResourcesDefiner() GenFn
- func (m MaterializedFlat) TableSQL() string
- func (m MaterializedFlat) TriggerSQL() string
- type Membership
- type Object
- type ObjectChangelogTrigger
- type PDP
- type Perm
- type PermNode
- type PermissionExport
- type PermissionInfo
- type Policy
- type Pos
- type Preset
- type Principal
- type ProcEntry
- type Procedures
- type Querier
- type RLSResult
- type ReachGrant
- type Relation
- type RenderHint
- type Repr
- type Require
- type ResourceAccessSurface
- func (r *ResourceAccessSurface) AccessorsSQL() string
- func (r *ResourceAccessSurface) ConditionalBy() string
- func (r *ResourceAccessSurface) GrantInsert(scope []string, resourceID, kind, principalID, access string) (string, []any)
- func (r *ResourceAccessSurface) GrantKindAllowed(kind string) bool
- func (r *ResourceAccessSurface) IsConditional() bool
- func (r *ResourceAccessSurface) IsReadMode(mode string) bool
- func (r *ResourceAccessSurface) ListGrantsArgs(resourceID string) []any
- func (r *ResourceAccessSurface) ListGrantsSQL() string
- func (r *ResourceAccessSurface) ModeSQL() string
- func (r *ResourceAccessSurface) RevokeDelete(resourceID, kind, principalID, access string) (string, []any)
- func (r *ResourceAccessSurface) SetVisibilitySQL() string
- type RoleAssignment
- type RoleAssignmentSurface
- func (r *RoleAssignmentSurface) AssignInsert(assignmentID, subjectID, roleID string, scope []string, grantedBy string, ...) (string, []any)
- func (r *RoleAssignmentSurface) AssignTouchInsert(assignmentID, subjectID, roleID string, scope []string, grantedBy string, ...) (string, []any)
- func (r *RoleAssignmentSurface) ListForPrincipalSQL() string
- func (r *RoleAssignmentSurface) ListForRoleSQL() string
- func (r *RoleAssignmentSurface) RevokeSQL() string
- type RoleStore
- type Row
- type Rows
- type SQLDB
- type ScaffoldOptions
- type Schema
- type Spec
- func (s *Spec) AsyncCursorSQL() string
- func (s *Spec) AsyncSQL() string
- func (s *Spec) BuildClaims(p Principal) (map[string]string, error)
- func (s *Spec) ChangelogSQL() string
- func (s *Spec) ChangelogTableSQL() string
- func (s *Spec) ClaimsContract() ([]string, error)
- func (s *Spec) ClaimsContractEntries() ([]ClaimEntry, error)
- func (s *Spec) ClaimsSetSQL(local bool) string
- func (s *Spec) ConditionalResourceAccessSurface(object string) (*ResourceAccessSurface, error)
- func (s *Spec) ConnectionRole() string
- func (s *Spec) DefinerNames() ([]string, error)
- func (s *Spec) EmitAppSurface() (*AppCheckSurface, error)
- func (s *Spec) EmitAsyncIndexes() []AsyncIndex
- func (s *Spec) EmitChangelogTriggers() []ChangelogTrigger
- func (s *Spec) EmitDefiners() ([]GenFn, error)
- func (s *Spec) EmitFieldAccess() (map[string]*FieldAccess, error)
- func (s *Spec) EmitFieldScopes() (map[string]map[string]string, error)
- func (s *Spec) EmitFramework(pkg string) (string, error)
- func (s *Spec) EmitFrameworkTS() (string, error)
- func (s *Spec) EmitGroupTriggers() []GroupTrigger
- func (s *Spec) EmitMaterializedFlats() []MaterializedFlat
- func (s *Spec) EmitObjectChangelogTriggers() []ObjectChangelogTrigger
- func (s *Spec) EmitPDP() (map[string]*PDP, error)
- func (s *Spec) EmitRLS() (*RLSResult, error)
- func (s *Spec) EmitSupabaseProfile() (string, error)
- func (s *Spec) EmitTS() (string, error)
- func (s *Spec) EmitTriggers() []ClosureTrigger
- func (s *Spec) ExpandedPresets(rolestore string) (map[string][]string, error)
- func (s *Spec) FlatsSQL() string
- func (s *Spec) FreeColumns(sub *Subject) ([]string, error)
- func (s *Spec) GrantSurface(name string) (*GrantSurface, error)
- func (s *Spec) HoldsResolver(rolestore string) (*HoldsResolver, error)
- func (s *Spec) MintClaims(values map[string]string) (string, error)
- func (s *Spec) MintClaimsFor(p Principal) (string, error)
- func (s *Spec) PinnedColumns(sub *Subject) (cols []string, virtualAnchor bool, err error)
- func (s *Spec) PointCheckSQL(object string) (string, error)
- func (s *Spec) ReachGrants() []ReachGrant
- func (s *Spec) RenderClaimsContractEntriesGo(varName string) (string, error)
- func (s *Spec) RenderClaimsContractGo(varName string) (string, error)
- func (s *Spec) RenderClaimsContractTS(varName string) (string, error)
- func (s *Spec) ResourceAccessSurface(object string) (*ResourceAccessSurface, error)
- func (s *Spec) RoleAssignmentSurface(rolestore string) (*RoleAssignmentSurface, error)
- func (s *Spec) SessionSetupSQL(local bool) []string
- func (s *Spec) SetRoleSQL(local bool) string
- func (s *Spec) TableCoverage(dbTables []string) TableCoverage
- func (s *Spec) TriggersSQL() string
- func (s *Spec) ValidateAgainst(sc *Schema) error
- func (s *Spec) Vocabularies() []VocabularyInfo
- type Subject
- type TableCoverage
- type Template
- type Term
- type Topology
- type UngovEntry
- type Ungoverned
- type ViaClosure
- type ViaColumn
- type ViaComposition
- type ViaEdge
- type ViaGrant
- type ViaGroup
- type ViaMemberIn
- type ViaObject
- type ViaRole
- type Vocabulary
- func (v *Vocabulary) CapGrant(held, requested []string) DelegationCap
- func (v *Vocabulary) ExpandImplications(perms []string) ([]string, error)
- func (v *Vocabulary) HasPermission(perm string) bool
- func (v *Vocabulary) ImpliedPermissions(perm string) ([]string, error)
- func (v *Vocabulary) PresetPermissions(name string) ([]string, error)
- func (v *Vocabulary) PresetsAtOrAbove(threshold string) []string
- func (v *Vocabulary) RankOf(preset string) (int, bool)
- type VocabularyInfo
- type Zookie
Examples ¶
Constants ¶
const ChangelogChannel = "demesne_authz_changelog"
Variables ¶
This section is empty.
Functions ¶
func CapabilityGateErr ¶
func DefinersSQL ¶
func MintClaimsValues ¶
func ZookieNowSQL ¶
func ZookieNowSQL() string
Types ¶
type Affordance ¶
type Affordance struct {
Hint AffordanceHint
AsOf Zookie
Freshness Freshness
Source AffordanceSource
}
func ComposeAffordance ¶
func ComposeAffordance(allowed bool, asOf Zookie, c Consistency) Affordance
func (Affordance) Render ¶
func (a Affordance) Render() RenderHint
type AffordanceHint ¶
type AffordanceHint int
const ( HintUnknown AffordanceHint = iota HintLikely HintUnlikely )
type AffordanceSource ¶
type AffordanceSource int
const ( SourceAsyncIndex AffordanceSource = iota SourceFloor )
type AppCheck ¶ added in v0.71.0
AppCheck is one @check permission's point-check: its verb and the boolean SELECT.
type AppCheckSurface ¶
type AppCheckSurface struct {
Objects []AppObjectSurface
}
func (*AppCheckSurface) Object ¶
func (a *AppCheckSurface) Object(name string) (AppObjectSurface, bool)
type AppObjectSurface ¶
type AppObjectSurface struct {
Object string
Table string
PK string
FlatListFn string
AsyncCheckSQL string
EditCheckSQL string
// Checks holds one point-check per @check permission (verb + SQL): compiled
// predicates exposed as Can<Verb>, with no RLS policy.
Checks []AppCheck
}
func (AppObjectSurface) CheckEditSQL ¶
func (o AppObjectSurface) CheckEditSQL() string
func (AppObjectSurface) CheckManySQL ¶
func (o AppObjectSurface) CheckManySQL() string
func (AppObjectSurface) CheckSQL ¶
func (o AppObjectSurface) CheckSQL() string
func (AppObjectSurface) CheckVerbSQL ¶ added in v0.71.0
func (o AppObjectSurface) CheckVerbSQL(verb string) string
CheckVerbSQL returns the point-check SQL for a @check verb, or "" if the object has no @check permission of that name.
func (AppObjectSurface) ListResourcesFastSQL ¶
func (o AppObjectSurface) ListResourcesFastSQL() string
func (AppObjectSurface) ListResourcesSQL ¶
func (o AppObjectSurface) ListResourcesSQL() string
type AsyncIndex ¶
type AsyncIndex struct {
Schema string
TableSchema string
Changelog string
Cursor string
Base string
GrantTable string
RecordCol string
KindCol string
PrincipalCol string
DiscrimCol string
DiscrimVal string
IDType string
}
func (AsyncIndex) AffordanceFnSQL ¶
func (a AsyncIndex) AffordanceFnSQL() string
func (AsyncIndex) ApplyFnSQL ¶
func (a AsyncIndex) ApplyFnSQL() string
func (AsyncIndex) RebuildFnSQL ¶
func (a AsyncIndex) RebuildFnSQL() string
func (AsyncIndex) TableSQL ¶
func (a AsyncIndex) TableSQL() string
func (AsyncIndex) WatermarkFnSQL ¶
func (a AsyncIndex) WatermarkFnSQL() string
type ChangelogTrigger ¶
type ChangelogTrigger struct {
Schema string
TableSchema string
Changelog string
Table string
RecordCol string
KindCol string
PrincipalCol string
DiscrimCol string
}
func (ChangelogTrigger) FunctionSQL ¶
func (c ChangelogTrigger) FunctionSQL() string
func (ChangelogTrigger) TriggerSQL ¶
func (c ChangelogTrigger) TriggerSQL() string
type ClaimEntry ¶
type ClosureTrigger ¶
type ClosureTrigger struct {
Schema string
TableSchema string
Closure string
Ancestor string
Descendant string
Base string
BaseID string
BaseParent string
}
func (ClosureTrigger) FunctionSQL ¶
func (c ClosureTrigger) FunctionSQL() string
func (ClosureTrigger) TriggerSQL ¶
func (c ClosureTrigger) TriggerSQL() string
type Consistency ¶
type Consistency interface {
Level() ConsistencyLevel
// contains filtered or unexported methods
}
func AtLeastAsFresh ¶
func AtLeastAsFresh(z Zookie) Consistency
func FullyConsistent ¶
func FullyConsistent() Consistency
func MinimizeLatency ¶
func MinimizeLatency() Consistency
type ConsistencyLevel ¶
type ConsistencyLevel int
const ( LevelMinimizeLatency ConsistencyLevel = iota LevelAtLeastAsFresh LevelFullyConsistent )
type DelegationCap ¶
type EffectivePerms ¶
type EffectivePerms struct {
// contains filtered or unexported fields
}
func (EffectivePerms) Holds ¶
func (e EffectivePerms) Holds(perm string) bool
func (EffectivePerms) Permissions ¶
func (e EffectivePerms) Permissions() []string
type EffectiveRoles ¶ added in v0.63.0
type EffectiveRoles struct {
// contains filtered or unexported fields
}
func NewEffectiveRoles ¶ added in v0.63.0
func NewEffectiveRoles(keys ...string) EffectiveRoles
func ResolveRoles ¶ added in v0.63.0
func ResolveRoles(assignments []RoleAssignment, scope []string) EffectiveRoles
func (EffectiveRoles) Holds ¶ added in v0.63.0
func (e EffectiveRoles) Holds(roleKey string) bool
func (EffectiveRoles) Roles ¶ added in v0.63.0
func (e EffectiveRoles) Roles() []string
type ExportParameter ¶ added in v0.83.0
type ExternalArg ¶ added in v0.78.0
type FieldAccess ¶ added in v0.68.0
type FieldAccess struct {
Object string
Principals []string
Rules []FieldAccessRule
}
func (*FieldAccess) RenderGo ¶ added in v0.68.0
func (fa *FieldAccess) RenderGo() string
func (*FieldAccess) RenderGrants ¶ added in v0.68.0
func (fa *FieldAccess) RenderGrants(table string) string
func (*FieldAccess) RenderTS ¶ added in v0.68.0
func (fa *FieldAccess) RenderTS() string
type FieldAccessRule ¶ added in v0.68.0
type FieldScopeEntry ¶
type FieldScopes ¶
type FieldScopes struct {
Site string
Entries []FieldScopeEntry
Pos Pos
}
type ForeignKey ¶
type ForeignKey struct {
Table, Column, RefTable, RefColumn string
}
type GenFn ¶
type Grant ¶
type Grant struct {
Name string
Level string
Table string
GranteeCol string
LevelCol string
ActiveCol string
ExpiresCol string
IDCol string
GrantedByCol string
RevokedByCol string
CreatedAtCol string
// Verbs bounds which table ops the grant's reach is spliced into. Empty
// means every op, which is what a grant carrying no `confers` clause gets,
// so a spec written before the clause existed keeps its behaviour exactly.
//
// Without a bound the same reach predicate lands on select, insert, update
// and delete alike, so a grant meant to let a holder READ what it reaches
// also lets it rewrite and destroy it. That is rarely what a reach is for,
// and it cannot be narrowed after the fact by the permission expression,
// which never sees the reach.
Verbs []string
ExtraCols []string
Named string
Scopes []GrantScope
ClaimKey string
ClaimValue string
Pos Pos
}
func (*Grant) Confers ¶ added in v0.81.0
Confers reports whether the grant's reach applies to a table op. A grant that names no verbs confers all of them.
func (*Grant) GranteeColumn ¶
func (*Grant) Granularity ¶
func (g *Grant) Granularity() GrantGranularity
type GrantGranularity ¶
type GrantGranularity int
const ( LevelReach GrantGranularity = iota RowReach )
func (GrantGranularity) String ¶
func (g GrantGranularity) String() string
type GrantScope ¶ added in v0.83.0
type GrantSurface ¶
type GrantSurface struct {
Name string
Level string
Table string
GranteeCol string
LevelCol string
ActiveCol string
ExpiresCol string
PK string
GrantedByCol string
RevokedByCol string
CreatedAtCol string
ExtraCols []string
}
func (*GrantSurface) GrantInsert ¶
func (*GrantSurface) ListSQL ¶
func (g *GrantSurface) ListSQL() string
func (*GrantSurface) RevokeSQL ¶
func (g *GrantSurface) RevokeSQL() string
type GroupTrigger ¶
type GroupTrigger struct {
Schema string
TableSchema string
Closure string
GroupCol string
MemberCol string
Edge string
EdgeMember string
EdgeGroup string
}
func (GroupTrigger) FunctionSQL ¶
func (g GroupTrigger) FunctionSQL() string
func (GroupTrigger) TriggerSQL ¶
func (g GroupTrigger) TriggerSQL() string
type HoldsResolver ¶
type HoldsResolver struct {
Assignments string
KindCol string
KindVal string
SubjectCol string
ScopeCols []string
RevokedCol string
Plane string
PlaneDepth int
RoleCol string
RolesTable string
RolesID string
KeyCol string
PermsCol string
Vocab *Vocabulary
}
func (*HoldsResolver) AssignmentsSQL ¶
func (r *HoldsResolver) AssignmentsSQL() string
func (*HoldsResolver) GlobalAssignmentsSQL ¶ added in v0.76.0
func (r *HoldsResolver) GlobalAssignmentsSQL() string
func (*HoldsResolver) Resolve ¶
func (r *HoldsResolver) Resolve(assignments []RoleAssignment, scope []string) (EffectivePerms, error)
func (*HoldsResolver) SelectedScopeCols ¶ added in v0.77.0
func (r *HoldsResolver) SelectedScopeCols() []string
func (*HoldsResolver) Vocabulary ¶
func (r *HoldsResolver) Vocabulary() *Vocabulary
type Implication ¶ added in v0.76.0
type MaterializedFlat ¶
type MaterializedFlat struct {
Schema string
TableSchema string
Flat string
ObjTable string
ObjPK string
Col string
Closure string
GroupCol string
MemberCol string
Kind string
ClaimExpr string
IDType string
}
func (MaterializedFlat) FunctionSQL ¶
func (m MaterializedFlat) FunctionSQL() string
func (MaterializedFlat) HasReverse ¶
func (m MaterializedFlat) HasReverse() bool
func (MaterializedFlat) IndexesSQL ¶
func (m MaterializedFlat) IndexesSQL() string
func (MaterializedFlat) MemberDefiner ¶
func (m MaterializedFlat) MemberDefiner() GenFn
func (MaterializedFlat) ReconcileSQL ¶
func (m MaterializedFlat) ReconcileSQL() string
func (MaterializedFlat) ResourcesDefiner ¶
func (m MaterializedFlat) ResourcesDefiner() GenFn
func (MaterializedFlat) TableSQL ¶
func (m MaterializedFlat) TableSQL() string
func (MaterializedFlat) TriggerSQL ¶
func (m MaterializedFlat) TriggerSQL() string
type Membership ¶
type Object ¶
type Object struct {
Name string
Table string
PK string
PKCols []string
Level string
Scoped []string
ScopeWildcards []string
// ScopeWildcardVerbs bounds a wildcard to named table ops, keyed by level.
// An absent or empty entry means every op, which is what a bare `wildcard`
// gets, so a spec written before the clause existed keeps its behaviour.
//
// The distinction matters because a wildcard says two things at once that
// are not equally safe. It says a row carrying NULL at this level belongs to
// no instance of it, and it says such a row is in scope for a caller who
// stands in one instance. Reading a row that belongs to everyone is the
// point of a shared tier; WRITING one from inside a single instance is a
// caller reaching outside the instance that confines it.
ScopeWildcardVerbs map[string][]string
ReachUses []GrantUse
Admits []*Admit
Exports []PermissionExport
Relations []*Relation
Perms []*Perm
Requires []*Require
Gates []*Gate
FieldPrincipals []string
Fields []*FieldRule
Use string
Omit []string
TrackOwner bool
TrackVisibility bool
Pos Pos
}
func (*Object) HasGrantStore ¶
func (*Object) IsLevelEntity ¶
type ObjectChangelogTrigger ¶
type ObjectChangelogTrigger struct {
Schema string
TableSchema string
Changelog string
Table string
Rel string
PK string
OwnerIDCol string
OwnerKindCol string
ModeCol string
}
func (ObjectChangelogTrigger) FunctionSQL ¶
func (c ObjectChangelogTrigger) FunctionSQL() string
func (ObjectChangelogTrigger) TriggerSQL ¶
func (c ObjectChangelogTrigger) TriggerSQL() string
type Perm ¶
type PermissionExport ¶ added in v0.83.0
type PermissionExport struct {
Verb string
Name string
Params []ExportParameter
Pos Pos
}
type PermissionInfo ¶ added in v0.64.0
type Procedures ¶
type Querier ¶
type ReachGrant ¶
type ReachGrant interface {
EdgeTable() string
GranteeColumn() string
Granularity() GrantGranularity
}
type RenderHint ¶
type RenderHint bool
type ResourceAccessSurface ¶
type ResourceAccessSurface struct {
Table string
ScopeCols []string
ModeCol string
// contains filtered or unexported fields
}
func (*ResourceAccessSurface) AccessorsSQL ¶
func (r *ResourceAccessSurface) AccessorsSQL() string
AccessorsSQL selects the enumerator. On a conditional surface it selects the claim columns too: they are the part of the answer that names nobody, and a caller that has asked for this surface has said it will read them.
func (*ResourceAccessSurface) ConditionalBy ¶ added in v0.85.0
func (r *ResourceAccessSurface) ConditionalBy() string
func (*ResourceAccessSurface) GrantInsert ¶
func (r *ResourceAccessSurface) GrantInsert(scope []string, resourceID, kind, principalID, access string) (string, []any)
func (*ResourceAccessSurface) GrantKindAllowed ¶
func (r *ResourceAccessSurface) GrantKindAllowed(kind string) bool
func (*ResourceAccessSurface) IsConditional ¶ added in v0.84.0
func (r *ResourceAccessSurface) IsConditional() bool
IsConditional reports whether this object's read admits readers the enumeration cannot name, so that its listing carries rows naming no principal. ConditionalBy names which admissions those are — 'app_scope', 'mode', 'claim <key>'.
func (*ResourceAccessSurface) IsReadMode ¶
func (r *ResourceAccessSurface) IsReadMode(mode string) bool
func (*ResourceAccessSurface) ListGrantsArgs ¶
func (r *ResourceAccessSurface) ListGrantsArgs(resourceID string) []any
func (*ResourceAccessSurface) ListGrantsSQL ¶
func (r *ResourceAccessSurface) ListGrantsSQL() string
func (*ResourceAccessSurface) ModeSQL ¶
func (r *ResourceAccessSurface) ModeSQL() string
func (*ResourceAccessSurface) RevokeDelete ¶
func (r *ResourceAccessSurface) RevokeDelete(resourceID, kind, principalID, access string) (string, []any)
func (*ResourceAccessSurface) SetVisibilitySQL ¶
func (r *ResourceAccessSurface) SetVisibilitySQL() string
type RoleAssignment ¶
type RoleAssignmentSurface ¶
type RoleAssignmentSurface struct {
Assignments string
PK string
KindCol string
KindVal string
SubjectCol string
RoleCol string
ScopeCols []string
RevokedCol string
GrantedAtCol string
GrantedByCol string
RevokedByCol string
ExtraCols []string
RolesTable string
RolesID string
KeyCol string
PermsCol string
}
func (*RoleAssignmentSurface) AssignInsert ¶
func (*RoleAssignmentSurface) AssignTouchInsert ¶
func (*RoleAssignmentSurface) ListForPrincipalSQL ¶
func (r *RoleAssignmentSurface) ListForPrincipalSQL() string
func (*RoleAssignmentSurface) ListForRoleSQL ¶
func (r *RoleAssignmentSurface) ListForRoleSQL() string
func (*RoleAssignmentSurface) RevokeSQL ¶
func (r *RoleAssignmentSurface) RevokeSQL() string
type RoleStore ¶
type RoleStore struct {
Name string
Assignments string
KindCol string
KindVal string
SubjectCol string
ScopeCols []string
Plane string
RoleCol string
RolesTable string
RolesID string
KeyCol string
RevokedCol string
PermsCol string
IDCol string
GrantedAtCol string
GrantedByCol string
RevokedByCol string
ExtraCols []string
Pos Pos
}
type ScaffoldOptions ¶
type ScaffoldOptions struct {
MinContainerRefs int
}
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
func (*Schema) AddForeignKey ¶
type Spec ¶
type Spec struct {
Topology *Topology
Vocabs []*Vocabulary
Subjects []*Subject
Objects []*Object
Procedures []*Procedures
Ungoverned []*Ungoverned
FieldScopes []*FieldScopes
RoleStores []*RoleStore
Grants []*Grant
Templates []*Template
Externals []*External
Claims *ClaimsAccessor
DefinerSchema string
TableSchema string
Identifiers string
}
func (*Spec) AsyncCursorSQL ¶
func (*Spec) ChangelogSQL ¶
func (*Spec) ChangelogTableSQL ¶
func (*Spec) ClaimsContract ¶
func (*Spec) ClaimsContractEntries ¶
func (s *Spec) ClaimsContractEntries() ([]ClaimEntry, error)
func (*Spec) ClaimsSetSQL ¶
func (*Spec) ConditionalResourceAccessSurface ¶ added in v0.84.0
func (s *Spec) ConditionalResourceAccessSurface(object string) (*ResourceAccessSurface, error)
ConditionalResourceAccessSurface is ResourceAccessSurface for a caller that has accounted for claim-admitted readers. It accepts an object with or without a claim, so a caller written against it stays correct if a claim is added to the spec later.
func (*Spec) ConnectionRole ¶
func (*Spec) DefinerNames ¶
func (*Spec) EmitAppSurface ¶
func (s *Spec) EmitAppSurface() (*AppCheckSurface, error)
func (*Spec) EmitAsyncIndexes ¶
func (s *Spec) EmitAsyncIndexes() []AsyncIndex
func (*Spec) EmitChangelogTriggers ¶
func (s *Spec) EmitChangelogTriggers() []ChangelogTrigger
func (*Spec) EmitDefiners ¶
func (*Spec) EmitFieldAccess ¶ added in v0.68.0
func (s *Spec) EmitFieldAccess() (map[string]*FieldAccess, error)
func (*Spec) EmitFieldScopes ¶
func (*Spec) EmitFrameworkTS ¶
func (*Spec) EmitGroupTriggers ¶
func (s *Spec) EmitGroupTriggers() []GroupTrigger
func (*Spec) EmitMaterializedFlats ¶
func (s *Spec) EmitMaterializedFlats() []MaterializedFlat
func (*Spec) EmitObjectChangelogTriggers ¶
func (s *Spec) EmitObjectChangelogTriggers() []ObjectChangelogTrigger
func (*Spec) EmitSupabaseProfile ¶
func (*Spec) EmitTriggers ¶
func (s *Spec) EmitTriggers() []ClosureTrigger
func (*Spec) ExpandedPresets ¶ added in v0.64.0
Example ¶
s := exampleSpecForDoc()
presets, err := s.ExpandedPresets("staff")
if err != nil {
panic(err)
}
names := make([]string, 0, len(presets))
for name := range presets {
names = append(names, name)
}
sort.Strings(names)
for _, name := range names {
fmt.Printf("%s = %s\n", name, strings.Join(presets[name], " "))
}
Output: tenant_owner = docs:publish docs:read docs:read:* docs:write ws_editor = docs:publish docs:read docs:write ws_viewer = docs:read
func (*Spec) GrantSurface ¶
func (s *Spec) GrantSurface(name string) (*GrantSurface, error)
func (*Spec) HoldsResolver ¶
func (s *Spec) HoldsResolver(rolestore string) (*HoldsResolver, error)
func (*Spec) PinnedColumns ¶
func (*Spec) ReachGrants ¶
func (s *Spec) ReachGrants() []ReachGrant
func (*Spec) RenderClaimsContractEntriesGo ¶
func (*Spec) RenderClaimsContractGo ¶
func (*Spec) RenderClaimsContractTS ¶
func (*Spec) ResourceAccessSurface ¶
func (s *Spec) ResourceAccessSurface(object string) (*ResourceAccessSurface, error)
ResourceAccessSurface describes object's grant store and its accessor enumerator.
It refuses an object whose read admits readers the enumeration cannot name, because that object has no plain enumerator to describe — see conditionalAccessors. Use ConditionalResourceAccessSurface, which returns the same surface over the conditional function and a query shape that carries the extra columns.
func (*Spec) RoleAssignmentSurface ¶
func (s *Spec) RoleAssignmentSurface(rolestore string) (*RoleAssignmentSurface, error)
func (*Spec) SessionSetupSQL ¶
func (*Spec) SetRoleSQL ¶
func (*Spec) TableCoverage ¶
func (s *Spec) TableCoverage(dbTables []string) TableCoverage
func (*Spec) TriggersSQL ¶
func (*Spec) ValidateAgainst ¶
func (*Spec) Vocabularies ¶ added in v0.64.0
func (s *Spec) Vocabularies() []VocabularyInfo
Example ¶
s := exampleSpecForDoc()
for _, v := range s.Vocabularies() {
fmt.Println(v.Name)
for _, p := range v.Permissions {
fmt.Printf(" %s parameterized=%v\n", p.Name, p.Parameterized)
}
}
Output: staff docs:read parameterized=false docs:write parameterized=false docs:publish parameterized=false docs:read:* parameterized=true member self:read parameterized=false self:write parameterized=false platform platform:manage parameterized=false
type TableCoverage ¶
type Term ¶
type Term struct {
Ident string
WalkVerb string
Builtin string
SessionRel string
// ExcludeRels are the owner relations @app_scope(exclude a, b) subtracts:
// the app plane admits a caller presenting no subject claim, MINUS the rows
// those relations own. More than one because a table can be owned on more
// than one plane — an admin-owned row and a customer-owned row are both
// somebody's private data, and a trusted caller with no subject of its own
// has no business reading either.
ExcludeRels []string
ModeCol string
ModeVal string
ModeScope string
GrantRef string
KindVal string
SelfCol string
// ClaimKey and ClaimVal are @claim("key", "value"): the request carries this
// claim with this value.
//
// It differs from every other term in WHO it admits. The rest name a subject
// — an owner, a grantee, a member of a group — and a subject can be listed.
// This names a CONDITION, and the set of callers who satisfy it is not
// derivable from any row. That is the whole reason it is a separate kind of
// term rather than another relation, and it is what the accessor emitter has
// to account for; see conditionalAccessors.
ClaimKey string
ClaimVal string
WithinLevel string
WithinNullable bool
HoldsPerm string
ExternalFn string
ExternalArgs []ExternalArg
Pos Pos
}
type Topology ¶
func (*Topology) LevelByName ¶
type UngovEntry ¶
type Ungoverned ¶
type Ungoverned struct {
EmitSite string
Entries []UngovEntry
Pos Pos
}
type ViaClosure ¶
type ViaComposition ¶
type ViaGrant ¶
type ViaGrant struct {
Table string
RecordCol string
KindCol string
PrincipalCol string
AccessCol string
DiscrimCol string
DiscrimVal string
// The optional membership hop: a grant row whose KindCol equals
// GroupKindVal names a GROUP in PrincipalCol, and admits every principal
// the closure lists as that group's member. The closure/edge pair is the
// same machinery `via group` uses (transitive, trigger-maintained), so a
// spec may share one closure between an audience column and group grants.
GroupKindVal string
GroupClosure string
GroupGroupCol string
GroupMemberCol string
GroupEdge string
GroupEdgeMember string
GroupEdgeGroup string
Tracked bool
Async bool
}
func (*ViaGrant) GranteeColumn ¶
func (*ViaGrant) Granularity ¶
func (e *ViaGrant) Granularity() GrantGranularity
type ViaMemberIn ¶
type Vocabulary ¶
type Vocabulary struct {
Name string
Permissions []string
Implications []*Implication
Presets []*Preset
Rank []string
Pos Pos
}
func (*Vocabulary) CapGrant ¶
func (v *Vocabulary) CapGrant(held, requested []string) DelegationCap
func (*Vocabulary) ExpandImplications ¶ added in v0.76.0
func (v *Vocabulary) ExpandImplications(perms []string) ([]string, error)
func (*Vocabulary) HasPermission ¶ added in v0.72.0
func (v *Vocabulary) HasPermission(perm string) bool
func (*Vocabulary) ImpliedPermissions ¶ added in v0.76.0
func (v *Vocabulary) ImpliedPermissions(perm string) ([]string, error)
func (*Vocabulary) PresetPermissions ¶
func (v *Vocabulary) PresetPermissions(name string) ([]string, error)
func (*Vocabulary) PresetsAtOrAbove ¶
func (v *Vocabulary) PresetsAtOrAbove(threshold string) []string
type VocabularyInfo ¶ added in v0.64.0
type VocabularyInfo struct {
Name string
Permissions []PermissionInfo
}
type Zookie ¶
type Zookie struct {
// contains filtered or unexported fields
}
func ParseZookie ¶
func ZookieFromXid ¶
Source Files
¶
- access_runtime.go
- admit.go
- app_surface.go
- ast.go
- consistency.go
- delegation.go
- emit_async.go
- emit_changelog.go
- emit_claims.go
- emit_closure.go
- emit_definers.go
- emit_fieldaccess.go
- emit_framework.go
- emit_framework_ts.go
- emit_pdp.go
- emit_require.go
- emit_rls.go
- emit_supabase.go
- emit_ts.go
- grant_runtime.go
- grant_scope.go
- grants.go
- holds.go
- introspect.go
- lexer.go
- model.go
- parser.go
- permission_export.go
- querier.go
- role_assignment_runtime.go
- runtime.go
- scaffold.go
- schema.go
- session.go
- table_coverage.go
- validate.go