Skip to content

Commit a7707a7

Browse files
committed
[issue-96] Making kid in id_token optional
kid is optional if there is a single key in the JWK Set document. See http://openid.net/specs/openid-connect-core-1_0.html#Signing
1 parent 3913186 commit a7707a7

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎src/ResponseValidator.js‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ export default class ResponseValidator {
243243
}
244244

245245
var kid = jwt.header.kid;
246-
if (!kid) {
247-
Log.error("No kid found in id_token");
248-
return Promise.reject(new Error("No kid found in id_token"));
249-
}
250246

251247
return this._metadataService.getIssuer().then(issuer => {
252248
Log.info("Received issuer");
@@ -258,6 +254,17 @@ export default class ResponseValidator {
258254
}
259255

260256
Log.info("Received signing keys");
257+
if (!kid) {
258+
if (keys.length > 1) {
259+
Log.error("No kid found in id_token");
260+
return Promise.reject(new Error("No kid found in id_token"));
261+
} else {
262+
// kid is mandatory only when there are multiple keys in the referenced JWK Set document
263+
// see http://openid.net/specs/openid-connect-core-1_0.html#Signing
264+
kid = keys[0].kid;
265+
}
266+
267+
}
261268

262269
let key = keys.filter(key => {
263270
return key.kid === kid;

0 commit comments

Comments
 (0)