auth

package
v0.0.0-...-d8adeec Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxUserInfo = "user"
)
View Source
const (
	TokenTTLHours = time.Hour * 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AClaims

type AClaims struct {
	jwt.StandardClaims
	UserID string         `json:"user_id"`
	Role   model.UserRole `json:"role"`
}

func NewClaims

func NewClaims(userID string, role model.UserRole) AClaims

type AuthInterceptor

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

func NewAuthInterceptor

func NewAuthInterceptor(tokenManager TokenManager, whiteList map[string]interface{}) AuthInterceptor

func (AuthInterceptor) Unary

type Hasher

type Hasher struct {
}

func NewHasher

func NewHasher() Hasher

func (Hasher) Hash

func (h Hasher) Hash(password string) (string, error)

func (Hasher) IsValid

func (h Hasher) IsValid(password, hash string) bool

type TokenManager

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

func NewTokenManager

func NewTokenManager(secret string) TokenManager

func (TokenManager) Parse

func (m TokenManager) Parse(tokenString string) (*AClaims, error)

func (TokenManager) Sign

func (m TokenManager) Sign(claims jwt.Claims) (string, error)

type UserInfo

type UserInfo struct {
	UserID string
	Role   model.UserRole
}

func UserInfoFromContext

func UserInfoFromContext(ctx context.Context) *UserInfo

Jump to

Keyboard shortcuts

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