credsutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MPL-2.0 Imports: 6 Imported by: 19

Documentation

Index

Constants

View Source
const (
	NoneLength int = -1
)

Variables

This section is empty.

Functions

func GenerateUsername added in v0.2.0

func GenerateUsername(opts ...UsernameOpt) (string, error)

func RandomAlphaNumeric

func RandomAlphaNumeric(length int, prependA1a bool) (string, error)

RandomAlphaNumeric returns a random string of characters [A-Za-z0-9-] of the provided length. The string generated takes up to 4 characters of space that are predefined and prepended to ensure password character requirements. It also requires a min length of 10 characters.

Types

type CaseOp added in v0.2.0

type CaseOp int
const (
	KeepCase CaseOp = iota
	Uppercase
	Lowercase
)

type CredentialsProducer

type CredentialsProducer interface {
	GenerateCredentials(context.Context) (string, error)
	GenerateUsername(dbplugin.UsernameConfig) (string, error)
	GeneratePassword() (string, error)
	GenerateExpiration(time.Time) (string, error)
}

CredentialsProducer can be used as an embedded interface in the Database definition. It implements the methods for generating user information for a particular database type and is used in all the builtin database types.

type SQLCredentialsProducer

type SQLCredentialsProducer struct {
	DisplayNameLen    int
	RoleNameLen       int
	UsernameLen       int
	Separator         string
	LowercaseUsername bool
}

SQLCredentialsProducer implements CredentialsProducer and provides a generic credentials producer for most sql database types.

func (*SQLCredentialsProducer) GenerateCredentials added in v0.1.12

func (scp *SQLCredentialsProducer) GenerateCredentials(ctx context.Context) (string, error)

func (*SQLCredentialsProducer) GenerateExpiration

func (scp *SQLCredentialsProducer) GenerateExpiration(ttl time.Time) (string, error)

func (*SQLCredentialsProducer) GeneratePassword

func (scp *SQLCredentialsProducer) GeneratePassword() (string, error)

func (*SQLCredentialsProducer) GenerateUsername

func (scp *SQLCredentialsProducer) GenerateUsername(config dbplugin.UsernameConfig) (string, error)

type UsernameOpt added in v0.2.0

type UsernameOpt func(*usernameBuilder)

func Case added in v0.2.0

func Case(c CaseOp) UsernameOpt

func DisplayName added in v0.2.0

func DisplayName(dispName string, maxLength int) UsernameOpt

func MaxLength added in v0.2.0

func MaxLength(maxLen int) UsernameOpt

func RoleName added in v0.2.0

func RoleName(roleName string, maxLength int) UsernameOpt

func Separator added in v0.2.0

func Separator(sep string) UsernameOpt

func ToLower added in v0.2.0

func ToLower() UsernameOpt

func ToUpper added in v0.2.0

func ToUpper() UsernameOpt

Jump to

Keyboard shortcuts

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