Documentation
¶
Overview ¶
Package dbauthz is the single place that decides whether a caller may use a database explorer route (ADR 082). Every explorer route goes through Resolve.
Index ¶
Constants ¶
const ( ReasonOK = "ok" ReasonBadInput = "invalid action or resource" ReasonNoEngine = "no policy engine" ReasonEngineError = "policy evaluation failed" ReasonExplicitDeny = "explicit policy deny" ReasonNoAbility = "missing ability" ReasonHidden = "resource not visible" ReasonStepUp = "step up required" PolicyNone = "none" PolicyDenied = "deny" PolicyAllowed = "allow" )
Reasons and policy decision values.
const ResourcePrefix = "database:"
ResourcePrefix is the policy resource namespace for databases.
Variables ¶
var Actions = []Action{ActionRead, ActionQuery, ActionWrite, ActionExport, ActionAdmin, ActionTunnel, ActionUserCreate}
Actions lists every known db action, for policy validation.
Functions ¶
func DenyNames ¶
DenyNames lists the action names whose explicit Deny also blocks action: a Deny on db:read blocks query and export, a Deny on db:query blocks export. Write and admin Denies stay their own.
func EffectiveAbility ¶
EffectiveAbility is the flat ability an action needs today; unknown actions map to root so a mistake fails closed.
Types ¶
type Action ¶
type Action string
Action is a database explorer action, also valid in IAM policy documents.
const ( ActionRead Action = "db:read" ActionQuery Action = "db:query" ActionWrite Action = "db:write" ActionExport Action = "db:export" ActionAdmin Action = "db:admin" // ActionTunnel and ActionUserCreate let a policy grant just those, without root on the database. ActionTunnel Action = "db:tunnel" ActionUserCreate Action = "db:user-create" )
The db actions, named as in IAM policy documents.
type Decision ¶
type Decision struct {
Allowed bool
Hidden bool
Reason string
Abilities []string
PolicyDecision string
Limits Limits
RequiredStepUp bool
}
Decision is the outcome of Resolve.
type PolicyEngine ¶
type PolicyEngine interface {
Evaluate(ctx context.Context, c Caller, ability string, action Action, resource string) (Verdict, error)
}
PolicyEngine is the IAM evaluation the API supplies. One call applies visibility, team, environment and policy rules for the effective ability and the db action; an explicit Deny on either always wins.