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

OAuth2 policy incorrectly resolve consumer of API #608

Open
DrMegavolt opened this issue Jan 12, 2018 · 2 comments
Open

OAuth2 policy incorrectly resolve consumer of API #608

DrMegavolt opened this issue Jan 12, 2018 · 2 comments
Assignees
Labels

Comments

@DrMegavolt
Copy link
Contributor

From gitter chat. (ref Neil Stevens @StickNitro 15:46 JAN 12)

Scenario

So you have appA appB
during creation appA was created with userA.id and it gets appA.id
appB userB.id -> appB.id
now you are logging in with userB through appA
after oauth dance client device has a token
now request will go through Gateway pipelines and only token is passed in request
EG resolves token into egContext.consumer
id: appA.id
userId: userA.id
token.consumerId: appA.id
So the question is where is id of the actual user userB.id?
and there is no such place, which is wrong. It is not the app who is the consumer of the API, it is userB who is the consumer
At least this is what I have locally. do you have the same ?

@StickNitro
Yes, pretty much, except during creation I have appA is created with userA.id and it gets appA.id and appB is created with userA.id which gets appB.id but I think the second last line is accurate in that the consumer of the API is the user not the app


Notes:

Token Service stores consumerId relation to token
the problem is that it is called with app id instead of user.id

technically egContext.consumer should have both app.id and user.id

And OAuthtorize server actually has both of them. It is EG tokenService problem that it does not store userid

const tokenCriteria = {
        consumerId: consumer.id,
        authenticatedUserId: codeObj.userId,
        authType: 'oauth2'
      };
@DrMegavolt DrMegavolt added the bug label Jan 12, 2018
@DrMegavolt DrMegavolt self-assigned this Jan 12, 2018
@DrMegavolt
Copy link
Contributor Author

And what about scopes? investigate what scopes are assigned to token

@DrMegavolt
Copy link
Contributor Author

from source code scopes are taken from consumer, and in terms of oauthtorize is an app.
there is a test that checks that behavior
https://github.com/ExpressGateway/express-gateway/blob/master/test/policies/oauth/oauth-policy.test.js#L98

it should be changed to validate based on user

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

No branches or pull requests

1 participant