roleoption

package
v0.0.0-...-1b6ad0c Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BcryptCost = bcrypt.DefaultCost
View Source
var ByName = map[string]Option{
	"CREATEROLE":   CREATEROLE,
	"NOCREATEROLE": NOCREATEROLE,
	"PASSWORD":     PASSWORD,
	"LOGIN":        LOGIN,
	"NOLOGIN":      NOLOGIN,
	"VALID_UNTIL":  VALIDUNTIL,
}

ByName is a map of string -> kind value.

View Source
var ErrEmptyPassword = errors.New("empty passwords are not permitted")

ErrEmptyPassword indicates that an empty password was attempted to be set.

Functions

func HashPassword

func HashPassword(password string) ([]byte, error)

HashPassword takes a raw password and returns a bcrypt hashed password.

Types

type List

type List []RoleOption

List is a list of role options.

func (List) CheckRoleOptionConflicts

func (rol List) CheckRoleOptionConflicts() error

CheckRoleOptionConflicts returns an error if two or more options conflict with each other.

func (List) Contains

func (rol List) Contains(p Option) bool

Contains returns true if List contains option, false otherwise.

func (List) GetHashedPassword

func (rol List) GetHashedPassword() ([]byte, error)

GetHashedPassword returns the value of the password after hashing it. Returns error if no password option is found or if password is invalid.

func (List) GetSQLStmts

func (rol List) GetSQLStmts(op string) (map[string]func() (bool, string, error), error)

GetSQLStmts returns a map of SQL stmts to apply each role option. Maps stmts to values (value of the role option).

func (List) ToBitField

func (rol List) ToBitField() (uint32, error)

ToBitField returns the bitfield representation of a list of role options.

type Option

type Option uint32

Option defines a role option. This is output by the parser

const (
	CREATEROLE Option
	NOCREATEROLE
	PASSWORD
	LOGIN
	NOLOGIN
	VALIDUNTIL
)

KindList of role options.

func ToOption

func ToOption(str string) (Option, error)

ToOption takes a string and returns the corresponding Option.

func (Option) Mask

func (o Option) Mask() uint32

Mask returns the bitmask for a given role option.

func (Option) String

func (i Option) String() string

type RoleOption

type RoleOption struct {
	Option
	HasValue bool
	// Need to resolve value in Exec for the case of placeholders.
	Value func() (bool, string, error)
}

RoleOption represents an Option with a value.

Jump to

Keyboard shortcuts

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