service

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 认证接口错误返回.
	ErrorReasonServerBusy    = errors.New("服务器繁忙")
	ErrorReasonRelogin       = errors.New("请重新登陆")
	ErrorReasonWrongPassword = errors.New("用户或密码错误")
)
View Source
var ExpireTime = 3600 // token有效期

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

AuthConfig, 认证信息结构体,记录用户认证信息(可选).

type AuthDBConfig

type AuthDBConfig struct {
	DBName   string `yaml:"DBName"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Protocol string `yaml:"protocol"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

AuthDBConfig, mysql数据库信息结构体,该库用于存放用户认证信息(可选).

type AuthService

type AuthService struct {
	Port          int `yaml:"Port"`
	*AuthDBConfig `yaml:"AuthDBConfig,omitempty"`
	*AuthConfig   `yaml:"AuthConfig,omitempty"`
}

AuthService, bifrost认证服务结构体,用于用户认证.

func (*AuthService) Login

func (s *AuthService) Login(ctx context.Context, username, password string, unexpired bool) (string, error)

func (*AuthService) Verify

func (s *AuthService) Verify(ctx context.Context, token string) (bool, error)

type JWTClaims

type JWTClaims struct {
	jwt.RegisteredClaims
	UserID      int      `json:"user_id"`
	Password    string   `json:"password"`
	Username    string   `json:"username"`
	FullName    string   `json:"full_name"`
	Permissions []string `json:"permissions"`
}

JWTClaims, jwt断言对象,定义认证接口校验的用户信息.

type Service

type Service interface {
	Login(ctx context.Context, username, password string, unexpired bool) (string, error)
	Verify(ctx context.Context, token string) (bool, error)
}

type ServiceMiddleware

type ServiceMiddleware func(Service) Service

ServiceMiddleware define service middleware.

Jump to

Keyboard shortcuts

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