feat: 新增客户端授权管理和开放接口
This commit is contained in:
@@ -54,7 +54,7 @@ func (s Oauth2Service) ValidateCode(code string) error {
|
||||
}
|
||||
|
||||
// ByClient 客户端信息
|
||||
func (s Oauth2Service) ByClient(clientId, clientSecret string) (token.Oauth2Info, error) {
|
||||
func (s Oauth2Service) ByClient(clientId, clientSecret, ipaddr string) (token.Oauth2Info, error) {
|
||||
info := token.Oauth2Info{}
|
||||
|
||||
// 查询用户登录账号
|
||||
@@ -66,9 +66,13 @@ func (s Oauth2Service) ByClient(clientId, clientSecret string) (token.Oauth2Info
|
||||
if len(rows) > 0 {
|
||||
item = rows[0]
|
||||
}
|
||||
if item.ClientId == "" {
|
||||
if item.ClientId == "" || item.ClientSecret == "" {
|
||||
return info, fmt.Errorf("clientId or clientSecret is not exist")
|
||||
}
|
||||
// 判断IP白名单
|
||||
if !strings.Contains(item.IPWhite, ipaddr) {
|
||||
return info, fmt.Errorf("ip whitelist mismatch")
|
||||
}
|
||||
|
||||
info.ClientId = clientId
|
||||
// 用户权限组标识
|
||||
|
||||
Reference in New Issue
Block a user