package ldap_lib import ( "github.com/zeromicro/go-zero/core/logx" "net/http" ) type LdapVerifyType string const ( API_PATH LdapVerifyType = "api_path" MENU_PATH LdapVerifyType = "menu_path" ) type LdapOptions struct { Type LdapVerifyType Value string } // 验证权限 func (l *Ldap) VerifyAuthority(r *http.Request, options ...LdapOptions) bool { return true 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 } return true }