Skip to content

Commit

Permalink
Add support for retrieving token from uri (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohitty authored and labkode committed Aug 8, 2019
1 parent e1ea57c commit a285c4f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ func (s *strategy) GetCredentials(w http.ResponseWriter, r *http.Request) (*auth
if token == "" {
// TODO make realm configurable or read it from forwarded for header
// see https://github.com/stanvit/go-forwarded as middleware
w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Bearer realm="%s"`, r.Host))
return nil, fmt.Errorf("no Bearer auth provided")
tokens, ok := r.URL.Query()["access_token"]

if !ok || len(tokens[0]) < 1 {
w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Bearer realm="%s"`, r.Host))
return nil, fmt.Errorf("no Bearer auth provided")
}
token = tokens[0]
}

return &auth.Credentials{ClientSecret: token}, nil
Expand Down

0 comments on commit a285c4f

Please sign in to comment.