diff --git a/admin.go b/admin.go index 18d1fb2..58785f1 100644 --- a/admin.go +++ b/admin.go @@ -6,6 +6,7 @@ import ( "regexp" "sort" "strings" + "log" "github.com/go-ldap/ldap/v3" "github.com/gorilla/mux" @@ -194,6 +195,7 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) { modify_request.Add("member", []string{member}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("198: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -201,6 +203,9 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) { } } else if action == "add-external" { mail := strings.Join(r.Form["mail"], "") + sn := strings.Join(r.Form["sn"], "") + givenname := strings.Join(r.Form["givenname"], "") + member := strings.Join(r.Form["member"], "") displayname := strings.Join(r.Form["displayname"], "") searchRequest := ldap.NewSearchRequest( @@ -217,11 +222,22 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) { if config.MailingGuestsBaseDN != "" { guestDn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, mail, config.MailingGuestsBaseDN) req := ldap.NewAddRequest(guestDn, nil) - req.Attribute("objectclass", []string{"inetOrgPerson", "organizationalPerson", "person", "top"}) - req.Attribute("mail", []string{mail}) + //req.Attribute("objectclass", []string{"inetOrgPerson", "organizationalPerson", "person", "top"}) + req.Attribute("objectclass", []string{"inetOrgPerson"}) + req.Attribute("mail", []string{fmt.Sprintf("%s",mail)}) + if givenname != "" { + req.Attribute("givenname", []string{givenname}) + } + if member != "" { + req.Attribute("member", []string{member}) + } if displayname != "" { req.Attribute("displayname", []string{displayname}) } + if sn != "" { + req.Attribute("sn", []string{sn}) + } + log.Printf(fmt.Sprintf("226: %v",req)) err := login.conn.Add(req) if err != nil { dError = err.Error() @@ -230,6 +246,7 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) { modify_request.Add("member", []string{guestDn}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("249: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -244,6 +261,7 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) { modify_request.Add("member", []string{sr.Entries[0].DN}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("264: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -259,6 +277,7 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) { modify_request.Delete("member", []string{member}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("280: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -446,6 +465,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { modify_request.Replace(attr, values_filtered) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("468: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -467,6 +487,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { modify_request.Add(attr, values_filtered) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("490: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -479,6 +500,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { modify_request.Replace(attr, []string{}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("503: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -490,6 +512,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { modify_request.Delete("member", []string{dn}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("515: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -501,6 +524,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { modify_request.Add("member", []string{dn}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("527: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -512,6 +536,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { modify_request.Delete("member", []string{member}) err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("539: %v",modify_request)) if err != nil { dError = err.Error() } else { @@ -777,9 +802,13 @@ type CreateData struct { IdType string IdValue string DisplayName string + GivenName string + Member string + Mail string Description string StructuralObjectClass string ObjectClass string + SN string Error string } @@ -845,6 +874,7 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) { data.IdType = config.UserNameAttr data.StructuralObjectClass = "groupOfNames" data.ObjectClass = "groupOfNames\ntop" + data.Member = "cn=sogo@resdigita.org,ou=users,dc=resdigita,dc=org" } else if template == "ou" { data.IdType = "ou" data.StructuralObjectClass = "organizationalUnit" @@ -864,7 +894,11 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) { } data.IdValue = strings.TrimSpace(strings.Join(r.Form["idvalue"], "")) data.DisplayName = strings.TrimSpace(strings.Join(r.Form["displayname"], "")) + data.GivenName = strings.TrimSpace(strings.Join(r.Form["givenname"], "")) + data.Mail = strings.TrimSpace(strings.Join(r.Form["mail"], "")) + data.Member = strings.TrimSpace(strings.Join(r.Form["member"], "")) data.Description = strings.TrimSpace(strings.Join(r.Form["description"], "")) + data.SN = strings.TrimSpace(strings.Join(r.Form["sn"], "")) object_class := []string{} for _, oc := range strings.Split(data.ObjectClass, "\n") { @@ -884,17 +918,34 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) { dn := data.IdType + "=" + data.IdValue + "," + super_dn req := ldap.NewAddRequest(dn, nil) req.Attribute("objectclass", object_class) + // req.Attribute("mail", []string{data.IdValue}) + /* if data.StructuralObjectClass != "" { req.Attribute("structuralobjectclass", []string{data.StructuralObjectClass}) } + */ if data.DisplayName != "" { req.Attribute("displayname", []string{data.DisplayName}) } + if data.GivenName != "" { + req.Attribute("givenname", []string{data.GivenName}) + } + if data.Mail != "" { + req.Attribute("mail", []string{data.Mail}) + } + if data.Member != "" { + req.Attribute("member", []string{data.Member}) + } + if data.SN != "" { + req.Attribute("sn", []string{data.SN}) + } if data.Description != "" { req.Attribute("description", []string{data.Description}) } - err := login.conn.Add(req) + log.Printf(fmt.Sprintf("899: %v",err)) + log.Printf(fmt.Sprintf("899: %v",req)) + log.Printf(fmt.Sprintf("899: %v",data)) if err != nil { data.Error = err.Error() } else { diff --git a/main.go b/main.go index ae8fe06..9b56b2d 100644 --- a/main.go +++ b/main.go @@ -258,13 +258,14 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus { "givenname", "sn", "mail", + "cn", "memberof", "description", "garage_s3_access_key", - FIELD_NAME_DIRECTORY_VISIBILITY, - FIELD_NAME_PROFILE_PICTURE, }, nil) +// FIELD_NAME_DIRECTORY_VISIBILITY, +// FIELD_NAME_PROFILE_PICTURE, sr, err := l.Search(searchRequest) if err != nil { diff --git a/profile.go b/profile.go index a082ad8..a33d03a 100644 --- a/profile.go +++ b/profile.go @@ -3,6 +3,8 @@ package main import ( "net/http" "strings" + "log" + "fmt" "github.com/go-ldap/ldap/v3" ) @@ -15,10 +17,10 @@ type ProfileTplData struct { DisplayName string GivenName string Surname string - Visibility string Description string - ProfilePicture string } +//ProfilePicture string +//Visibility string func handleProfile(w http.ResponseWriter, r *http.Request) { templateProfile := getTemplate("profile.html") @@ -35,47 +37,53 @@ func handleProfile(w http.ResponseWriter, r *http.Request) { } data.Mail = login.UserEntry.GetAttributeValue("mail") - data.DisplayName = login.UserEntry.GetAttributeValue("displayname") - data.GivenName = login.UserEntry.GetAttributeValue("givenname") + data.DisplayName = login.UserEntry.GetAttributeValue("displayName") + data.GivenName = login.UserEntry.GetAttributeValue("givenName") data.Surname = login.UserEntry.GetAttributeValue("sn") - data.Visibility = login.UserEntry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY) + // data.Visibility = login.UserEntry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY) data.Description = login.UserEntry.GetAttributeValue("description") - data.ProfilePicture = login.UserEntry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE) + //data.ProfilePicture = login.UserEntry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE) if r.Method == "POST" { //5MB maximum size files r.ParseMultipartForm(5 << 20) - data.DisplayName = strings.TrimSpace(strings.Join(r.Form["display_name"], "")) data.GivenName = strings.TrimSpace(strings.Join(r.Form["given_name"], "")) data.Surname = strings.TrimSpace(strings.Join(r.Form["surname"], "")) data.Description = strings.Trim(strings.Join(r.Form["description"], ""), "") + /* visible := strings.TrimSpace(strings.Join(r.Form["visibility"], "")) if visible != "" { visible = "on" - } + } else { + visible = "off" + } data.Visibility = visible - + */ + /* profilePicture, err := uploadProfilePicture(w, r, login) if err != nil { data.ErrorMessage = err.Error() } - - if profilePicture != "" { + if profilePicture != "" { data.ProfilePicture = profilePicture } - + */ modify_request := ldap.NewModifyRequest(login.Info.DN, nil) modify_request.Replace("displayname", []string{data.DisplayName}) modify_request.Replace("givenname", []string{data.GivenName}) - modify_request.Replace("sn", []string{data.Surname}) + modify_request.Replace("surname", []string{data.Surname}) modify_request.Replace("description", []string{data.Description}) - modify_request.Replace(FIELD_NAME_DIRECTORY_VISIBILITY, []string{data.Visibility}) - if data.ProfilePicture != "" { - modify_request.Replace(FIELD_NAME_PROFILE_PICTURE, []string{data.ProfilePicture}) - } + //modify_request.Replace(FIELD_NAME_DIRECTORY_VISIBILITY, []string{data.Visibility}) + //modify_request.Replace(FIELD_NAME_DIRECTORY_VISIBILITY, []string{"on"}) + //if data.ProfilePicture != "" { + // modify_request.Replace(FIELD_NAME_PROFILE_PICTURE, []string{data.ProfilePicture}) + // } - err = login.conn.Modify(modify_request) + err := login.conn.Modify(modify_request) + log.Printf(fmt.Sprintf("Profile:079: %v",modify_request)) + log.Printf(fmt.Sprintf("Profile:079: %v",err)) + log.Printf(fmt.Sprintf("Profile:079: %v",data)) if err != nil { data.ErrorMessage = err.Error() } else { @@ -120,19 +128,13 @@ func handlePasswd(w http.ResponseWriter, r *http.Request) { } else if password2 != password { data.NoMatchError = true } else { - modify_request := ldap.NewModifyRequest(login.Info.DN, nil) - pw, err := SSHAEncode(password) - if err == nil { - modify_request.Replace("userpassword", []string{pw}) - err := login.conn.Modify(modify_request) - if err != nil { - data.ErrorMessage = err.Error() - } else { - data.Success = true - } - } else { - data.ErrorMessage = err.Error() - } + passwordModifyRequest := ldap.NewPasswordModifyRequest(login.Info.DN,"",password) + _, err := login.conn.PasswordModify(passwordModifyRequest) + if err != nil { + data.ErrorMessage = err.Error() + } else { + data.Success = true + } } } diff --git a/static/image/lesgrandsvoisinscomcom-transparent.max-1000x100.svg b/static/image/lesgrandsvoisinscomcom-transparent.max-1000x100.svg new file mode 100644 index 0000000..8e34974 --- /dev/null +++ b/static/image/lesgrandsvoisinscomcom-transparent.max-1000x100.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/admin_create.html b/templates/admin_create.html index 1ea6fee..ab28226 100644 --- a/templates/admin_create.html +++ b/templates/admin_create.html @@ -47,21 +47,42 @@ {{ if eq .Template "user" }}
- +
- +
+ + +
+ +
+ + +
+ +
+ + +
+ {{ else }}
- + +
+ + +
+ {{ end }} +
diff --git a/templates/home.html b/templates/home.html index 241a59d..fbc80a5 100644 --- a/templates/home.html +++ b/templates/home.html @@ -20,7 +20,7 @@
- + {{if .Login.CanInvite}}
diff --git a/templates/layout.html b/templates/layout.html index 3f9851d..498359c 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -10,7 +10,7 @@
-

Guichet Deuxfleurs💮💮

+

Guichet Les Grands Voisins


{{template "body" .}}
diff --git a/templates/login.html b/templates/login.html index 84742e1..4d2c03d 100644 --- a/templates/login.html +++ b/templates/login.html @@ -29,7 +29,7 @@

Mot de passe oublié ? -Écrivez à coucouarobasedeuxfleurs.fr +Écrivez à chrisarobaselesgandsvoisins.com ou contactez directement votre opérateur·ice préféré·e.

{{end}} diff --git a/templates/profile.html b/templates/profile.html index 56461eb..59d665b 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -32,6 +32,8 @@
+{{/* + + + +*/}}