do not send www-authenticate basic for Api requests

This commit is contained in:
Michael Barz
2023-04-03 11:34:42 +02:00
parent 16f8c49de9
commit df537ea98d
2 changed files with 9 additions and 1 deletions
@@ -147,7 +147,9 @@ func configureSupportedChallenges(options Options) {
func writeSupportedAuthenticateHeader(w http.ResponseWriter, r *http.Request) {
caser := cases.Title(language.Und)
for _, s := range SupportedAuthStrategies {
w.Header().Add(WwwAuthenticate, fmt.Sprintf("%v realm=\"%s\", charset=\"UTF-8\"", caser.String(s), r.Host))
if r.Header.Get("X-Requested-With") != "XMLHttpRequest" {
w.Header().Add(WwwAuthenticate, fmt.Sprintf("%v realm=\"%s\", charset=\"UTF-8\"", caser.String(s), r.Host))
}
}
}