userinters

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 2 Imported by: 19

Documentation

Index

Constants

View Source
const (
	AuthMethodNameAnonymous    = "anonymous"
	AuthMethodNameUserPassword = "userPassword"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthForUserPolicy

type AuthForUserPolicy struct {
	UserID           uint64
	VerifiedMethods  []*VerifiedMethodWithTokenData
	SupportedMethods []string
}

type Authenticator

type Authenticator interface {
	GetMethodName() (method string)
	Verify(ctx context.Context) (uid uint64, tokenData []byte, ok bool, err error)
}

type AuthingData

type AuthingData struct {
	AuthForUserPolicy
	UniqueID uint64
	StartAt  time.Time
}

type AuthingDataStorage

type AuthingDataStorage interface {
	Store(ctx context.Context, d *AuthingData, expiration time.Duration) error
	Load(ctx context.Context, uniqueID uint64) (*AuthingData, error)
	Delete(ctx context.Context, uniqueID uint64) error
}

type LoginRequest

type LoginRequest struct {
	ContinueID        uint64
	Authenticators    []Authenticator
	TokenLiveDuration time.Duration
}

type LoginResponse

type LoginResponse struct {
	Status            LoginStatus
	RequiredOrMethods []string
	UserID            uint64
	Token             string
	ContinueID        uint64
}

type LoginStatus

type LoginStatus int
const (
	LoginStatusSuccess LoginStatus = iota
	LoginStatusNeedMoreAuthenticator
)

type Policy

type Policy interface {
	RequireAuthMethod(ctx context.Context, d *AuthForUserPolicy) (requiredOrMethods []string, err error)
}

type StatusController

type StatusController interface {
	IsTokenBanned(ctx context.Context, id uint64) (bool, error)
	BanToken(ctx context.Context, id uint64, expireAt int64) error
}

type UserCenter

type UserCenter interface {
	Login(ctx context.Context, request *LoginRequest) (resp *LoginResponse, err error)
	Logout(ctx context.Context, token string) (err error)

	CheckToken(ctx context.Context, token string, renewToken bool) (newToken string, uid uint64,
		tokenDataList map[string][]byte, err error)
}

type VerifiedMethodWithTokenData

type VerifiedMethodWithTokenData struct {
	MethodName string
	TokenData  []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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