fusenapi/utils/ldap_lib/auth.go

23 lines
548 B
Go
Raw Normal View History

2023-11-21 10:10:30 +00:00
package ldap_lib
import "github.com/zeromicro/go-zero/core/logx"
// 验证权限
func (l *Ldap) VerifyAuthority(token, jwtSecret string) bool {
info, err := l.ParseJwtToken(token, jwtSecret)
if err != nil {
logx.Error("解析token失败", err, "----token:", token)
return false
}
//查询ldap
userInfo, err := l.GetLdapUserInfo(info.UserDN)
if err != nil {
logx.Error("获取ldap用户信息失败", err, "----user_dn:", info.UserDN)
}
if userInfo.Status != 1 {
return false
}
// TODO 查询权限组相关信息
return true
}