auth

package module
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 34

Documentation

Overview

Package auth is used to generate authentication tokens used to connect to a given Amazon Relational Database Service (RDS) database.

Before using the authentication please visit the docs here to ensure the database has the proper policies to allow for IAM token authentication. https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html#UsingWithRDS.IAMDBAuth.Availability https://aws.github.io/aws-sdk-go-v2/docs/sdk-utilities/rds

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAuthToken

func BuildAuthToken(ctx context.Context, endpoint, region, dbUser string, creds aws.CredentialsProvider, optFns ...func(options *BuildAuthTokenOptions)) (string, error)

BuildAuthToken will return an authorization token used as the password for a DB connection.

* endpoint - Endpoint consists of the port needed to connect to the DB. <host>:<port> * region - Region is the location of where the DB is * dbUser - User account within the database to sign in with * creds - Credentials to be signed with

The following example shows how to use BuildAuthToken to create an authentication token for connecting to a MySQL database in RDS.

authToken, err := BuildAuthToken(dbEndpoint, awsRegion, dbUser, awsCreds)

// Create the MySQL DNS string for the DB connection
// user:password@protocol(endpoint)/dbname?<params>
connectStr = fmt.Sprintf("%s:%s@tcp(%s)/%s?allowCleartextPasswords=true&tls=rds",
   dbUser, authToken, dbEndpoint, dbName,
)

// Use db to perform SQL operations on database
db, err := sql.Open("mysql", connectStr)

See http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html for more information on using IAM database authentication with RDS.

Types

type BuildAuthTokenOptions

type BuildAuthTokenOptions struct{}

BuildAuthTokenOptions is the optional set of configuration properties for BuildAuthToken

Jump to

Keyboard shortcuts

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