Documentation
¶
Overview ¶
Package policy is the gate every operation passes through.
The policy file is written by the deployer and is read-only to the agent (in a Pod it is a ConfigMap mount). The effective mode for an operation is the lower of the policy mode and the mode the account logged in with, so a policy can never grant more than the token's scopes and a token can never be used beyond what the policy allows.
Index ¶
Constants ¶
const DefaultSignoff = "\n\n-- \nSent by an automated assistant"
DefaultSignoff is appended to agent-written bodies unless the policy sets `signoff` explicitly (an empty string disables it).
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath resolves the policy file: $EMAIL_POLICY_FILE, else <configDir>/policy.toml.
Types ¶
type DefaultSection ¶
type DeleteSection ¶
type DeleteSection struct {
Enabled bool `toml:"enabled" json:"enabled"`
}
type Op ¶
type Op string
Op is an operation the CLI can perform.
const ( OpList Op = "list" OpSearch Op = "search" OpGet Op = "get" OpThread Op = "thread" OpAttachmentList Op = "attachments.list" OpAttachmentGet Op = "attachments.download" OpSync Op = "sync" OpDraftList Op = "draft.list" OpDraftGet Op = "draft.get" OpDraftCreate Op = "draft.create" OpDraftReply Op = "draft.reply" OpDraftForward Op = "draft.forward" OpDraftUpdate Op = "draft.update" OpDraftDelete Op = "draft.delete" OpMove Op = "move" OpLabel Op = "label" OpMark Op = "mark" OpSend Op = "send" OpAPI Op = "api" )
type Policy ¶
type Policy struct {
Default DefaultSection `toml:"default" json:"default"`
Send SendSection `toml:"send" json:"send"`
Delete DeleteSection `toml:"delete" json:"delete"`
Watch WatchSection `toml:"watch" json:"watch"`
Source string `toml:"-" json:"source"` // file path, or "builtin"
}
func Builtin ¶
func Builtin() *Policy
Builtin is used when no policy file exists: read-only, which is the safe failure mode for a missing or mis-mounted ConfigMap.
func Load ¶
Load reads the policy at path. A missing file yields Builtin(); a file that exists but fails to parse, or has unknown keys, is an error — a typo in a security config must not silently fall back to defaults.
func (*Policy) EffectiveMode ¶
type Request ¶
type Request struct {
Op Op
AccountMode Mode // mode the account logged in with (bounds the token's scopes)
AccountDomain string // domain of the logged-in mailbox, used as "internal" when no allowlist is set
Recipients []string // email addresses the operation would address
Dest string // move destination
AddLabels []string // label additions
HasReplyCtx bool // send: the draft is a reply/forward of an existing message
APIMethod string
APIPath string
}
Request describes one operation to be checked.
type SendSection ¶
type SendSection struct {
AllowedRecipientDomains []string `toml:"allowed_recipient_domains" json:"allowed_recipient_domains"`
MaxRecipients int `toml:"max_recipients" json:"max_recipients"` // 0 = unlimited
BlockExternalForward bool `toml:"block_external_forward" json:"block_external_forward"`
RequireReplyContext bool `toml:"require_reply_context" json:"require_reply_context"`
}
type WatchSection ¶
type WatchSection struct {
IgnoreSenders []string `toml:"ignore_senders" json:"ignore_senders"`
IgnoreSubjects []string `toml:"ignore_subjects" json:"ignore_subjects"`
// OnlyUnread skips mail already read (on the phone, say) by the time
// watch sees it.
OnlyUnread bool `toml:"only_unread" json:"only_unread"`
}
WatchSection filters what `email watch` notifies about. Entries match as case-insensitive substrings: "noreply@" or a "@domain" suffix.