implement pool group and user get routes,

improvements to http return codes,
add localdb backend handler
This commit is contained in:
2026-04-29 21:15:20 +00:00
parent 136dc90f13
commit de7ac282db
10 changed files with 434 additions and 105 deletions
+14 -7
View File
@@ -1,18 +1,16 @@
package ldap
import (
"fmt"
"net/http"
"regexp"
"github.com/gin-gonic/gin"
"github.com/go-ldap/ldap/v3"
common "user-manager-api/app/common"
)
type LDAPConfig struct {
BaseDN string
LdapURL string
StartTLS bool
}
func LDAPEntryToUser(entry *ldap.Entry) common.User {
return common.User{
CN: entry.GetAttributeValue("cn"),
@@ -37,9 +35,18 @@ func ParseLDAPError(err error) gin.H {
} else {
return gin.H{
"ok": true,
"code": 200,
"code": http.StatusOK,
"result": "OK",
"message": "",
}
}
}
func ExtractUIDFromUserDN(dn string) (string, error) {
m := regexp.MustCompilePOSIX("uid=([[:alnum:]]+)")
x := m.FindStringSubmatch(dn)
if len(x) != 2 {
return "", fmt.Errorf("could not find uid in dn %s", dn)
}
return x[1], nil
}