core

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: MIT Imports: 11 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsufficientStrength = errors.New("insufficient strength")
)

Functions

func ToContext

func ToContext(parent context.Context, ctx *Context) context.Context

Types

type Context

type Context struct {
	UserID     string
	TenantID   string
	Claims     map[string]interface{}
	IsLoggedIn bool
	TenantSide TenantSide

	AutoSetTenantID        bool
	MultiTenancyDataFilter bool
}

func FromContext

func FromContext(ctx context.Context) *Context

func NewContext

func NewContext() *Context

func (*Context) AreAllGranted added in v0.0.3

func (c *Context) AreAllGranted(claim string, something ...string) bool

func (*Context) IsAnyGranted added in v0.0.3

func (c *Context) IsAnyGranted(claim string, something ...string) bool

type ContextKey

type ContextKey struct{}

type ILookupNormalizer

type ILookupNormalizer interface {
	Normalize(string) string
}

func NewLookupNormalizer

func NewLookupNormalizer() ILookupNormalizer

type IPasswordHasher

type IPasswordHasher interface {
	HashPassword(ctx context.Context, plainPassword string) (hash string, err error)
	VerifyHashedPassword(ctx context.Context, hashedPassword string, plainPassword string) bool
}

func NewArgon2PasswordHasher

func NewArgon2PasswordHasher() IPasswordHasher

func NewBcryptPasswordHasher

func NewBcryptPasswordHasher() IPasswordHasher

type IPasswordValidator

type IPasswordValidator interface {
	Validate(ctx context.Context, password string) error
}

func NewPasswordValidator

func NewPasswordValidator() IPasswordValidator

type ITokenizer

type ITokenizer interface {
	Issue(userID string, extra map[string]interface{}) (token string, err error)
	Parse(token string) (claims jwt.Claims, err error)
	ParseFromReq(req *http.Request) (claims jwt.Claims, err error)
}

func NewTokenizer

func NewTokenizer(c *TokenizerConfig) ITokenizer

type TenantSide

type TenantSide int
const (
	UNKNOWN TenantSide = iota
	HOST
	TENANT
)

type TokenizerConfig

type TokenizerConfig struct {
	ExpireDuration time.Duration
	Secret         string
}

Jump to

Keyboard shortcuts

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