Skip to content

Commit

Permalink
oauth: fix osin.CheckBasicAuth return value inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas committed Dec 20, 2015
1 parent f2ee621 commit 57d5427
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions oauth/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func (h *Handler) SetRoutes(r *mux.Router, extractor func(h hctx.ContextHandler)

func (h *Handler) RevokeHandler(w http.ResponseWriter, r *http.Request) {
auth, err := osin.CheckBasicAuth(r)
if err != nil {
pkg.HttpError(w, errors.New("Unauthorized"), http.StatusServiceUnavailable)
return
} else if auth == nil {
pkg.HttpError(w, errors.New("Unauthorized"), http.StatusUnauthorized)
return
}

client, err := h.OAuthStore.GetClient(auth.Username)
if err != nil {
pkg.HttpError(w, errors.New("Unauthorized"), http.StatusServiceUnavailable)
Expand Down Expand Up @@ -148,6 +156,9 @@ func (h *Handler) IntrospectHandler(w http.ResponseWriter, r *http.Request) {
if _, err := h.OAuthStore.GetClient(auth.Username); err != nil {
pkg.HttpError(w, errors.New("Unauthorized"), http.StatusUnauthorized)
return
} else if auth == nil {
pkg.HttpError(w, errors.New("Unauthorized"), http.StatusUnauthorized)
return
}

result := make(map[string]interface{})
Expand Down

0 comments on commit 57d5427

Please sign in to comment.