v0.5.7 : Ajout flag -version, correction filtre cn=

This commit is contained in:
yo 2023-09-29 11:35:58 +02:00
parent b0d006b39b
commit dfc26b821c

16
main.go
View File

@ -22,7 +22,7 @@ import (
)
var (
gVersion = "0.5.6"
gVersion = "0.5.8"
gRoLdap *MyLdap
)
@ -263,6 +263,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, nil)
return
}
defer ldapCon.Conn.Close()
// json format is the default
format := c.DefaultQuery("format", "json")
@ -298,6 +299,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, nil)
return
}
defer ldapCon.Conn.Close()
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, "ALL")
if err != nil {
@ -334,6 +336,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, nil)
return
}
defer ldapCon.Conn.Close()
res, err := searchByCn(ldapCon, ou, cn, class, attr)
if err != nil {
@ -365,6 +368,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, nil)
return
}
defer ldapCon.Conn.Close()
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, attr)
if err != nil {
@ -405,6 +409,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
defer ldapCon.Conn.Close()
// Unmarshall json body to a map
if c.Request.Header.Get("Content-Type") == "application/json" {
@ -468,6 +473,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
defer ldapCon.Conn.Close()
// Unmarshall json body to a map
if c.Request.Header.Get("Content-Type") == "application/json" {
@ -521,6 +527,7 @@ func initRouter(r *gin.Engine) {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
defer ldapCon.Conn.Close()
// Unmarshall json body to a map
if c.Request.Header.Get("Content-Type") == "application/json" {
@ -570,6 +577,7 @@ func main() {
var tlsCert string
var doTls bool
var debug bool
var showversion bool
flag.StringVar(&confFile, "config", "", "Path to the config file (optional)")
flag.StringVar(&listen, "listen-addr", "0.0.0.0:8080", "listen address for server")
@ -582,9 +590,15 @@ func main() {
flag.StringVar(&tlsPrivKey, "ssl-private-key", "", "SSL Private key")
flag.StringVar(&tlsCert, "ssl-certificate", "", "SSL certificate (PEM format)")
flag.BoolVar(&debug, "debug", false, "Set log level to debug")
flag.BoolVar(&showversion, "version", false, "Show version then exit")
flag.Parse()
if showversion {
fmt.Printf("GlApi v%s\n", gVersion)
return
}
if len(confFile) > 0 {
viper.SetConfigFile(confFile)
if err := viper.ReadInConfig(); err != nil {