新增:ldap用户OTP认证(同步ldap用户到本地【仅作为管理otp秘钥,支持ldap用户下发客户端证书】)

新增:支持用户批量发送邮件,批量删除
This commit is contained in:
wsczx
2025-08-29 15:11:38 +08:00
parent 861b07a47d
commit efdcd236f5
9 changed files with 649 additions and 13928 deletions

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"github.com/bjdgyc/anylink/base"
"github.com/bjdgyc/anylink/dbdata"
)
@@ -149,3 +150,35 @@ func GroupAuthLogin(w http.ResponseWriter, r *http.Request) {
}
RespSucess(w, "ok")
}
func SaveLdapUsers(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
RespError(w, RespInternalErr, err)
return
}
defer r.Body.Close()
v := &dbdata.Group{}
err = json.Unmarshal(body, v)
if err != nil {
RespError(w, RespParamErr, "参数错误")
return
}
// 保存LDAP用户
if v.Auth["type"] == "ldap" {
authLdap := dbdata.AuthLdap{}
if err := authLdap.ParseGroup(v); err != nil {
RespError(w, RespInternalErr, err)
return
}
go func() {
if err := authLdap.SaveUsers(v); err != nil {
base.Error("LDAP用户同步失败:", err)
} else {
base.Info("LDAP用户同步成功")
}
}()
}
RespSucess(w, "LDAP用户同步成功")
}