Merge pull request from GHSA-8w3j-g983-8jh5

* Add Test and Authenticator for ghsa-8w3j-g983-8jh5

* fix for ghsa-8w3j-g983-8jh5

* nit whitespace

not sure why lint isn't catching...
This commit is contained in:
Fabian Strachanski
2019-07-10 15:47:23 +02:00
committed by Arthur Cinader
parent 050dd19e80
commit 73b0f9a339
3 changed files with 68 additions and 10 deletions

View File

@@ -118,6 +118,7 @@ const defaultConfiguration = {
},
auth: {
// Override the facebook provider
custom: mockCustom(),
facebook: mockFacebook(),
myoauth: {
module: path.resolve(__dirname, 'myoauth'), // relative path as it's run from src
@@ -348,6 +349,24 @@ function range(n) {
return answer;
}
function mockCustomAuthenticator(id, password) {
const custom = {};
custom.validateAuthData = function(authData) {
if (authData.id === id && authData.password.startsWith(password)) {
return Promise.resolve();
}
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'not validated');
};
custom.validateAppId = function() {
return Promise.resolve();
};
return custom;
}
function mockCustom() {
return mockCustomAuthenticator('fastrde', 'password');
}
function mockFacebookAuthenticator(id, token) {
const facebook = {};
facebook.validateAuthData = function(authData) {
@@ -406,6 +425,7 @@ global.jequal = jequal;
global.range = range;
global.reconfigureServer = reconfigureServer;
global.defaultConfiguration = defaultConfiguration;
global.mockCustomAuthenticator = mockCustomAuthenticator;
global.mockFacebookAuthenticator = mockFacebookAuthenticator;
global.jfail = function(err) {
fail(JSON.stringify(err));