libauth

package
v0.0.6-4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 9 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 int64, claimsType ClaimsType, userType UserType,
	transferMetadata *TransferMetadata, expire time.Duration) (string, error)

func (*Auth) KeyFunc

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

type Claims

type Claims struct {
	InternalID       int64             `json:"iid"`
	Type             ClaimsType        `json:"ct"`
	UserType         UserType          `json:"ut"`
	TransferMetadata *TransferMetadata `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 TransferMetadata

type TransferMetadata struct {
	Name      string `json:"n"`
	Size      int64  `json:"s"`
	ChunkSize int64  `json:"cs"`
	CallBack  int    `json:"cb"`
}

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