gormauth

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 12 Imported by: 0

README

GORM Dynamic Authentication

This package implements easy-to-use dynamic authentication for GORM connections. This is useful when using any kind of authentication mechanism where credentials may change between when the GORM handle is initially created and when new connections may open. Examples could include username/password credentials that are rotated frequently, or IAM authentication with AWS RDS.

Database Support

This package supports MySQL, and theoretically supports PostgreSQL as well, although that has not yet been tested. It is built in a modular fashion that supports the implementation of additional databases as well. See the connectors and dialectors submodules.

Examples

We have provided examples for the following use cases:

For more custom implementations (multiple sources, multiple replicas, etc.), see the internal workings of the functions used in the examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMysqlGorm

func GetMysqlGorm(
	ctx context.Context,
	input GetMysqlGormInput,
) (*gorm.DB, stackerr.Error)

Types

type ConnectionParameters added in v0.3.1

type ConnectionParameters struct {
	DialectorInput dialectors.MysqlDialectorInput
	// OPTIONAL: A function that gets the TLS config to use for a
	// connection based on the given host name
	GetTlsConfigFunc GetTlsConfigCallback
	AuthSettings     authenticators.AuthenticationSettings
}

type GetMysqlGormInput

type GetMysqlGormInput struct {
	// Input values for write connections
	WriteConnectionParameters []*ConnectionParameters
	// Input values for read connections
	ReadConnectionParameters []*ConnectionParameters
	// OPTIONAL: A set of GORM options to use for all connections
	GormOptions []gorm.Option
	// OPTIONAL: The policy to use for connecting to read replicas.
	// If not provided, the Random policy will be used.
	ReplicaPolicy dbresolver.Policy
}

The input values for getting a standard MySQL GORM DB handle

type GetTlsConfigCallback

type GetTlsConfigCallback func(ctx context.Context, host string) (*tls.Config, stackerr.Error)

A function signature for a callback function that gets the TLS configuration to use for a specific host.

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

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