Documentation
¶
Overview ¶
Package personacfg holds the YAML shape of a persona definition and the one conversion from it to the runtime persona the authorizer evaluates.
It is a package of its own because pkg/platform is at its size budget and because the conversion had been written twice: once at startup and once in the admin API's revert-to-file path. The second copy is what dropped a persona's API route rules when its database override was deleted (#1479). The types are aliased back into pkg/platform, so a config file and every caller naming platform.PersonaDef are unchanged.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIRouteDef ¶
type APIRouteDef struct {
// Connection is a glob matched against the connection name.
Connection string `yaml:"connection"`
// Methods are HTTP method globs. Empty matches any method.
Methods []string `yaml:"methods,omitempty"`
// Paths are path globs, matched against both the path a call reaches and
// the catalog template it resolved from. Empty matches any path.
Paths []string `yaml:"paths,omitempty"`
// Action is "allow" (the default) or "deny". Deny wins.
Action string `yaml:"action,omitempty"`
}
APIRouteDef defines one per-(connection, method, path) rule for the HTTP API gateway in config. Mirrors persona.APIRouteRule.
type ConnectionRulesDef ¶
type ConnectionRulesDef struct {
Allow []string `yaml:"allow,omitempty"`
Deny []string `yaml:"deny,omitempty"`
}
ConnectionRulesDef defines connection access rules in config.
type ContextDef ¶
type ContextDef struct {
DescriptionPrefix string `yaml:"description_prefix,omitempty"`
DescriptionOverride string `yaml:"description_override,omitempty"`
AgentInstructionsSuffix string `yaml:"agent_instructions_suffix,omitempty"`
AgentInstructionsOverride string `yaml:"agent_instructions_override,omitempty"`
}
ContextDef defines per-persona context overrides.
type LegacyUploads ¶ added in v1.166.3
LegacyUploads is the personas a configuration file still gives #2258's uploads recipient lists (share_personas, share_emails), each with the line its mapping starts on. #2290 made uploads a switch and migration 000219 read a stored list as on; a file naming one was read as off and logged as an unrecognized key, which left an external persona's people with no way to upload and nothing in the portal saying why (#2744). It is read as on, as the stored form is, and logged so the file is changed to uploads: true.
func ReadLegacyUploads ¶ added in v1.166.3
func ReadLegacyUploads(expanded []byte) LegacyUploads
ReadLegacyUploads finds every personas.<name>.portal.uploads that is a mapping.
func (LegacyUploads) Accepts ¶ added in v1.166.3
func (l LegacyUploads) Accepts(unknown string) bool
Accepts reports whether a strict decode's unknown-key error is a legacy uploads mapping this release reads.
func (LegacyUploads) Apply ¶ added in v1.166.3
func (l LegacyUploads) Apply(cfg *PersonasConfig)
Apply turns each legacy-uploads persona's uploads on and logs the personas.
type PersonaDef ¶
type PersonaDef struct {
DisplayName string `yaml:"display_name"`
Description string `yaml:"description,omitempty"`
Roles []string `yaml:"roles"`
Tools ToolRulesDef `yaml:"tools"`
Connections ConnectionRulesDef `yaml:"connections"`
// APIRoutes narrows which HTTP methods and paths this persona may
// invoke on api-kind connections it already reaches. Optional: a
// connection no rule names keeps the connection-level decision as its
// only gate.
APIRoutes []APIRouteDef `yaml:"api_routes,omitempty"`
Context ContextDef `yaml:"context"`
Priority int `yaml:"priority,omitempty"`
// ServiceAccount marks a persona an automated caller signs in under: its
// calls are audited but not cataloged (#1980). The same rule as naming
// the persona in calls.exclude_personas, stated on the persona itself.
ServiceAccount bool `yaml:"service_account,omitempty"`
// Portal is what the persona's people may do in the portal, one setting
// per area (#2225). Absent, and any field left unset, resolves to what the
// persona reached before the setting existed.
Portal *persona.PortalAccess `yaml:"portal,omitempty"`
// HideAutomations is the setting portal.automations replaced (#2109,
// #2225). It is still read, as portal.automations: false when the portal
// block does not set automations, so a file written for the release
// before keeps its meaning.
HideAutomations bool `yaml:"hide_automations,omitempty"`
// AllowSharing lets the persona's people share what they own (#2241).
// Absent allows it.
AllowSharing *bool `yaml:"allow_sharing,omitempty"`
// External marks the persona for people outside the organization, whose
// accounts the platform creates (#2092).
External bool `yaml:"external,omitempty"`
}
PersonaDef defines a persona.
func (PersonaDef) ToPersona ¶
func (d PersonaDef) ToPersona(name, source string) *persona.Persona
ToPersona builds the runtime persona this definition describes. source is the provenance label the caller stamps on it.
It is the single construction of a file persona: the platform's startup load and the admin API's revert-to-file path both go through it, so a field added to PersonaDef reaches both rather than only the one its author remembered.
type PersonasConfig ¶
type PersonasConfig struct {
Definitions map[string]PersonaDef `yaml:",inline"`
// DefaultPersona is no longer honored: a caller whose roles match no
// persona has no access. The field is still parsed so Validate can reject a
// config that sets it, and — because Definitions is an inline map — so that
// `default_persona: analyst` does not decode as a persona *named*
// "default_persona".
DefaultPersona string `yaml:"default_persona"`
RoleMapping RoleMappingConfig `yaml:"role_mapping"`
}
PersonasConfig holds persona definitions.
type RoleMappingConfig ¶
RoleMappingConfig configures role mapping.
type ToolRulesDef ¶
ToolRulesDef defines tool access rules.