some error handling

This commit is contained in:
Livio Amstutz 2019-11-28 08:56:53 +01:00
parent 8ee38d2ec8
commit 10d671956a
3 changed files with 32 additions and 21 deletions

View file

@ -4,6 +4,7 @@ import (
"net/http"
"github.com/caos/oidc/pkg/oidc"
"github.com/caos/oidc/pkg/utils"
)
const (
@ -47,8 +48,13 @@ func AuthRequestError(w http.ResponseWriter, r *http.Request, authReq *oidc.Auth
http.Redirect(w, r, url, http.StatusFound)
}
func ExchangeRequestError(w http.ResponseWriter, r *http.Request, exchangeReq *oidc.AuthRequest, err error) {
func ExchangeRequestError(w http.ResponseWriter, r *http.Request, err error) {
e, ok := err.(*OAuthError)
if !ok {
e.ErrorType = ServerError
e.Description = err.Error()
}
utils.MarshalJSON(w, e)
}
type OAuthError struct {