policy

package
v0.0.0-...-9268282 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const DefaultCallbacks = 4

DefaultCallbacks is the callback allowance per key when a policy does not name one.

View Source
const DefaultRooms = 64

DefaultRooms is the room allowance applied when a policy does not name one.

Variables

This section is empty.

Functions

func CanRead

func CanRead(p Policy, e event.Event, a Access) bool

CanRead applies the read rule, kind blocks, private repository rules and recipient addressing to one event.

func CanWrite

func CanWrite(p Policy, e event.Event, a Access) bool

CanWrite applies kind blocks, allowlists and the tenant write rule to one event.

func IsPrivateRepository

func IsPrivateRepository(e event.Event) bool

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

func PrivatePeerBase(source string, peers []string) string

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.

func Validate

func Validate(p Policy) error

Validate checks policy enum values, URL fields, feature dependencies and numeric bounds.

Types

type Access

type Access struct {
	PubKeys []string
	Role    string
	Member  bool
	Owner   bool
}

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

type MemberInvites struct {
	Depth int `json:"depth"`
	Quota int `json:"quota"`
}

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 Defaults

func Defaults(owner string) Policy

func Patch

func Patch(cur Policy, raw map[string]json.RawMessage) (Policy, error)

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

func (p Policy) PrivateServiceEnabled() bool

PrivateServiceEnabled reports whether the tenant has the complete GRASP-08 private service contract enabled.

func (*Policy) UnmarshalJSON

func (p *Policy) UnmarshalJSON(data []byte) error

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

type RetentionRule struct {
	Kind int `json:"kind"`
	Days int `json:"days"`
}

RetentionRule assigns a retention period to one kind; negative kinds are used as the wildcard rule by the gate.

type Sites

type Sites struct {
	Enabled bool `json:"enabled"`
	Mirror  bool `json:"mirror"`
}

Sites controls hosted site publication and mirroring.

type Succession

type Succession struct {
	Heir      string `json:"heir"`
	AfterDays int    `json:"afterDays"`
}

Succession describes the account handoff after a period of inactivity.

Jump to

Keyboard shortcuts

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