provision

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MongoPresetNames = []string{"readonly", "readwrite", "admin"}

MongoPresetNames lists all recognized MongoDB preset names.

View Source
var PresetNames = []string{"readonly", "readwrite", "admin"}

PresetNames lists all recognized preset names.

Functions

func ExpandPresets added in v0.5.0

func ExpandPresets(presets []string, schemas []string) ([]string, error)

ExpandPresets expands preset names into GRANT fragments for the given schemas. Returns fragments suitable for use as: GRANT <fragment> TO <role>.

Types

type Dialect added in v0.2.0

type Dialect int

Dialect represents the database backend type.

const (
	// DialectPostgres is standard PostgreSQL.
	DialectPostgres Dialect = iota
	// DialectCockroachDB is CockroachDB.
	DialectCockroachDB
)

type MongoProvisioner added in v0.6.3

type MongoProvisioner struct {
	// contains filtered or unexported fields
}

MongoProvisioner manages dynamic MongoDB user lifecycle.

func NewMongoProvisioner added in v0.6.3

func NewMongoProvisioner(adminUser, adminPassword, backend, authDatabase, userPrefix, peerService string, backendTLS bool, store *restrict.RedisStore, logger *slog.Logger, dialFunc func(ctx context.Context, network, addr string) (net.Conn, error)) *MongoProvisioner

NewMongoProvisioner creates a new MongoProvisioner.

func NewMongoReplicaSetProvisioner added in v0.6.3

func NewMongoReplicaSetProvisioner(adminUser, adminPassword string, backends []string, replicaSet, authDatabase, userPrefix, peerService string, backendTLS bool, store *restrict.RedisStore, logger *slog.Logger, dialFunc func(ctx context.Context, network, addr string) (net.Conn, error)) *MongoProvisioner

NewMongoReplicaSetProvisioner creates a Mongo provisioner that can discover the primary from a replica set seed list. When replicaSet is empty and a single backend is supplied, it uses directConnection=true for standalone compatibility.

func (*MongoProvisioner) EnsureUser added in v0.6.3

func (p *MongoProvisioner) EnsureUser(ctx context.Context, loginName, nodeName string, roles []MongoRole) (string, string, error)

EnsureUser creates or updates a dynamic MongoDB user for the given identity and node with the specified roles across all permitted databases. Returns the MongoDB username and password.

Credentials are cached with a short TTL to prevent password rotation races when multiple connections for the same user arrive concurrently.

type MongoRole added in v0.6.3

type MongoRole struct {
	Role string `bson:"role"`
	DB   string `bson:"db"`
}

MongoRole represents a MongoDB role assignment.

func ExpandMongoPresets added in v0.6.3

func ExpandMongoPresets(presets []string, database string) ([]MongoRole, error)

ExpandMongoPresets expands preset names into MongoDB role assignments for the given database.

type Provisioner

type Provisioner struct {
	// contains filtered or unexported fields
}

Provisioner manages dynamic PostgreSQL user lifecycle.

func NewProvisioner

func NewProvisioner(adminUser, adminPassword, adminDatabase, backend, userPrefix string, backendTLS, allowRawSQL bool, peerService string, store *restrict.RedisStore, logger *slog.Logger, dialFunc func(ctx context.Context, network, addr string) (net.Conn, error), lookupFunc func(ctx context.Context, host string) ([]string, error)) *Provisioner

NewProvisioner creates a new Provisioner.

func (*Provisioner) EnsureUser

func (p *Provisioner) EnsureUser(ctx context.Context, loginName, nodeName, database string, perms *auth.DBPermissions) (string, string, error)

EnsureUser creates or updates a dynamic PG role for the given identity, node, and database. Returns the PG username and password.

type SQLTemplateData

type SQLTemplateData struct {
	Role string // Sanitized PG role identifier
}

SQLTemplateData holds the variables available in SQL templates.

Jump to

Keyboard shortcuts

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