Skip to content

Commit 42f75d6

Browse files
authored
fix(auth): Properly handle google token issuer (#6836)
* Updated TOKEN_ISSUER to 'accounts.google.com' Hi, I was getting this issue from today morning parse-server/Adapters/Auth/google.js was expecting the TOKEN_ISSUER to be prefixed with https:// but on debugging the original value was not having the prefix, removing https:// from TOKEN_ISSUER solved this bug. This issue is introduced in 4.3.0 as in 4.2.0 it is working fine currently I have downgraded the version to 4.2.0 for it to work properly and suggesting the changes please merge this PR. * Update google.js * Update AuthenticationAdapters.spec.js * Update google.js * Update google.js
1 parent 92afcca commit 42f75d6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

spec/AuthenticationAdapters.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ describe('google auth adapter', () => {
701701
fail();
702702
} catch (e) {
703703
expect(e.message).toBe(
704-
'id token not issued by correct provider - expected: https://accounts.google.com | from: https://not.google.com'
704+
'id token not issued by correct provider - expected: accounts.google.com or https://accounts.google.com | from: https://not.google.com'
705705
);
706706
}
707707
});

src/Adapters/Auth/google.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ var Parse = require('parse/node').Parse;
66
const https = require('https');
77
const jwt = require('jsonwebtoken');
88

9-
const TOKEN_ISSUER = 'https://accounts.google.com';
9+
const TOKEN_ISSUER = 'accounts.google.com';
10+
const HTTPS_TOKEN_ISSUER = 'https://accounts.google.com';
1011

1112
let cache = {};
1213

@@ -67,8 +68,8 @@ async function verifyIdToken({id_token: token, id}, {clientId}) {
6768
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, `${message}`);
6869
}
6970

70-
if (jwtClaims.iss !== TOKEN_ISSUER) {
71-
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, `id token not issued by correct provider - expected: ${TOKEN_ISSUER} | from: ${jwtClaims.iss}`);
71+
if (jwtClaims.iss !== TOKEN_ISSUER && jwtClaims.iss !== HTTPS_TOKEN_ISSUER) {
72+
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, `id token not issued by correct provider - expected: ${TOKEN_ISSUER} or ${HTTPS_TOKEN_ISSUER} | from: ${jwtClaims.iss}`);
7273
}
7374

7475
if (jwtClaims.sub !== id) {

0 commit comments

Comments
 (0)