-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(openid-connect): Add extra validation if audience claim exists in the Bearer token #11059
Conversation
@dtsek could you please add test cases as well? |
Hello @shreemaan-abhishek , could you give me some extra information regarding testing since I didn't see something relevant apart from the other tests? In order to test this feature, I will need an IdP that can provide Bearer tokens for different clients so I can prove that the one with the valid Is there something available that I can use from your side? Otherwise I could take a look at something like https://www.oauth.com/playground/oidc.html but it will take some time. An alternative would be to provide manually two JWTs, one with a correct |
You can use the config that didn't work before your bugfix to show that it works now in the tests. You can take motivation from the existing test cases in
You can use existing services defined as docker compose applications here, define new services (not recommended because #11068) or use a mock server. |
I forgot to share this link that shows how test cases can be written: https://apisix.apache.org/docs/apisix/internal/testing-framework/ |
Hello @shreemaan-abhishek , unfortunately I cannot provide for the time being a test case because in https://github.com/apache/apisix/blob/c0e3d9150f06c3140a52d145782085d26bc1ea67/ci/pod/keycloak/kcadm_configure_university.sh there is only one client being configured and I would like to avoid modifying many services outside of the plugin. In order to create a test case to prove the bugfix I will need two valid clients. The correct one should get allowed by I am also having some issues testing locally the test cases, but it is more related to the needed openresty modules. I can always provide some proof from my instance, but I imagine this is not enough for the PR. |
I came across this PR while working on another issue in the openid plugin. While I understand the need for an audience check in the use case mentioned I have concerns about the solution proposed with this change. As far as I know neither openid nor oauth2 specify a format, existence or content of an audience claim (e.g. https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3. Some IDPs are using JWTs and the client_id as value of the aud claim, but that's not a requirement and not the case for every IDP. Hard-coding the check to the client_id configured in the plugin would break the plugin for some IDPs which are not using the client_id in an audience claim but still conforming to the spec. The apisix openid plugin is using lua-resty-openidc to verify access tokens, the method |
Hi @markusmueller, so you propose something like additional variables in the config of the plugin to
|
Yes @dtsek , I'm suggesting additional config variables and reuse of existing methods. Let me illustrate and hope it makes it more clear :-) The plugin is using lua-resty-openidc for JWT validation. Instead of implementing your own claim validation the idea is to reuse existing methods:
Rough draft of the additional config properties:
Example config:
|
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
Description
Issue:
openid-connect
currently does not validate if the audience claim matches the client_id which means that every valid JWT can authenticate using this plugin, even if it was generated for a different client.Solution: This MR enhances the
introspect
function by adding a simple validation that the audience claimaud
is the same as the providedclient_id
.Note: There is no documentation that can be updated, unless a note should be added to explain this functionality in the page of the plugin.
Fixes # (issue)
#11018
Checklist