Documentation
¶
Overview ¶
Package access holds the presentation side of authorization shared by the team, roles, API key and MCP screens: the permission catalogue as the API returns it, scope labels ("Beta Program list only"), sign-in method and two-factor labels, and the "who can help" helper names.
Index ¶
- func AndList(names []string) string
- func AudienceInScope(scope authz.Scope, lists []uuid.UUID, segments int) bool
- func AudienceScopeProblem(l i18n.Lang) string
- func CantGrant(l i18n.Lang, p authz.Permission, helpers []string) string
- func Groups(l i18n.Lang) []string
- func Helpers(ctx context.Context, q *store.Queries, wsID uuid.UUID, perm authz.Permission) []string
- func ImpliedBy(set authz.Set, p authz.Permission) authz.Permission
- func ListNames(ctx context.Context, q *store.Queries, wsID uuid.UUID) (map[uuid.UUID]string, error)
- func NotHoldable(l i18n.Lang, p authz.Permission, t authz.ActorType) string
- func OrList(names []string) string
- func ParseLists(ids []string) []uuid.UUID
- func ParseScope(raw json.RawMessage) authz.Scope
- func Plural(n int, one, many string) string
- func ScopeJSON(s authz.Scope) json.RawMessage
- func ScopeKind(s authz.Scope, names map[uuid.UUID]string) (kind, value string)
- func ScopeProblem(l i18n.Lang, err error) string
- func ScopeText(s authz.Scope, names map[uuid.UUID]string, listWord bool) i18n.Text
- func ScopeWhat(l i18n.Lang, s authz.Scope, names map[uuid.UUID]string) string
- func Verb(p authz.Permission) string
- type Identity
- type MemberSignInMethod
- type MemberTwoFA
- type PermissionInfo
- type ScopeError
- type ScopeRequest
- type ScopeSummary
- type ScopedList
- type TwoFAInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AudienceInScope ¶
AudienceInScope reports whether a list scope allows an audience: its lists only, no segment.
func AudienceScopeProblem ¶
AudienceScopeProblem says why AudienceInScope refused, in a language.
func CantGrant ¶
CantGrant explains an escalation in a language: "You can't grant segments:sql because you don't hold it. Ask Linh Nguyen."
func Groups ¶
Groups returns the permission groups in display order, named in a language as Catalog names them.
func Helpers ¶
Helpers names up to two active members who hold perm, Owners first ("Ask Linh Nguyen or Marcus Chen").
func ImpliedBy ¶
func ImpliedBy(set authz.Set, p authz.Permission) authz.Permission
ImpliedBy returns the permission in set that implies p ("campaigns:edit" implies "campaigns:view"), or "" when p stands on its own.
func NotHoldable ¶
NotHoldable explains in a language why a key or agent can't hold p (authz.HoldableBy).
func ParseLists ¶
ParseLists parses stored list ids, skipping invalid ones.
func ParseScope ¶
func ParseScope(raw json.RawMessage) authz.Scope
ParseScope reads a stored scope ({} = everything).
func ScopeJSON ¶
func ScopeJSON(s authz.Scope) json.RawMessage
ScopeJSON encodes a scope for storage.
func ScopeKind ¶
ScopeKind describes a scope for a kept message's select: "all", "list" (one list: value is its name), "only" (one sender domain: the domain) or "other" (value is the lists and domains written in English).
func ScopeProblem ¶
ScopeProblem is the field problem's sentence for a scope that doesn't resolve, in a language: "Unknown list "…"."
func ScopeText ¶
ScopeText keeps a scope's label for later readers (an audit entry's summary): "Beta Program list only", or "all lists" when it places no restriction.
func ScopeWhat ¶
ScopeWhat says what a scope covers, without "only", for a table's Scope column: "Beta Program", "2 lists · news.acme.io", or "all lists".
func Verb ¶
func Verb(p authz.Permission) string
Verb returns the action part of a permission key: "campaigns:edit" → "edit".
Types ¶
type MemberSignInMethod ¶
type MemberSignInMethod struct {
Kind string `json:"kind" enum:"password,passkey,sso,google,microsoft,github"`
// Label is "Password", "passkey" or "Google Workspace SSO".
Label string `json:"label"`
// Preset of the SSO provider (google, entra, okta…) for the icon.
Preset string `json:"preset,omitempty"`
}
MemberSignInMethod is one way a person signs in.
func PrimarySignIn ¶
func PrimarySignIn(all []MemberSignInMethod) []MemberSignInMethod
PrimarySignIn is the sign-in shown in the team list: the member's own credentials (password, passkey) when they have any, otherwise their SSO or social sign-ins. Linked identities next to a password are listed on the member page only.
func SignInMethods ¶
func SignInMethods(hasPassword bool, passkeys int64, ids []Identity) []MemberSignInMethod
SignInMethods lists how a person signs in, password first.
type MemberTwoFA ¶
type MemberTwoFA struct {
State string `json:"state" enum:"on,off,idp,required"`
// Method is "TOTP" or "passkey" when on.
Method string `json:"method,omitempty"`
GraceUntil *time.Time `json:"graceUntil,omitempty"`
// GraceDays is the whole days left in the grace period (0 = ends today).
GraceDays *int `json:"graceDays,omitempty"`
}
MemberTwoFA is a member's two-factor status (A5 §5.8): On, Off, Via IdP or "Required, grace ends in N days".
func TwoFAStatus ¶
func TwoFAStatus(in TwoFAInput) MemberTwoFA
TwoFAStatus computes the badge shown in the members list.
type PermissionInfo ¶
type PermissionInfo struct {
Key string `json:"key" example:"campaigns:send"`
Group string `json:"group" example:"Campaigns"`
Label string `json:"label" example:"Send or schedule campaigns"`
Description string `json:"description"`
Sensitive bool `json:"sensitive"`
Implies []string `json:"implies"`
OwnerOnly bool `json:"ownerOnly"`
// PeopleOnly: API keys and MCP agents can't hold it.
PeopleOnly bool `json:"peopleOnly"`
// NoAgents: MCP agents can't hold it.
NoAgents bool `json:"noAgents"`
}
PermissionInfo describes one permission key for the role editor, API key and agent pickers.
func Catalog ¶
func Catalog(l i18n.Lang) []PermissionInfo
Catalog returns every permission in display order, its group, label and description in a language.
type ScopeError ¶
type ScopeError struct {
// Domain is true for a sender domain, false for a list.
Domain bool
Value string
}
ScopeError is a requested list or sender domain the workspace doesn't have.
func (*ScopeError) Error ¶
func (e *ScopeError) Error() string
type ScopeRequest ¶
type ScopeRequest struct {
Lists []string `json:"lists,omitempty" maxItems:"100" doc:"List ids"`
SenderDomains []string `json:"senderDomains,omitempty" maxItems:"20"`
}
ScopeRequest is the request shape of a scope.
type ScopeSummary ¶
type ScopeSummary struct {
Lists []ScopedList `json:"lists"`
SenderDomains []string `json:"senderDomains"`
// Label is "" for no restriction, otherwise "Beta Program list only",
// "Weekly Digest only" or "2 lists · news.acme.io".
Label string `json:"label"`
// All is true when the scope places no restriction ("All lists").
All bool `json:"all"`
}
ScopeSummary is a scope as shown in the UI.
type ScopedList ¶
ScopedList is one list in a scope.
type TwoFAInput ¶
type TwoFAInput struct {
TOTP bool
Passkeys int64
SSOOnly bool // signs in only through an IdP that enforces its own second factor
GraceUntil *time.Time
Required bool // the policy requires two-factor for this member
Now time.Time
}
TwoFAInput is what the two-factor status is computed from.