Documentation
¶
Overview ¶
Package scope decides which brains a request may read.
The rules are deliberately small and fail closed:
- A token grants a fixed set of brains. Nothing outside that set is ever readable.
- The harness sends the brains a session wants (from projects.yaml). Asking for a brain the token does not grant is an error, not a silent drop, so a misconfigured session is visible immediately.
- With no requested brains, the session gets every granted brain except sensitive ones. Sensitive brains are only ever included by name.
- Cortex is always included when the token grants it.
- A grant may name a family, "client-*", which covers every brain named "client-<suffix>". Families are never expanded by default: their members are only read when named, so a new sub-project brain needs no new grant and never leaks into a default scope.
Index ¶
- Constants
- Variables
- func IsFamily(s string) bool
- func Matches(entry, name string) bool
- func MatchesAny(entries []string, name string) bool
- func ParseHeader(v string) ([]string, error)
- func Resolve(granted, requested []string, sensitive func(string) bool) ([]string, error)
- func ValidEntry(s string) bool
- func ValidFamily(s string) bool
- func ValidName(s string) bool
Constants ¶
const Cortex = "cortex"
Cortex is the shared brain every scope builds on.
const FamilySuffix = "-*"
FamilySuffix marks a family pattern: "client-*" covers "client-<suffix>".
Variables ¶
var ErrForbidden = errors.New("brain not permitted for this token")
ErrForbidden is returned when a request asks for a brain its token does not grant.
Functions ¶
func Matches ¶
Matches reports whether name is entry itself, or a member of the family entry. A family never matches its own base name: "client-*" does not match "client".
func MatchesAny ¶
MatchesAny reports whether name matches any of the entries.
func ParseHeader ¶
ParseHeader splits a comma-separated brain list (the X-Ki-Brains header).
func Resolve ¶
Resolve returns the sorted brains a request may read. sensitive reports whether a brain must only be included when explicitly requested.
func ValidEntry ¶
ValidEntry reports whether s is a valid brain name or family pattern.
func ValidFamily ¶
ValidFamily reports whether s is a well-formed family pattern: a valid name followed by "-*".
Types ¶
This section is empty.