providers/proxy: better log outpost token errors

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-02-06 20:26:43 +01:00
parent 1919a9dd77
commit 61b06eff06
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package application
import (
"context"
"encoding/json"
"io"
"net/http"
"net/url"
"strings"
@ -29,7 +30,11 @@ func (a *Application) attemptBasicAuth(username, password string) *Claims {
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
res, err := a.httpClient.Do(req)
if err != nil || res.StatusCode > 200 {
a.log.WithError(err).Warning("failed to send token request")
b, err := io.ReadAll(res.Body)
if err != nil {
b = []byte(err.Error())
}
a.log.WithError(err).WithField("body", string(b)).Warning("failed to send token request")
return nil
}
var token TokenResponse