5 Star 14 Fork 12

go-course / go12

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
interface.go 917 Bytes
一键复制 编辑 原始数据 按行查看 历史
Mr.Yu 提交于 2023-09-24 11:35 . 补充ioc理念和实现
package token
import "context"
const (
AppName = "token"
)
type Service interface {
// 登录接口(颁发Token)
Login(context.Context, *LoginRequest) (*Token, error)
// 退出接口(销毁Token)
Logout(context.Context, *LogoutRequest) error
// 校验Token 是给内部中间层使用 身份校验层
// 校验完后返回Token, 通过Token获取 用户信息
ValiateToken(context.Context, *ValiateToken) (*Token, error)
}
func NewLoginRequest() *LoginRequest {
return &LoginRequest{}
}
type LoginRequest struct {
Username string
Password string
}
// 万一的Token泄露, 不知道refresh_token,也没法推出
type LogoutRequest struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
func NewValiateToken(at string) *ValiateToken {
return &ValiateToken{
AccessToken: at,
}
}
type ValiateToken struct {
AccessToken string `json:"access_token"`
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/go-course/go12.git
git@gitee.com:go-course/go12.git
go-course
go12
go12
8a8b3aa3c2e4

搜索帮助

344bd9b3 5694891 D2dac590 5694891