Skip to content

Use an empty object as default value of options for Google Sign in #6844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,27 @@ describe('server', () => {
})
.catch(done.fail);
});

it('should not fail when Google signin is introduced without the optional clientId', done => {
const jwt = require('jsonwebtoken');

reconfigureServer({
auth: { google: {} }
})
.then(() => {
const fakeClaim = {
iss: 'https://accounts.google.com',
aud: 'secret',
exp: Date.now(),
sub: 'the_user_id',
};
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
spyOn(jwt, 'decode').and.callFake(() => fakeDecodedToken);
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
const user = new Parse.User();
user.linkWith('google', { authData: { id: 'the_user_id', id_token: 'the_token' }})
.then(done);
})
.catch(done.fail);
});
});
2 changes: 1 addition & 1 deletion src/Adapters/Auth/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function verifyIdToken({id_token: token, id}, {clientId}) {
}

// Returns a promise that fulfills if this user id is valid.
function validateAuthData(authData, options) {
function validateAuthData(authData, options = {}) {
return verifyIdToken(authData, options);
}

Expand Down