Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upPass payload to keyfinder #172
Conversation
Added check that |
I added a view comments to your changes. If you find the time you may fix them. Otherwise the PR looks good to me. |
key = yield(header) if keyfinder | ||
def signature_algorithm_and_key(header, payload, key, &keyfinder) | ||
if keyfinder | ||
key = (keyfinder.arity == 2) ? keyfinder.call(header, payload) : keyfinder.call(header) |
This comment has been minimized.
This comment has been minimized.
excpt
Oct 20, 2016
Member
Please change your code to use yield
instead of keyfinder.call (yield(header, playload)
and yield(header)
) and use a full if else
condition statement instead of your ternary conditions.
key = if keyfinder.arity == 2
yield(header, payload)
else
yield(header)
This comment has been minimized.
This comment has been minimized.
CodeMonkeySteve
Oct 20, 2016
Author
Contributor
With the arity check, I prefer call
to yield
, as it makes it more obvious that keyfinder
is the block being called. But I'll defer to your style.
def signature_algorithm_and_key(header, payload, key, &keyfinder) | ||
if keyfinder | ||
key = (keyfinder.arity == 2) ? keyfinder.call(header, payload) : keyfinder.call(header) | ||
raise JWT::DecodeError, 'No verification key available' unless key |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
CodeMonkeySteve
Oct 20, 2016
Author
Contributor
Apparently no one likes my style of putting two spaces before postfix conditionals, but I wouldn't call it a code smell. ;)
Made style changes. |
Thanks. :) |
CodeMonkeySteve commentedOct 17, 2016
•
edited by excpt
I have an app that I would like to authenticate to using tokens signed with HMAC (created by the app) or ECDSA (created by other companies), depending on the value of the issuer (
iss
) claim. I'm using thekeyfinder
block to implement that logic, but it needs to have thepayload
passed to it in order to find the appropriate public key for the issuer. To that end, I made a small change to pass both theheader
andpayload
tokeyfinder
, if it has arity of 2. Now my calling code looks like: