auth

package
v0.0.0-...-0ea6ada Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAdminUser     = "admin"
	DefaultAdminPassword = "admin"
)

Default admin credentials

Variables

View Source
var PasswordRequirementsMsg = fmt.Sprintf(
	"password must have between %d and %d characters of which at least "+
		"1 uppercase letter, 1 digit and 1 special character",
	minPasswordLen,
	maxPasswordLen,
)

PasswordRequirementsMsg message used to inform the user about password strength requirements

View Source
var ValidRolesMsg = fmt.Sprintf(
	"valid roles: %d = %s, %d = %s",
	RoleAdmin, RoleAdmin,
	RoleAuditor, RoleAuditor,
)

ValidRolesMsg ...

Functions

func ComparePasswords

func ComparePasswords(plainPassword string, hashedPassword string) bool

ComparePasswords ...

func GenerateOrLoadKeys

func GenerateOrLoadKeys() error

GenerateOrLoadKeys ...

func GenerateToken

func GenerateToken(userID int64, role Role) (string, time.Time, error)

GenerateToken ...

func HashAndSaltPassword

func HashAndSaltPassword(password string) (string, error)

HashAndSaltPassword ...

func IsStrongPassword

func IsStrongPassword(password string) error

IsStrongPassword checks if the provided password meets the strength requirements

func IsValidRole

func IsValidRole(role int) bool

IsValidRole ...

Types

type JSONToken

type JSONToken struct {
	UserID     int64
	Role       Role
	Expiration time.Time
}

JSONToken ...

func VerifyToken

func VerifyToken(token string) (*JSONToken, error)

VerifyToken ...

type Role

type Role uint8

Role ...

const (
	RoleAdmin Role = iota + 1
	RoleAuditor
)

Roles ...

func ParseRole

func ParseRole(roleStr string) (Role, error)

ParseRole ...

func (Role) String

func (r Role) String() string

Jump to

Keyboard shortcuts

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