dbauth

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderName = "dbauth"

Functions

This section is empty.

Types

type Dependencies

type Dependencies struct {
	Db                   GormReadWrite
	Log                  Logger
	Secret               string
	GetUserRecordsFunc   func() []UserRecord
	SaveUserRecordFunc   func(user UserRecord) error
	GenerateAuthHashFunc func(user UserRecord) string
	HashWorkFactor       int
}

type GormReadWrite

type GormReadWrite interface {
	Read() *gorm.DB
	Write() *gorm.DB
}

type Logger

type Logger interface {
	InfoF(category string, message string, args ...interface{})
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func New

func New(dependencies Dependencies) (*Provider, error)

func (*Provider) ChangePassword added in v0.9.0

func (a *Provider) ChangePassword(ctx *fasthttp.RequestCtx) (bool, map[string]error)

func (*Provider) GenerateLoginToken added in v0.9.0

func (a *Provider) GenerateLoginToken(user UserRecord) (string, error)

func (*Provider) GetPermissions added in v0.10.0

func (a *Provider) GetPermissions(ctx *fasthttp.RequestCtx) []string

func (*Provider) GetProviderName

func (a *Provider) GetProviderName() string

func (*Provider) GetUniqueIdentifier

func (a *Provider) GetUniqueIdentifier(ctx *fasthttp.RequestCtx) string

func (*Provider) IsAuthenticated

func (a *Provider) IsAuthenticated(ctx *fasthttp.RequestCtx) bool

func (*Provider) Login

func (a *Provider) Login(ctx *fasthttp.RequestCtx) (bool, map[string]error)

func (*Provider) Logout

func (a *Provider) Logout(ctx *fasthttp.RequestCtx) bool

func (*Provider) Register

func (a *Provider) Register(ctx *fasthttp.RequestCtx) (bool, map[string]error)

func (*Provider) SetAuthCookie

func (a *Provider) SetAuthCookie(ctx *fasthttp.RequestCtx, user UserRecord) error

type UserClaim

type UserClaim struct {
	Email    string `json:"email"`
	AuthHash string `json:"auth_hash"`
	jwt.StandardClaims
}

type UserRecord

type UserRecord interface {
	GetEmail() string
	SetEmail(email string)
	GetPassword() string
	SetPassword(password string)
	GetCreated() time.Time
	GetPermissions() []string
}

Jump to

Keyboard shortcuts

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