Ai
7 Star 17 Fork 27

go-course/go9

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
interface.go 653 Bytes
一键复制 编辑 原始数据 按行查看 历史
Mr.Yu 提交于 2023-02-19 18:42 +08:00 . 添加认证接口
package token
import (
context "context"
"fmt"
)
const (
AppName = "tokens"
)
type Service interface {
// 令牌颁发: Restful
IssueToken(context.Context, *IssueTokenRequest) (*Token, error)
RPCServer
}
func NewValidateTokenRequest(ak string) *ValidateTokenRequest {
return &ValidateTokenRequest{
AccessToken: ak,
}
}
func NewIssueTokenRequest() *IssueTokenRequest {
return &IssueTokenRequest{}
}
func (req *IssueTokenRequest) Validate() error {
switch req.GrantType {
case GRANT_TYPE_PASSWORD, GRANT_TYPE_LDAP:
if req.Username == "" || req.Password == "" {
return fmt.Errorf("用户名或者密码缺失")
}
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/go-course/go9.git
git@gitee.com:go-course/go9.git
go-course
go9
go9
2c311f48cd84

搜索帮助