auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const IDKey = "aibou_id"

Variables

View Source
var PBKDF2DefaultIter = 8192
View Source
var PBKDF2DefaultKeyLen = 20
View Source
var PBKDF2DefaultSaltLen = 64
View Source
var PBKDF2Hash = sha3.New512
View Source
var TestNoHashAuth = TestNoSecurity{}

Functions

func OK

func OK(c *gin.Context) error

func Salt

func Salt(saltLen int) (salt []byte)

func SaltDefault

func SaltDefault() (salt []byte)

func SetupJWT

func SetupJWT(app *gin.Engine, middleware bool) gin.HandlerFunc

func User

func User(c *gin.Context) (types.User, error)

Types

type AuthBackend

type AuthBackend interface {
	CheckID(string) bool
	CheckIDPBKDF2(string, string) bool
	Close() error
}
var JWTAuthBackend AuthBackend = TestNoHashAuth

type JWTAuthBind

type JWTAuthBind struct {
	ID   string `json:"id" binding:"required"`
	Pass string `json:"pass" binding:"required"`
}

type JWTUser

type JWTUser struct {
	ID string
}

type PBKDF2Config

type PBKDF2Config struct {
	Pass   []byte `json:"pass"`
	Salt   []byte `json:"salt"`
	Iter   int    `json:"iter"`
	KeyLen int    `json:"key_len"`
}

func FromJSON

func FromJSON(src []byte) (config PBKDF2Config, err error)

func (PBKDF2Config) Key

func (config PBKDF2Config) Key() []byte

func (PBKDF2Config) ToJSON

func (config PBKDF2Config) ToJSON() (src []byte)

type Redis

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

func NewRedis

func NewRedis(opt godis.Option) *Redis

func (*Redis) CheckID

func (r *Redis) CheckID(id string) bool

func (*Redis) CheckIDPBKDF2

func (r *Redis) CheckIDPBKDF2(id string, pass string) bool

func (*Redis) Close

func (r *Redis) Close() error

type TestNoSecurity

type TestNoSecurity struct{}

func (TestNoSecurity) CheckID

func (t TestNoSecurity) CheckID(id string) bool

func (TestNoSecurity) CheckIDPBKDF2

func (t TestNoSecurity) CheckIDPBKDF2(id string, hash string) bool

func (TestNoSecurity) Close

func (t TestNoSecurity) Close() error

Jump to

Keyboard shortcuts

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