libauth

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(NewAuth)

Functions

func FromContextAssertUserType added in v0.0.6

func FromContextAssertUserType(ctx context.Context, userTypes ...UserType) bool

func NewClaims

func NewClaims() jwtv4.Claims

Types

type Auth

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

func NewAuth

func NewAuth(config *conf.Auth) (*Auth, error)

func (*Auth) GeneratePassword

func (a *Auth) GeneratePassword(password string) (string, error)

func (*Auth) GenerateToken

func (a *Auth) GenerateToken(id model.InternalID, claimsType ClaimsType, userType UserType,
	transferMetadata any, expire time.Duration) (string, error)

func (*Auth) KeyFunc

func (a *Auth) KeyFunc(t ClaimsType) jwtv4.Keyfunc

type Claims

type Claims struct {
	InternalID       model.InternalID `json:"iid,string"`
	Type             ClaimsType       `json:"ct"`
	UserType         UserType         `json:"ut"`
	TransferMetadata any              `json:"tm,omitempty"`
	jwtv4.RegisteredClaims
}

func FromContext

func FromContext(ctx context.Context) (*Claims, bool)

type ClaimsType

type ClaimsType int
const (
	ClaimsTypeUnspecified ClaimsType = iota
	ClaimsTypeAccessToken
	ClaimsTypeRefreshToken
	ClaimsTypeUploadToken
	ClaimsTypeDownloadToken
)

type UserType

type UserType int
const (
	UserTypeUnspecified UserType = iota
	UserTypeAdmin
	UserTypeNormal
	UserTypeSentinel
)

Jump to

Keyboard shortcuts

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