Documentation
¶
Index ¶
- Variables
- func ExpandPresets(presets []string, schemas []string) ([]string, error)
- type Dialect
- type MongoProvisioner
- type MongoRole
- type Provisioner
- func (p *Provisioner) EnsureUser(ctx context.Context, loginName, nodeName, database string, ...) (string, string, error)
- func (p *Provisioner) EnsureUserWithRoleScope(ctx context.Context, loginName, nodeName, database, roleScope string, ...) (string, string, error)
- func (p *Provisioner) ReconcileRole(ctx context.Context, pgUser, database string, perms *auth.DBPermissions) error
- func (p *Provisioner) SetCredentialTTL(d time.Duration)
- type SQLTemplateData
Constants ¶
This section is empty.
Variables ¶
var ErrLockBusy = errors.New("role busy: another connection is provisioning it")
ErrLockBusy is returned when a role lock could not be taken within the caller's budget. It means another connection is provisioning the same role, not that the backend is broken, so callers can surface a retryable error.
var MongoPresetNames = []string{"readonly", "readwrite", "admin"}
MongoPresetNames lists all recognized MongoDB preset names.
var PresetNames = []string{"readonly", "readwrite", "admin"}
PresetNames lists all recognized preset names.
Functions ¶
Types ¶
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 NewMongoShardedProvisioner ¶ added in v0.7.0
func NewMongoShardedProvisioner(adminUser, adminPassword string, mongosBackends []string, authDatabase, userPrefix, peerService string, backendTLS bool, store *restrict.RedisStore, logger *slog.Logger, dialFunc func(ctx context.Context, network, addr string) (net.Conn, error)) *MongoProvisioner
NewMongoShardedProvisioner creates a Mongo provisioner that connects to a sharded cluster through its mongos routers. Unlike the replica-set provisioner it never sets replicaSet or directConnection, so the driver detects the sharded topology and routes createUser/updateUser through a mongos — which propagates the change to the config servers and all shards.
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 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.
func (*Provisioner) EnsureUserWithRoleScope ¶ added in v0.6.6
func (p *Provisioner) EnsureUserWithRoleScope(ctx context.Context, loginName, nodeName, database, roleScope string, perms *auth.DBPermissions) (string, string, error)
EnsureUserWithRoleScope creates or updates a dynamic PG role with an additional role-name scope. The database used for grants is unchanged.
func (*Provisioner) ReconcileRole ¶ added in v0.6.6
func (p *Provisioner) ReconcileRole(ctx context.Context, pgUser, database string, perms *auth.DBPermissions) error
ReconcileRole updates privileges for an existing backend role without rotating its password. It is used by active sessions during revalidation.
func (*Provisioner) SetCredentialTTL ¶ added in v0.7.0
func (p *Provisioner) SetCredentialTTL(d time.Duration)
SetCredentialTTL overrides how long a provisioned role's password stays in effect before the next connection rotates it. Zero restores rotate-on-every- connection. Intended for tests.
type SQLTemplateData ¶
type SQLTemplateData struct {
Role string // Sanitized PG role identifier
}
SQLTemplateData holds the variables available in SQL templates.