Skip to content

Commit 1290fd9

Browse files
committed
Fix apple signin authAdapter to use the user id instead of the user token
1 parent 0e9462b commit 1290fd9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Adapters/Auth/apple.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const getApplePublicKey = async () => {
2929
return currentKey;
3030
};
3131

32-
const verifyIdToken = async (token, clientID) => {
32+
const verifyIdToken = async ({ token, id }, clientID) => {
3333
if (!token) {
3434
throw new Parse.Error(
3535
Parse.Error.OBJECT_NOT_FOUND,
@@ -45,6 +45,12 @@ const verifyIdToken = async (token, clientID) => {
4545
`id token not issued by correct OpenID provider - expected: ${TOKEN_ISSUER} | from: ${jwtClaims.iss}`
4646
);
4747
}
48+
if (jwtClaims.sub !== id) {
49+
throw new Parse.Error(
50+
Parse.Error.OBJECT_NOT_FOUND,
51+
`auth data is invalid for this user.`
52+
);
53+
}
4854
if (clientID !== undefined && jwtClaims.aud !== clientID) {
4955
throw new Parse.Error(
5056
Parse.Error.OBJECT_NOT_FOUND,
@@ -56,7 +62,7 @@ const verifyIdToken = async (token, clientID) => {
5662

5763
// Returns a promise that fulfills if this id token is valid
5864
function validateAuthData(authData, options = {}) {
59-
return verifyIdToken(authData.id, options.client_id);
65+
return verifyIdToken(authData, options.client_id);
6066
}
6167

6268
// Returns a promise that fulfills if this app id is valid.

0 commit comments

Comments
 (0)