Add support for multiple apple public keys#8
Add support for multiple apple public keys#8tomislavherman wants to merge 5 commits intoTechofficer:masterfrom
Conversation
Currently we use only first public key provided by apple to verify ID token. It seems that apple issues ID tokens with different keys (3 in this moment). This fix uses `header.kid` field from ID token in order to identify which public key will be used to verify ID token.
source/index.js
Outdated
| const data = await request({ url: url.toString(), method: 'GET' }); | ||
| const key = JSON.parse(data).keys[0]; | ||
| const key = JSON.parse(data).keys.find(key => key.kid === kid); |
There was a problem hiding this comment.
request-promise-native accepts a json option to automatically parse the response as json.
Can be written as the following for a small gain in readability
const keys = await request({ url: url.toString(), method: 'GET', json: true });
const key = keys.find(k => k.kid === kid);There was a problem hiding this comment.
Nice catch! Pull request is updated.
|
Can we move the discussion in #9 ? IMO, it would be good to move to |
|
@alexabidri I applied your suggestion to this PR. I hope this is ok. |
|
@tomislavherman Good job! Personnaly I would prefer to use As apple-signin is a package aim to be used by some startup/corporations, I would avoid using a non maintained module which doesnt provide big improvements except to promisify a already existing module. Some hours ago, jwks-rsa got a new release (1.7.0) Here is a simple wrapper to promisified |
|
Thanks, @alexabidri. I agree with you regarding the I would just instantiate jwks client in the scope of the module instead of in the scope of |
Create wrapper around client which promisifies getSigningKey on jwks client
Currently we use only first public key provided by apple to verify ID
token. It seems that apple issues ID tokens with different keys (3 in
this moment). This fix uses
header.kidfield from ID token in order toidentify which public key will be used to verify ID token.