Documentation
¶
Overview ¶
Package policy defines the durable tenant policy and the access decisions derived from it. Policies are JSON values validated at their boundary; access checks receive the caller's authenticated keys and membership facts.
Index ¶
- Constants
- func CanRead(p Policy, e event.Event, a Access) bool
- func CanWrite(p Policy, e event.Event, a Access) bool
- func IsPrivateRepository(e event.Event) bool
- func PrivatePeerBase(source string, peers []string) string
- func PrivateRepository(ctx context.Context, lookup PrivateRepositoryLookup, e event.Event) (bool, error)
- func Validate(p Policy) error
- type Access
- type CustomHost
- type Delivery
- type Features
- type FileLimits
- type Inbox
- type MemberInvites
- type Notify
- type Policy
- type PrivateRepositoryLookup
- type RetentionRule
- type Sites
- type Succession
Constants ¶
const DefaultCallbacks = 4
DefaultCallbacks is the callback allowance per key when a policy does not name one.
const DefaultRooms = 64
DefaultRooms is the room allowance applied when a policy does not name one.
Variables ¶
This section is empty.
Functions ¶
func CanRead ¶
CanRead applies the read rule, kind blocks, private repository rules and recipient addressing to one event.
func IsPrivateRepository ¶
IsPrivateRepository identifies a GRASP repository announcement carrying the private=true marker. State events are associated with their announcement by owner and identifier at the storage boundary.
func PrivatePeerBase ¶
PrivatePeerBase returns the configured HTTP base for a private peer URL.
func PrivateRepository ¶
func PrivateRepository(ctx context.Context, lookup PrivateRepositoryLookup, e event.Event) (bool, error)
PrivateRepository reports whether an event is a private repository event. Repository state inherits privacy from its corresponding announcement.
Types ¶
type CustomHost ¶
type CustomHost struct {
Host string `json:"host"`
ID string `json:"id"`
Site string `json:"site,omitempty"`
At int64 `json:"at"`
Status string `json:"status"`
SSLStatus string `json:"sslStatus"`
}
CustomHost records a tenant-managed host and its provisioning state.
type Delivery ¶
type Delivery struct {
Enabled bool `json:"enabled"`
}
Delivery controls event delivery services.
type Features ¶
type Features struct {
Search string `json:"search"`
Sync bool `json:"sync"`
Count bool `json:"count"`
Discovery bool `json:"discovery"`
Names bool `json:"names"`
Files bool `json:"files"`
Pages bool `json:"pages"`
Sites Sites `json:"sites"`
Signer bool `json:"signer"`
Marmot bool `json:"marmot"`
Grasp bool `json:"grasp"`
Grasp02 bool `json:"grasp02"`
Grasp03 bool `json:"grasp03"`
Grasp05 bool `json:"grasp05"`
Grasp06 bool `json:"grasp06"`
// Grasp08 enables the private-service profile. It is a tenant boundary,
// not a repository visibility hint: all reads require current membership.
Grasp08 bool `json:"grasp08"`
Push bool `json:"push"`
// Jobs admits long-task requests, answers and cancels (kinds 43001 to
// 43006) from members and agents. It is on unless the owner switches it
// off.
Jobs bool `json:"jobs"`
}
Features selects relay protocols and tenant capabilities.
type FileLimits ¶
type FileLimits struct {
MaxFileBytes int64 `json:"maxFileBytes"`
UserStorageBytes int64 `json:"userStorageBytes"`
}
FileLimits controls a tenant's file storage allowances. Zero is unlimited.
type Inbox ¶
type Inbox struct {
Targeted bool `json:"targeted"`
}
Inbox controls targeted inbox admission.
type MemberInvites ¶
MemberInvites controls invitation depth and quota.
type Notify ¶
type Notify struct {
Reports bool `json:"reports"`
Jobs bool `json:"jobs"`
Succession bool `json:"succession"`
Digest bool `json:"digest"`
}
Notify selects tenant notification categories.
type Policy ¶
type Policy struct {
Owner string `json:"owner"`
CustomHosts []CustomHost `json:"customHosts"`
Succession *Succession `json:"succession"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
Banner string `json:"banner"`
Contact string `json:"contact"`
PostingPolicy string `json:"postingPolicy"`
PrivacyPolicy string `json:"privacyPolicy"`
Tags []string `json:"tags"`
LanguageTags []string `json:"languageTags"`
RelayCountries []string `json:"relayCountries"`
Notify Notify `json:"notify"`
Writes string `json:"writes"`
OpenKinds []int `json:"openKinds"`
GuestReplies bool `json:"guestReplies"`
BlockedWords []string `json:"blockedWords"`
BlockedWordsInTags bool `json:"blockedWordsInTags"`
ReportThreshold int `json:"reportThreshold"`
Reads string `json:"reads"`
JoinTerms string `json:"joinTerms"`
DirectoryPublic bool `json:"directoryPublic"`
MinPow int `json:"minPow"`
MaxFuture int64 `json:"maxFuture"`
MemberInvites MemberInvites `json:"memberInvites"`
Views map[string]string `json:"views"`
Features Features `json:"features"`
PushCallbacks []string `json:"pushCallbacks"`
PrivatePeers []string `json:"privatePeers,omitempty"`
FileLimits FileLimits `json:"fileLimits"`
LetteredNips bool `json:"letteredNips"`
Delivery Delivery `json:"delivery"`
Inbox Inbox `json:"inbox"`
Dumps string `json:"dumps"`
DumpsKeep int `json:"dumpsKeep"`
// Rooms caps the chat rooms a tenant may create beside its main group.
// Zero switches room creation off.
Rooms int `json:"rooms"`
// Callbacks caps the event callbacks one key may register. The owner is
// not limited. Zero switches registration off for everyone else.
Callbacks int `json:"callbacks"`
BlockedKinds []int `json:"-"`
AllowedKinds []int `json:"-"`
Retention []RetentionRule `json:"-"`
}
Policy is the durable policy for one tenant. It combines identity and presentation settings, access rules, feature switches and storage limits.
func Patch ¶
Patch applies only recognized fields. A missing field is unchanged; an explicit null resets pointer fields and an explicit empty array clears it.
func (Policy) PrivateServiceEnabled ¶
PrivateServiceEnabled reports whether the tenant has the complete GRASP-08 private service contract enabled.
func (*Policy) UnmarshalJSON ¶
UnmarshalJSON applies the current defaults for room, callback and job settings before decoding a stored policy.
type PrivateRepositoryLookup ¶
type PrivateRepositoryLookup interface {
IsPrivateRepository(ctx context.Context, pubkey, identifier string) (bool, error)
}
PrivateRepositoryLookup supplies the stored repository privacy marker for replaceable repository state events. It keeps the policy package independent from the storage implementation.
type RetentionRule ¶
RetentionRule assigns a retention period to one kind; negative kinds are used as the wildcard rule by the gate.
type Succession ¶
Succession describes the account handoff after a period of inactivity.