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

[feature/oauth2] Allow OAuth2 access/refresh tokens to be supplied #659

Closed
wants to merge 1 commit into from

Conversation

eddmann
Copy link
Contributor

@eddmann eddmann commented Oct 27, 2015

Whilst testing the OAuth2 plugin we noticed that a 500 error status was returned every so often when generating a new access token.
Having a look at the code and also this issue #478, we found that it was most likely due to worker uuid seeds being the same - causing duplicate 'random' access tokens.
This feature request adds the ability to supply the desired access/refresh tokens upon issue.

@thibaultcha
Copy link
Member

Thank you @eddmann!

@thefosk wrote the OAuth2 plugin and should be the one reviewing this.

@eddmann
Copy link
Contributor Author

eddmann commented Oct 30, 2015

Great thanks :)

@subnetmarco subnetmarco self-assigned this Oct 30, 2015
@subnetmarco
Copy link
Member

On a side note, while I am reviewing this, it's also worthwhile investigating the "worker uuid seeds being the same" issue since that could happen somewhere else too. Including @Tieske in the conversation since we are using his https://github.com/Tieske/uuid library.

@thibaultcha thibaultcha changed the title Allow OAuth2 access/refresh tokens to be supplied [fix/oauth2] Allow OAuth2 access/refresh tokens to be supplied Nov 7, 2015
@subnetmarco
Copy link
Member

@eddmann correct me if I am wrong - with your code the client would be able to set arbitrary access_token and refresh_token values?

@eddmann
Copy link
Contributor Author

eddmann commented Nov 12, 2015

@thefosk That is correct, so as to allow control of access/refresh tokens generated/used to remain with an existing system i.e legacy app

@subnetmarco
Copy link
Member

@eddmann correct me if I am wrong, but if the client can set arbitrary access_token or refresh_token values, wouldn't that be a security issue (as opposed to the server being able to set them)?

On a side note starting from the next release, we fixed the uuid problem (#478).

@eddmann
Copy link
Contributor Author

eddmann commented Nov 17, 2015

@thefosk The intention of adding the ability to set arbitrary tokens is for the trusted 'Webapp Backend' to set them, not proxying values provided by the user, not sure if that is what you meant by client?
This addition allows current token generation methods to be maintained without enforcing a new external means - also providing a graceful migration path in the situation when moving over to Kong and its auto-generated tokens.

@subnetmarco
Copy link
Member

@eddmann I was mentioning the client because I got confused by this integration test: https://github.com/Mashape/kong/pull/659/files#diff-0458d9c5302a8f52664b5c7dcc2ad586R366

It seems like the client is setting the access_token without passing any provision_key.

@eddmann eddmann force-pushed the feature-supplied-oauth-tokens branch from f2d9a8c to f46926b Compare November 20, 2015 12:39
@eddmann eddmann changed the title [fix/oauth2] Allow OAuth2 access/refresh tokens to be supplied [feature/oauth2] Allow OAuth2 access/refresh tokens to be supplied Nov 20, 2015
Available on password, client credential and refresh token grant types
@eddmann eddmann force-pushed the feature-supplied-oauth-tokens branch from 73d9b42 to 9c87058 Compare November 20, 2015 14:10
@eddmann
Copy link
Contributor Author

eddmann commented Nov 20, 2015

@thefosk Very good point, just spent sometime updating the pull request.

Think it is probably easiest if I just layout more clearly what this feature is trying to achieve - as I don't think I have done the best of jobs, confusing matters by discussing the UUID bug within the initial description.

This pull adds the ability to optionally supply the access (and in some cases refresh) tokens upon issue, providing that a valid provision key has been supplied.
This addition allows current token generation methods to be maintained without enforcing a new external means.
This in-turn provides a graceful migration path in the situation when moving over to Kong and it's auto-generated tokens.
This pull implements this functionality into the client credentials, password and refresh token grant types.

@subnetmarco
Copy link
Member

In order to provide a custom access tokens (with optionally a custom refresh token) I see that your implementation uses the proxy port, and now properly checks the provision_key.

Do you think it makes sense to being able to create/update/delete access tokens using the admin API instead?

Let me explain better: like you already mentioned, I see this feature valuable when an API provider wants to migrate existing access tokens into Kong without any service disruption. But then, maybe we can add an additional endpoint on the admin API to do this and migrate all the access tokens?

We don't need this to happen on the proxy port, because if a client knows the provision_key, then it means that the client is the API provider. As such, we could directly expose this functionality in the admin API, in an endpoint like /oauth2_tokens/ which allows an API provider to execute CRUD operations on access tokens.

Thoughts?

@thibaultcha thibaultcha added pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. and removed pr/status/needs review labels Dec 17, 2015
@subnetmarco
Copy link
Member

The latter approach will be implemented in #729 - which deprecates this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants