auth

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const WaypointCap = "redo.com/cap/waypoint"
View Source
const WaypointManagerCap = "redo.com/cap/waypointManager"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResult

type AuthResult struct {
	LoginName    string
	NodeName     string
	Permissions  []string // all merged PG permissions (across all databases)
	Limits       MergedLimits
	MatchedRules []CapRule // rules that matched the backend, for per-database lookup
}

AuthResult is returned after successful authorization.

func Authorize

func Authorize(ctx context.Context, lc *local.Client, remoteAddr string, backend string, logger *slog.Logger) (*AuthResult, error)

Authorize checks the caller's Tailscale identity and capability grants for the given backend listener name.

type BandwidthCap

type BandwidthCap struct {
	Bytes  int64  `json:"bytes"`
	Period string `json:"period"`
}

BandwidthCap defines a byte budget over a time period.

type BandwidthTier

type BandwidthTier struct {
	Bytes  int64
	Period time.Duration
}

BandwidthTier defines a byte budget over a time period.

type CapRule

type CapRule struct {
	Backends []string   `json:"backends"`
	PG       *PGCap     `json:"pg,omitempty"`
	Limits   *LimitsCap `json:"limits,omitempty"`
}

CapRule represents a single capability rule from the Tailscale ACL grant.

type DBPermissions

type DBPermissions struct {
	Permissions []string `json:"permissions"`
	SQL         []string `json:"sql,omitempty"`
}

DBPermissions lists SQL GRANT statements and raw SQL for a database. SQL entries are Go text/template strings. Available variables:

  • {{.Role}} — the sanitized PG role identifier for the connecting user

func DatabasePermissions

func DatabasePermissions(result *AuthResult, database string) *DBPermissions

DatabasePermissions returns the merged permissions for a specific database from the matched rules. Returns nil if no rules grant access to the database.

type LimitsCap

type LimitsCap struct {
	MaxConns        int            `json:"max_conns,omitempty"`
	MaxBytesPerConn int64          `json:"max_bytes_per_conn,omitempty"`
	MaxConnDuration string         `json:"max_conn_duration,omitempty"`
	Bandwidth       []BandwidthCap `json:"bandwidth,omitempty"`
}

LimitsCap defines per-user restriction overrides from ACL grants.

type ManagerAuthResult

type ManagerAuthResult struct {
	LoginName string
	NodeName  string
}

ManagerAuthResult is returned after successful manager authorization.

func AuthorizeManager

func AuthorizeManager(ctx context.Context, lc *local.Client, remoteAddr string, logger *slog.Logger) (*ManagerAuthResult, error)

AuthorizeManager checks whether the caller has the waypointManager capability.

type ManagerCapRule

type ManagerCapRule struct {
}

ManagerCapRule represents a capability rule for the waypoint manager.

type MergedLimits

type MergedLimits struct {
	MaxConns        int
	MaxBytesPerConn int64
	MaxConnDuration time.Duration
	BandwidthTiers  []BandwidthTier
}

MergedLimits holds the resolved limits after merging all matching rules.

type PGCap

type PGCap struct {
	Databases map[string]DBPermissions `json:"databases"`
}

PGCap holds postgres-specific capabilities.

Jump to

Keyboard shortcuts

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