service

package
v0.0.0-...-1c8f81e Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth() *jwt.GfJWTMiddleware

func Authenticator

func Authenticator(ctx context.Context) (interface{}, error)

Authenticator is used to validate login parameters. It must return user data as user identifier, it will be stored in Claim Array. if your identityKey is 'id', your user data must have 'id' Check error (e) to determine the appropriate error message.

func IdentityHandler

func IdentityHandler(ctx context.Context) interface{}

IdentityHandler get the identity from JWT and set the identity for every request Using this function, by r.GetParam("id") get identity

func PayloadFunc

func PayloadFunc(data interface{}) jwt.MapClaims

PayloadFunc is a callback function that will be called during login. Using this function it is possible to add additional payload data to the webtoken. The data is then made available during requests via c.Get("JWT_PAYLOAD"). Note that the payload is not encrypted. The attributes mentioned on jwt.io can't be used as keys for the map. Optional, by default no additional data will be set.

func RegisterCaptcha

func RegisterCaptcha(i ICaptcha)

func RegisterMiddleware

func RegisterMiddleware(i IMiddleware)

func RegisterUser

func RegisterUser(i IUser)

func Unauthorized

func Unauthorized(ctx context.Context, code int, message string)

Unauthorized is used to define customized Unauthorized callback function.

Types

type ICaptcha

type ICaptcha interface {
	NewAndStore(ctx context.Context, name string) error
	VerifyAndClear(r *ghttp.Request, name string, value string) bool
}

func Captcha

func Captcha() ICaptcha

type IMiddleware

type IMiddleware interface {
	ResponseHandler(r *ghttp.Request)
	Ctx(r *ghttp.Request)
	Auth(r *ghttp.Request)
}

func Middleware

func Middleware() IMiddleware

type IUser

type IUser interface {
	Add(ctx context.Context, in model.AddUserInput) (out *model.AddUserOutput, err error)
	Update(ctx context.Context, in model.UpdateUserInput) (err error)

	Login(ctx context.Context, in model.UserLoginInput) (out *model.UserLoginOutput, err error)
	Logout(ctx context.Context) (err error)
	GetCurrentUserInfo(ctx context.Context) (out *model.UserInfo, err error)
}

func User

func User() IUser

Jump to

Keyboard shortcuts

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