mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: External AM fix parsing basic auth with escape characters (#84681)
This commit is contained in:
@@ -275,17 +275,16 @@ func (d *AlertsRouter) buildExternalURL(ds *datasources.DataSource) (string, err
|
||||
}
|
||||
}
|
||||
|
||||
// if basic auth is enabled we need to build the url with basic auth baked in
|
||||
if !ds.BasicAuth {
|
||||
return parsed.String(), nil
|
||||
// If basic auth is enabled we need to build the url with basic auth baked in.
|
||||
if ds.BasicAuth {
|
||||
password := d.secretService.GetDecryptedValue(context.Background(), ds.SecureJsonData, "basicAuthPassword", "")
|
||||
if password == "" {
|
||||
return "", fmt.Errorf("basic auth enabled but no password set")
|
||||
}
|
||||
parsed.User = url.UserPassword(ds.BasicAuthUser, password)
|
||||
}
|
||||
|
||||
password := d.secretService.GetDecryptedValue(context.Background(), ds.SecureJsonData, "basicAuthPassword", "")
|
||||
if password == "" {
|
||||
return "", fmt.Errorf("basic auth enabled but no password set")
|
||||
}
|
||||
return fmt.Sprintf("%s://%s:%s@%s%s%s", parsed.Scheme, ds.BasicAuthUser,
|
||||
password, parsed.Host, parsed.Path, parsed.RawQuery), nil
|
||||
return parsed.String(), nil
|
||||
}
|
||||
|
||||
func (d *AlertsRouter) Send(ctx context.Context, key models.AlertRuleKey, alerts definitions.PostableAlerts) {
|
||||
|
||||
Reference in New Issue
Block a user