auth

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 13 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 BackendCap added in v0.5.3

type BackendCap struct {
	PG     *PGCap     `json:"pg,omitempty"`
	Mongo  *MongoCap  `json:"mongo,omitempty"`
	Limits *LimitsCap `json:"limits,omitempty"`
}

BackendCap holds per-backend capabilities and limits.

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 {
	Limits   *LimitsCap            `json:"limits,omitempty"`
	Backends map[string]BackendCap `json:"backends"`
}

CapRule represents a single capability rule from the Tailscale ACL grant. Top-level Limits apply globally (per-user across all backends). Each backend entry in Backends carries its own PG and Limits (per-endpoint).

func (*CapRule) UnmarshalJSON added in v0.5.3

func (c *CapRule) UnmarshalJSON(data []byte) error

UnmarshalJSON supports both the current schema (backends as a map) and the legacy schema (backends as a string array with top-level pg/endpoint_limits).

type DBPermissions

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

DBPermissions defines access grants for a database. Permissions holds preset names ("readonly", "readwrite", "admin"). Schemas controls which schemas presets apply to (default: ["public"]). SQL holds advanced raw SQL templates (gateable by server config). 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, backend string, database string) *DBPermissions

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

type EndpointLimits added in v0.5.3

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

EndpointLimits holds per-endpoint restriction overrides.

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 {
	// Per-user (global) limits — checked against root key (waypoint:conns:<user>).
	MaxConns        int
	MaxBytesPerConn int64
	MaxConnDuration time.Duration
	BandwidthTiers  []BandwidthTier

	// Per-endpoint limits — checked against leaf key (waypoint:conns:<user>/<listener>).
	// Nil means no endpoint-specific limits (only global apply).
	Endpoint *EndpointLimits
}

MergedLimits holds the resolved limits after merging all matching rules.

type MongoCap added in v0.6.3

type MongoCap struct {
	Databases map[string]MongoDBPermissions `json:"databases"`
}

MongoCap holds MongoDB-specific capabilities.

type MongoDBPermissions added in v0.6.3

type MongoDBPermissions struct {
	Permissions []string `json:"permissions"`
}

MongoDBPermissions defines access grants for a MongoDB database. Permissions holds preset names ("readonly", "readwrite", "admin").

func MongoDatabasePermissions added in v0.6.3

func MongoDatabasePermissions(result *AuthResult, backend string, database string) *MongoDBPermissions

MongoDatabasePermissions returns the merged MongoDB permissions for a specific database from the matched rules for the given backend. Returns nil if no rules grant access to the database.

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