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

Support JWT scopes to allow or reject requests in OAuth2 plugin #1272

Closed
sshniro opened this issue Mar 15, 2020 · 11 comments
Closed

Support JWT scopes to allow or reject requests in OAuth2 plugin #1272

sshniro opened this issue Mar 15, 2020 · 11 comments

Comments

@sshniro
Copy link
Member

sshniro commented Mar 15, 2020

Issue description

The JWT contains the scopes available for a user via the scope attribute. Scope represents the capabilities the token has such as read or delete. It would be good if we can define a required set of scopes and allow or reject the request based on the required scope.

@membphis
Copy link
Member

can you provide an example?

@sshniro
Copy link
Member Author

sshniro commented Mar 17, 2020

The following is the scenario I have in mind.

The getProducts endpoint should be accessible via a token which has the read scope.

curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
  "uri": "/getProducts",
  "plugins": {
    "proxy-rewrite": {
      "scheme": "https"
    },
    "openid-connect": {
      "client_id": "api_six_client_id",
      "client_secret": "client_secret_code",
      "discovery": "full_URL_of_the_discovery_endpoint",
      "required_scope": "read_scope",
}
  }
}'

And the deleteProducts endpoint should be accessible via the token with a deletescope.

curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
  "uri": "/deleteProducts",
  "plugins": {
    "proxy-rewrite": {
      "scheme": "https"
    },
    "openid-connect": {
      "client_id": "api_six_client_id",
      "client_secret": "client_secret_code",
      "discovery": "full_URL_of_the_discovery_endpoint",
      "required_scope": "delete_scope",
}
  }
}'

This is how the core OpenID Library is suggesting to handle this scenario.

image
https://github.com/zmartzone/lua-resty-openidc#sample-configuration-for-oauth-20-jwt-token-validation

@membphis
Copy link
Member

@moonming you can take a look

@sshniro
Copy link
Member Author

sshniro commented Mar 31, 2020

@moonming any thoughts on this enhancement?

@moonming
Copy link
Member

required_scope should be scope?
others look good to me.

@spacewander
Copy link
Member

Is it still in need?

@tamasorban
Copy link

@spacewander, I believe there's still a need for this ticket. The openid-connect plugin introduced a scope property for a different purpose. The scope property described in the ticket would allow us to accept/reject the request.

@csotiriou
Copy link
Contributor

@spacewander, I believe there's still a need for this ticket. The openid-connect plugin introduced a scope property for a different purpose. The scope property described in the ticket would allow us to accept/reject the request.

I second that. I believe that this is indeed a very useful addition, and should definitely be reconsidered.

@csotiriou
Copy link
Contributor

I believe that this need is partially or completely fulfilled by this fix: #10493

@kayx23
Copy link
Member

kayx23 commented Dec 21, 2023

I believe that this need is partially or completely fulfilled by this fix: #10493

cc: @monkeyDluffy6017

@moonming moonming moved this to 🏗 In progress in Apache APISIX backlog Dec 22, 2023
@monkeyDluffy6017
Copy link
Contributor

considered resolved

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Apache APISIX backlog Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

8 participants