Skip to content

Commit fd31159

Browse files
authored
fix: Facebook Standard Login missing app ID validation (#10429)
1 parent 39af946 commit fd31159

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

spec/AuthenticationAdapters.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,24 @@ describe('facebook limited auth adapter', () => {
17321732
expect(e.message).toBe('Facebook auth is not configured.');
17331733
}
17341734
});
1735+
1736+
it('should throw error when appIds is not configured for Standard Login', async () => {
1737+
try {
1738+
await facebook.validateAuthData({ id: 'the_user_id', access_token: 'the_token' }, {});
1739+
fail('should have thrown');
1740+
} catch (e) {
1741+
expect(e.message).toBe('Facebook auth is not configured.');
1742+
}
1743+
});
1744+
1745+
it('should throw error when appIds is empty array for Standard Login', async () => {
1746+
try {
1747+
await facebook.validateAuthData({ id: 'the_user_id', access_token: 'the_token' }, { appIds: [] });
1748+
fail('should have thrown');
1749+
} catch (e) {
1750+
expect(e.message).toBe('Facebook auth is not configured.');
1751+
}
1752+
});
17351753
});
17361754

17371755
describe('OTP TOTP auth adatper', () => {

src/Adapters/Auth/facebook.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ function getAppSecretPath(authData, options = {}) {
7979
return `&appsecret_proof=${appsecret_proof}`;
8080
}
8181

82-
function validateGraphToken(authData, options) {
82+
function validateGraphToken(authData, options = {}) {
83+
if (!Array.isArray(options.appIds) || !options.appIds.length) {
84+
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Facebook auth is not configured.');
85+
}
8386
return graphRequest(
8487
'me?fields=id&access_token=' + authData.access_token + getAppSecretPath(authData, options)
8588
).then(data => {

0 commit comments

Comments
 (0)