Skip to content

Commit

Permalink
Merge pull request #6 from mgagliardo91/patch-auth-url
Browse files Browse the repository at this point in the history
fix(auth): Cache as authorize_url and respect relative server urls
  • Loading branch information
danielgtaylor committed Sep 2, 2020
2 parents f254e92 + d895bf9 commit 5a6424d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion oauth/authcode.go
Expand Up @@ -154,7 +154,7 @@ type AuthorizationCodeHandler struct{}
func (h *AuthorizationCodeHandler) Parameters() []cli.AuthParam {
return []cli.AuthParam{
{Name: "client_id", Required: true, Help: "OAuth 2.0 Client ID"},
{Name: "authorization_url", Required: true, Help: "OAuth 2.0 authorization URL, e.g. https://api.example.com/oauth/authorize"},
{Name: "authorize_url", Required: true, Help: "OAuth 2.0 authorization URL, e.g. https://api.example.com/oauth/authorize"},
{Name: "token_url", Required: true, Help: "OAuth 2.0 token URL, e.g. https://api.example.com/oauth/token"},
{Name: "scopes", Help: "Optional scopes to request in the token"},
}
Expand Down
4 changes: 3 additions & 1 deletion openapi/openapi.go
Expand Up @@ -345,7 +345,9 @@ func loadOpenAPI3(cfg Resolver, cmd *cobra.Command, location *url.URL, resp *htt
basePath := ""
prefix := location.Scheme + "://" + location.Host
for _, s := range swagger.Servers {
if strings.HasPrefix(s.URL, prefix) {
if strings.HasPrefix(s.URL, "/") {
basePath = s.URL
} else if strings.HasPrefix(s.URL, prefix) {
base, err := url.Parse(s.URL)
if err != nil {
return cli.API{}, err
Expand Down

0 comments on commit 5a6424d

Please sign in to comment.