package ldap_lib import ( "github.com/zeromicro/go-zero/core/logx" "net/http" ) type LdapOptions struct { } // 验证权限 func (l *Ldap) VerifyAuthority(r *http.Request, options ...string) bool { token := r.Header.Get("Ldap-Authorization") info, err := l.ParseJwtToken(token, l.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 } if len(options) == 0 { return true } // todo 获取分组信息 /*for _, option := range options { }*/ return true }