mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-13 00:52:01 -04:00
groupware: add workaround when using the master/impersonation account: in that case, don't use impersonation but the impersonation account directly
This commit is contained in:
@@ -104,14 +104,22 @@ func NewMasterAuthHttpJmapClientAuthenticator(masterUser string, masterPassword
|
|||||||
var _ HttpJmapClientAuthenticator = &MasterAuthHttpJmapClientAuthenticator{}
|
var _ HttpJmapClientAuthenticator = &MasterAuthHttpJmapClientAuthenticator{}
|
||||||
|
|
||||||
func (h *MasterAuthHttpJmapClientAuthenticator) Authenticate(ctx context.Context, username string, _ *log.Logger, req *http.Request) Error {
|
func (h *MasterAuthHttpJmapClientAuthenticator) Authenticate(ctx context.Context, username string, _ *log.Logger, req *http.Request) Error {
|
||||||
masterUsername := username + "%" + h.masterUser
|
if username == h.masterUser {
|
||||||
req.SetBasicAuth(masterUsername, h.masterPassword)
|
req.SetBasicAuth(username, h.masterPassword)
|
||||||
|
} else {
|
||||||
|
masterUsername := username + "%" + h.masterUser
|
||||||
|
req.SetBasicAuth(masterUsername, h.masterPassword)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MasterAuthHttpJmapClientAuthenticator) AuthenticateWS(ctx context.Context, username string, _ *log.Logger, headers http.Header) Error {
|
func (h *MasterAuthHttpJmapClientAuthenticator) AuthenticateWS(ctx context.Context, username string, _ *log.Logger, headers http.Header) Error {
|
||||||
masterUsername := username + "%" + h.masterUser
|
if username == h.masterUser {
|
||||||
headers.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(masterUsername+":"+h.masterPassword)))
|
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)))
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user