Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization Code flow wrong cache key #4

Closed
mgagliardo91 opened this issue Aug 18, 2020 · 3 comments · Fixed by #6
Closed

Authorization Code flow wrong cache key #4

mgagliardo91 opened this issue Aug 18, 2020 · 3 comments · Fixed by #6

Comments

@mgagliardo91
Copy link
Contributor

The authorization code workflow caches the authorization url as authorization_url; however, its usage in the remainder of the flow is for the name AuthorizeUrl (authorize_url). This results in an invalid authorization code URL being presented to the console.

Cached usage: https://github.com/danielgtaylor/restish/blob/master/oauth/authcode.go#L157

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: "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"},
	}
}

Proposed Change:

func (h *AuthorizationCodeHandler) Parameters() []cli.AuthParam {
	return []cli.AuthParam{
		{Name: "client_id", Required: true, Help: "OAuth 2.0 Client ID"},
		{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"},
	}
}
@mgagliardo91
Copy link
Contributor Author

Also, to add into this: I would like to understand why most of this information could not be retrieved from the openapi spec itself. The OpenApi 3.0 calls out securitySchemes that includes flows like authorizationCode which allows you to specify the values that restish attempts to collect via the user input. Any thoughts on adding a more declarative approach with collecting this info from the spec instead?

@danielgtaylor
Copy link
Owner

Nice find, I completely missed this! 👍

@danielgtaylor
Copy link
Owner

Sorry for the slow response on this. I've been busy 😞

Merged in 5a6424d and released in 0.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants