dbauthz

package
v1.5.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const ResourcePrefix = "database:"

ResourcePrefix is the policy resource namespace for databases.

Variables

Actions lists every known db action, for policy validation.

Functions

func DenyNames

func DenyNames(a Action) []string

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

func EffectiveAbility(a Action) string

EffectiveAbility is the flat ability an action needs today; unknown actions map to root so a mistake fails closed.

func Known

func Known(s string) bool

Known reports whether s names a db action.

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"
)

The db actions, named as in IAM policy documents.

type Caller

type Caller struct {
	PrincipalType string
	PrincipalID   string
	Abilities     []string
	StepUpFresh   bool
}

Caller is the authenticated principal making the request.

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 Limits

type Limits struct {
	MaxRows        int
	TimeoutSeconds int
}

Limits are per decision caps the handler applies; zero means engine default.

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.

type Resolver

type Resolver struct {
	Engine          PolicyEngine
	Limits          Limits
	EnforceStepUp   bool
	LimitsForAction func(Action) Limits
}

Resolver holds the engine and settings Resolve needs.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, caller Caller, resource string, action Action) (Decision, error)

Resolve decides whether caller may perform action on resource ("database:name"). Any error or doubt denies.

type Verdict

type Verdict struct {
	Allowed  bool
	Denied   bool
	Hidden   bool
	ByAction bool // granted only by a policy Allow naming the db action
}

Verdict is the engine's single answer for one action on one resource.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL