Skip to content

Commit 5bea87e

Browse files
authored
Merge pull request #1142 from cappyzawa/fix/double-secret-fetch
Fix double secret fetching in BasicAuth processing
2 parents 6e18c48 + a8c2fc0 commit 5bea87e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/server/event_handlers.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,13 @@ func extractAuthFromSecret(ctx context.Context, kubeClient client.Client, provid
344344
options = append(options, notifier.WithHeaders(headers))
345345
}
346346

347+
if user, ok := secret.Data["username"]; ok {
348+
if pass, ok := secret.Data["password"]; ok {
349+
options = append(options, notifier.WithUsername(strings.TrimSpace(string(user))))
350+
options = append(options, notifier.WithPassword(strings.TrimSpace(string(pass))))
351+
}
352+
}
353+
347354
return options, secret.Data, nil
348355
}
349356

@@ -404,12 +411,6 @@ func createNotifier(ctx context.Context, kubeClient client.Client, provider *api
404411
if val, ok := secretData[secrets.TokenKey]; ok {
405412
token = strings.TrimSpace(string(val))
406413
}
407-
408-
user, pass, err := secrets.BasicAuthFromSecret(ctx, kubeClient, provider.Spec.SecretRef.Name, provider.Namespace)
409-
if err == nil {
410-
options = append(options, notifier.WithUsername(user))
411-
options = append(options, notifier.WithPassword(pass))
412-
}
413414
}
414415

415416
if provider.Spec.ProxySecretRef != nil {

0 commit comments

Comments
 (0)