gormauth

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 11 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)

Gets a GORM DB handle for a MySQL database

Types

type GetMysqlGormInput

type GetMysqlGormInput struct {
	// REQUIRED: Input values for the write dialector
	WriteDialectorInput dialectors.MysqlDialectorInput
	// OPTIONAL: Input values for the read dialector
	ReadDialectorInput dialectors.MysqlDialectorInput
	// OPTIONAL: A set of GORM options to use for the connections
	GormOptions []gorm.Option
	// OPTIONAL: A function that gets the TLS config to use for a
	// connection based on the given host name
	GetTlsConfigFunc GetTlsConfigCallback
}

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