-
Notifications
You must be signed in to change notification settings - Fork 376
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
Shouldn't verification of additional claims, like iss, aud etc. be enforced when in options? #81
Comments
In the meantime I've checked a few other libraries, noteably:
and they all check the issuer claim when it's present in the options. |
This is a bug. After inspecting the code, the verification is triggered only when the iss payload is present. See: https://github.com/progrium/ruby-jwt/blob/master/lib/jwt.rb#L166 This affects also all the other verifications. Thanks for reporting. If you find the time to provide a PR I'd be happy to merge it. |
All right, I'd propose the following
This change then has verification of issuer enabled - as soon as PS: Btw, what is the reasoning behind using |
I agree with your proposal. With these changes it would become more easy to setup the library and check created tokens. But this would break the current api. In this case it would be required to switch to version 2.0. I don't have a problem with this next version step. The use of 'iss' instead of :iss was a mistake in the code review process. It simply slipped through and now it is in the current version. A fix for this could be this active support library. http://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html But this won't be needed if we make the version 2.0 step. In this case we can change everything to use the hash syntax and drop the ruby 1.8.x support. |
Then I'd propose the following:
|
Sounds excellent. 👍 If you have some ideas for version 2.0 send me a mail. |
I just created a google group. https://groups.google.com/forum/#!forum/ruby-jwt Drop your ideas there. :) |
Previously when the following options have been provided verify_iss: true, 'iss' => 'acme.org' and the "iss" claim was missing in the payload - no verification was executed. The same was true for "aud". This commit changes the behaviour, so when verify_iss: true, 'iss' => 'acme.org' is set - then the payload is expected to have the "iss" claim and verification will fail if missing. However, ensure to set `verify_iss` to `true`, otherwise the verification is not enabled. This change is backwards compatible, however it might break an app here or there, because previously the verification did not happen as expected. In addition: fixed related test cases and added new ones to ensure to cover all variants.
Created a PR, so I'm closing this. |
First of all - thanks for the great gem!
What I've stumbled upon while using the gem is the verification of additional attributes, like e.g. the
"iss"
claim. When"iss"
is supplied to the options inJWT.decode
it is not enforced or checked, even whenverify_iss
is set to true as long as it's not present in the actual payload. Basically I've had the following decoding code:and provided it a token like:
and expected it to raise an error, because
iss
is not set in the payload - is this assumption wrong? Should the presence of these attributes be verified again by the application? Looking at jwt.rb#166 the issuer is only verified when it's present in the payload. From my point of view - and I think the more "safe" variant - would be to always trust theoptions
and when"iss"
is present in the options then enforcing the check against the issuer.PS: I'm not savvy with the JWT spec, so it can be that the JWT spec actually proposes the current design. Then just ignore & close my issue :)
PPS: And if this proposal makes sense, I'd be happy to create a PR
The text was updated successfully, but these errors were encountered: