models

package
v0.0.0-...-412dc8c Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KDFAlgorithmV1Name   = "argon2id-v1"
	KDFAlgorithmV1Time   = 2
	KDFAlgorithmV1Memory = 64 * 1024
	KDFAlgorithmV1Thread = 4
	KDFAlgorithmV1KeyLen = 64
)
View Source
const (
	UserTypeNormal = "user"
	UserTypeAdmin  = "admin"
)

Variables

This section is empty.

Functions

func Models

func Models() []interface{}

Models List all known database models.

Types

type KDF

type KDF struct {
	Algorithm    string `gorm:"type:enum('argon2id-v1')"`
	PasswordHash []byte `gorm:"size:64"`
	Salt         []byte `gorm:"size:64"`
	TimeFactor   uint32
	MemoryFactor uint32
	ThreadFactor uint8
	KeyLen       uint32
}

func GenKDF

func GenKDF(password string) KDF

GenKDF Generate a new KDF object using the given password, storing the password hash.

func NewKDF

func NewKDF() KDF

NewKDF Generate a new KDF object without a password hash.

func (KDF) Derive

func (k KDF) Derive(password string) [64]byte

func (KDF) Validate

func (k KDF) Validate(password string) bool

type User

type User struct {
	Email     string
	FirstName string
	LastName  string
	Role      string `gorm:"type:enum('user','admin')"`
	KDF       KDF    `gorm:"embedded;embeddedPrefix:kdf_"`
	gorm.Model
}

func (User) Name

func (u User) Name() string

Jump to

Keyboard shortcuts

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