auth

package
v0.0.0-...-3839eb7 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenInvalid        = errs.NewI18nError("jwt.invalid").FallBack("invalid token").Code(code.UnAuthorized)
	ErrTokenParsedFailed   = errs.NewI18nError("jwt.parsed.failed").FallBack("token parsed failed").Code(code.Forbidden)
	ErrTokenExpired        = errs.NewI18nError("jwt.expired").FallBack("token expired").Code(code.UnAuthorized)
	ErrTokenNeedRefresh    = errs.NewI18nError("jwt.refresh").FallBack("token need to be refresh").Code(code.TokenNeedFresh)
	ErrWrongPassword       = errs.NewI18nError("user.wrongPassword").FallBack("wrong password")
	ErrTokenIssueFailed    = errs.NewI18nError("jwt.issue.failed").FallBack("token issue failed").Status(http.StatusInternalServerError)
	ErrRedundantExpiration = errs.NewI18nError("jwt.redundant").FallBack("redundant expiration").Code(code.RedundantRefresh)
)
View Source
var (
	ErrInvalidKey          = errs.NewI18nError("key.invalid").FallBack("invalid key")
	ErrKeyNoPerm           = errs.NewI18nError("key.noperm").FallBack("key has no permission")
	ErrInvalidKeyExpration = errs.NewI18nError("key.nopexp").FallBack("invalid expiration time")
)

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Name      string `json:"name"`
	Key       string `json:"key"`
	ExpiredAt uint64 `json:"expiredAt"`
}

type ForgotPasswordOption

type ForgotPasswordOption struct {
	// length of the password must be in range [10,30]
	Password string `json:"password" label:"field.password" example:"123456789"`
	// auth code get from user binding email
	Code string `json:"code" label:"field.code" example:"F294484D"`
}

func (ForgotPasswordOption) Validate

func (f ForgotPasswordOption) Validate(lang string) error

type KeyCreateOption

type KeyCreateOption struct {
	Uid       string `json:"-" swaggerignore:"true"`
	Name      string `json:"name"`
	Perms     []uint `json:"perms"`
	ExpiredAt int64  `json:"expiredAt"`
}

func (KeyCreateOption) Validate

func (c KeyCreateOption) Validate(lang string) error

type KeyRemoveOption

type KeyRemoveOption struct {
	system.Uid `json:"-" swaggerignore:"true"`
	Key        string `json:"key" uri:"key" form:"key"`
}

func (KeyRemoveOption) Validate

func (c KeyRemoveOption) Validate(lang string) error

type LoginOption

type LoginOption struct {
	// length of the username must be in range [6,20], and username must be Alphanumeric
	Username string `json:"username" label:"field.username" example:"dstadmin"`
	// length of the password must be in range [10,30]
	Password string `json:"password" label:"field.password" example:"0123456789"`

	Persistent bool `json:"persistent" example:"true"`
}

func (LoginOption) Validate

func (l LoginOption) Validate(lang string) error

type RefreshTokenOption

type RefreshTokenOption struct {
	Refresh string `json:"refresh" form:"refresh" uri:"refresh" label:"field.token.access"`
	Access  string `json:"access" form:"access" uri:"access" label:"field.token.refresh"`
}

func (RefreshTokenOption) Validate

func (r RefreshTokenOption) Validate(lang string) error

type RegisterOption

type RegisterOption struct {
	LoginOption
	// 8-digit auth code get from user binding email, and it must be Alphanumeric
	Code string `json:"code" label:"field.code" example:"F294484D"`
}

func (RegisterOption) Validate

func (r RegisterOption) Validate(lang string) error

type Token

type Token struct {
	// access token
	Token string `` /* 324-byte string literal not displayed */
	// refresh token
	Refresh string `` /* 336-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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