Documentation
¶
Overview ¶
Package personaaccess answers what a persona, saved or not, lets its people reach (#2257): the tools they can call and on which connections, the API operations, the scratch tables, the portal, sharing and the resource folders, the grants other objects hold that name the persona, and what no persona setting governs. The persona editor shows it beside every unsaved change, and the persona delete lists its references from it.
Every answer is the evaluation a request meets: persona.ToolFilter for tools, connections and API routes, the portal levels for the portal, and Registry.AdminRule for the administrator. Nothing here decides access; it reports what the deciders would decide.
Index ¶
- Constants
- func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, s *Service)
- func Registrations(ctx context.Context, db *sql.DB) map[string]int
- type Assignment
- type Config
- type ConnAccess
- type ConnItem
- type ConnSummary
- type Connection
- type Draft
- type Inventory
- type OpItem
- type OpSummary
- type Operation
- type PortalSummary
- type References
- type Report
- type RoleOverlap
- type Scratch
- type ScratchItem
- type SecretRefs
- type Service
- type Subject
- type Tool
- type ToolItem
- type ToolSummary
- type Unscoped
Constants ¶
const ( AccountInternal = "internal" AccountExternal = "external" AccountAutomated = "automated" )
Account types a persona can be (#2257): one of them, stored as the persona's external and service_account flags.
const ( DecisionAllow = "allow" DecisionDeny = "deny" DecisionNone = "none" DecisionExternal = "external" )
Tool decisions.
const ( OpOpen = "open" OpRuleAllow = "rule_allow" OpRuleDeny = "rule_deny" OpRuleNoMatch = "rule_nomatch" OpConnection = "connection" OpTool = "tool" OpExternal = "external" )
API operation decisions: what decided whether api_invoke_endpoint may call it. open is a connection no route rule touches.
const Path = "/api/v1/admin/personas/effective-access"
Path is the route the persona editor asks.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Assignment ¶
type Assignment struct {
Roles []string `json:"roles"`
// RoleMapping are the roles personas.role_mapping assigns to this
// persona outright, before roles and priority are compared.
RoleMapping []string `json:"role_mapping"`
// FolderReaderRoles make a person a member of the persona's folder and
// prompts: any of them, whatever persona the person resolves to.
FolderReaderRoles []string `json:"folder_reader_roles"`
// FolderWriterRole writes the persona's folder; administrators do too.
FolderWriterRole string `json:"folder_writer_role"`
RoleOverlaps []RoleOverlap `json:"role_overlaps"`
}
Assignment is who gets the persona and who reaches its folder.
type Config ¶
type Config struct {
// Personas is the live registry: the other personas and their roles.
Personas *persona.Registry
// AdminPersona is the configured administrator persona's name.
AdminPersona string
// RoleMapping is personas.role_mapping.oidc_to_persona.
RoleMapping map[string]string
// ExcludedFromCalls is calls.exclude_personas.
ExcludedFromCalls []string
// Inventory reads what the deployment serves now.
Inventory func(ctx context.Context) Inventory
// DB holds the references; nil reports none.
DB *sql.DB
// FileKeyRoles are the roles of the API keys the configuration declares.
FileKeyRoles [][]string
}
Config is what the evaluation reads.
type ConnAccess ¶
ConnAccess is one connection a tool reaches and whether the persona does.
type ConnItem ¶
type ConnItem struct {
Name string `json:"name"`
Kind string `json:"kind"`
Decision string `json:"decision"`
Matched string `json:"matched,omitempty"`
Exact bool `json:"exact"`
Scratch *Scratch `json:"scratch,omitempty"`
UsedByChannels []string `json:"used_by_channels"`
}
ConnItem is one connection's decision.
type ConnSummary ¶
type ConnSummary struct {
Total int `json:"total"`
Allowed int `json:"allowed"`
Items []ConnItem `json:"items"`
}
ConnSummary is the connections a persona's tool calls reach.
type Connection ¶
Connection is one connection the deployment serves.
type Draft ¶
type Draft struct {
Name string `json:"name" example:"analyst"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
Roles []string `json:"roles"`
AllowTools []string `json:"allow_tools"`
DenyTools []string `json:"deny_tools,omitempty"`
AllowConnections []string `json:"allow_connections,omitempty"`
DenyConnections []string `json:"deny_connections,omitempty"`
Priority int `json:"priority,omitempty"`
DescriptionPrefix string `json:"description_prefix,omitempty"`
DescriptionOverride string `json:"description_override,omitempty"`
AgentInstructionsSuffix string `json:"agent_instructions_suffix,omitempty"`
AgentInstructionsOverride string `json:"agent_instructions_override,omitempty"`
APIRoutes []persona.APIRouteRule `json:"api_routes,omitempty"`
ServiceAccount bool `json:"service_account,omitempty"`
Portal *persona.PortalAccess `json:"portal,omitempty"`
External bool `json:"external,omitempty"`
AllowSharing *bool `json:"allow_sharing,omitempty"`
}
Draft is a persona as the editor holds it, saved or not: the body the persona create and update routes take.
type Inventory ¶
type Inventory struct {
Tools []Tool
Connections []Connection
Operations []Operation
// Registrations counts the scratch tables registered on each connection.
Registrations map[string]int
}
Inventory is what the deployment serves, read per request so a connection added at run time is in the next answer.
type OpItem ¶
type OpItem struct {
Connection string `json:"connection"`
Method string `json:"method"`
Path string `json:"path"`
Decision string `json:"decision"`
RuleIndex int `json:"rule_index"`
Callable bool `json:"callable"`
}
OpItem is one operation's decision. RuleIndex is the persona's API route rule that decided it, -1 for none.
type OpSummary ¶
type OpSummary struct {
Total int `json:"total"`
Callable int `json:"callable"`
Items []OpItem `json:"items"`
}
OpSummary is the API operations api_invoke_endpoint may call.
type PortalSummary ¶
type PortalSummary struct {
Stored persona.PortalAccess `json:"stored"`
Effective persona.PortalAccess `json:"effective"`
CappedByExternal []string `json:"capped_by_external"`
}
PortalSummary is the portal block as stored, as its people get it, and what External lowered.
type References ¶
type References struct {
Secrets SecretRefs `json:"secrets"`
ScriptGrants int `json:"script_grants"`
ScriptVersions int `json:"script_versions"`
Prompts int `json:"prompts"`
WebhookSources []string `json:"webhook_sources"`
APIKeys int `json:"api_keys"`
// People are the addresses of the signed-in people whose recorded roles
// resolve to the persona (#2290).
People []string `json:"people"`
}
References are the grants other objects hold that name the persona. A persona deleted with them leaves them in place, and one created later under the same name inherits them.
func (References) Empty ¶
func (r References) Empty() bool
Empty reports whether nothing names the persona. Secrets that name no persona are not a reference to this one.
type Report ¶
type Report struct {
IsAdmin bool `json:"is_admin"`
// AdminPersona is the configured administrator persona's name, which is
// never external.
AdminPersona string `json:"admin_persona"`
AccountType string `json:"account_type"`
CallsExcludedByConfig bool `json:"calls_excluded_by_config"`
Assignment Assignment `json:"assignment"`
Tools ToolSummary `json:"tools"`
Connections ConnSummary `json:"connections"`
APIOperations OpSummary `json:"api_operations"`
Scratch []ScratchItem `json:"scratch"`
Portal PortalSummary `json:"portal"`
Sharing bool `json:"sharing"`
ResourceScopes []string `json:"resource_scopes"`
References References `json:"references"`
Unscoped Unscoped `json:"unscoped"`
}
Report is the answer.
type RoleOverlap ¶
type RoleOverlap struct {
Role string `json:"role"`
Persona string `json:"persona"`
Priority int `json:"priority"`
}
RoleOverlap is another persona listing one of this persona's roles.
type Scratch ¶
type Scratch struct {
Catalog string `json:"catalog"`
Schema string `json:"schema"`
// Writes reports whether the connection accepts writes, which registering
// a table and changing one through SQL both need.
Writes bool `json:"-"`
}
Scratch is a Trino connection's scratch catalog (docs/server/scratch-catalog.md).
type ScratchItem ¶
type ScratchItem struct {
Connection string `json:"connection"`
Catalog string `json:"catalog"`
Schema string `json:"schema"`
// List and Register are the portal's scratch-table routes.
List bool `json:"list"`
Register bool `json:"register"`
// DropViaSQL is trino_execute on the connection, whose Trino user holds
// every privilege on the scratch catalog: any registered table can be
// dropped or replaced, whoever registered it.
DropViaSQL bool `json:"drop_via_sql"`
Registrations int `json:"registrations"`
// QueryableFrom are the connections trino_query reaches that read every
// registered table when their Trino user reads the scratch catalog.
QueryableFrom []string `json:"queryable_from"`
}
ScratchItem is what the persona's people can do with the scratch tables on one connection they reach.
type SecretRefs ¶
SecretRefs are the stored secrets that name the persona, and how many name no persona, which every persona may use.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service answers for a persona.
func (*Service) References ¶
References are the grants other objects hold that name the stored persona.
type Subject ¶
type Subject struct {
Persona *persona.Persona
// Admin reports the persona is the administrator persona.
Admin bool
// Others are the other registered personas, for role overlaps.
Others []*persona.Persona
// RoleMapping is personas.role_mapping.oidc_to_persona.
RoleMapping map[string]string
// ExcludedFromCalls is calls.exclude_personas.
ExcludedFromCalls []string
}
Subject is the persona being evaluated with what decides it.
type Tool ¶
Tool is one tool the deployment registers. Kind is its toolkit's kind, empty for a platform tool that reaches no connection. Connection is set when the tool is bound to one connection rather than taking one per call.
type ToolItem ¶
type ToolItem struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Decision string `json:"decision"`
Matched string `json:"matched,omitempty"`
Exact bool `json:"exact"`
Connections []ConnAccess `json:"connections"`
Callable bool `json:"callable"`
}
ToolItem is one tool's decision.
type ToolSummary ¶
type ToolSummary struct {
Total int `json:"total"`
Callable int `json:"callable"`
Items []ToolItem `json:"items"`
}
ToolSummary is the tools a persona's people can call.