groupware: slightly improve the implementation of e77250b7c4

This commit is contained in:
Pascal Bleser
2026-07-02 11:05:40 +02:00
parent 4852e9e3e1
commit 5286e09032

View File

@@ -104,22 +104,20 @@ func NewMasterAuthHttpJmapClientAuthenticator(masterUser string, masterPassword
var _ HttpJmapClientAuthenticator = &MasterAuthHttpJmapClientAuthenticator{}
func (h *MasterAuthHttpJmapClientAuthenticator) Authenticate(ctx context.Context, username string, _ *log.Logger, req *http.Request) Error {
if username == h.masterUser {
req.SetBasicAuth(username, h.masterPassword)
} else {
masterUsername := username + "%" + h.masterUser
req.SetBasicAuth(masterUsername, h.masterPassword)
u := username
if username != h.masterUser {
u = username + "%" + h.masterUser
}
req.SetBasicAuth(u, h.masterPassword)
return nil
}
func (h *MasterAuthHttpJmapClientAuthenticator) AuthenticateWS(ctx context.Context, username string, _ *log.Logger, headers http.Header) Error {
if username == h.masterUser {
headers.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(username+":"+h.masterPassword)))
} else {
masterUsername := username + "%" + h.masterUser
headers.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(masterUsername+":"+h.masterPassword)))
u := username
if username != h.masterUser {
u = username + "%" + h.masterUser
}
headers.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(u+":"+h.masterPassword)))
return nil
}