mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 09:07:33 +00:00
Merge remote-tracking branch 'origin/main' into next-rc
This commit is contained in:
@@ -3,11 +3,13 @@ package ldap
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/zitadel/logging"
|
||||
@@ -262,12 +264,12 @@ func mapLDAPEntryToUser(
|
||||
}
|
||||
|
||||
return NewUser(
|
||||
user.GetAttributeValue(idAttribute),
|
||||
user.GetAttributeValue(firstNameAttribute),
|
||||
user.GetAttributeValue(lastNameAttribute),
|
||||
user.GetAttributeValue(displayNameAttribute),
|
||||
user.GetAttributeValue(nickNameAttribute),
|
||||
user.GetAttributeValue(preferredUsernameAttribute),
|
||||
getAttributeValue(user, idAttribute),
|
||||
getAttributeValue(user, firstNameAttribute),
|
||||
getAttributeValue(user, lastNameAttribute),
|
||||
getAttributeValue(user, displayNameAttribute),
|
||||
getAttributeValue(user, nickNameAttribute),
|
||||
getAttributeValue(user, preferredUsernameAttribute),
|
||||
domain.EmailAddress(user.GetAttributeValue(emailAttribute)),
|
||||
emailVerified,
|
||||
domain.PhoneNumber(user.GetAttributeValue(phoneAttribute)),
|
||||
@@ -277,3 +279,15 @@ func mapLDAPEntryToUser(
|
||||
user.GetAttributeValue(profileAttribute),
|
||||
), nil
|
||||
}
|
||||
|
||||
func getAttributeValue(user *ldap.Entry, attribute string) string {
|
||||
// return an empty string if no attribute is needed
|
||||
if attribute == "" {
|
||||
return ""
|
||||
}
|
||||
value := user.GetAttributeValue(attribute)
|
||||
if utf8.ValidString(value) {
|
||||
return value
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(user.GetRawAttributeValue(attribute))
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ func (msg *Email) GetContent() (string, error) {
|
||||
headers := make(map[string]string)
|
||||
from := msg.SenderEmail
|
||||
if msg.SenderName != "" {
|
||||
from = fmt.Sprintf("%s <%s>", msg.SenderName, msg.SenderEmail)
|
||||
from = fmt.Sprintf("%s <%s>", bEncodeWord(msg.SenderName), msg.SenderEmail)
|
||||
}
|
||||
headers["From"] = from
|
||||
if msg.ReplyToAddress != "" {
|
||||
@@ -55,7 +55,7 @@ func (msg *Email) GetContent() (string, error) {
|
||||
if !isHTML(msg.Content) {
|
||||
mime = "MIME-Version: 1.0" + lineBreak + "Content-Type: text/plain; charset=\"UTF-8\"" + lineBreak + lineBreak
|
||||
}
|
||||
subject := "Subject: " + bEncodeSubject(msg.Subject) + lineBreak
|
||||
subject := "Subject: " + bEncodeWord(msg.Subject) + lineBreak
|
||||
message += subject + mime + lineBreak + msg.Content
|
||||
|
||||
return message, nil
|
||||
@@ -70,6 +70,6 @@ func isHTML(input string) bool {
|
||||
}
|
||||
|
||||
// returns a RFC1342 "B" encoded string to allow non-ascii characters
|
||||
func bEncodeSubject(subject string) string {
|
||||
return mime.BEncoding.Encode("UTF-8", subject)
|
||||
func bEncodeWord(word string) string {
|
||||
return mime.BEncoding.Encode("UTF-8", word)
|
||||
}
|
||||
|
Reference in New Issue
Block a user