Skip authData validation if it hasn't changed. (#3783)

* Adds test for the new feature

* Re-validate authData only if mutated

- In case of short-lived tokens (like facebook) this will allow clients to be lax with asking users to re-login
This commit is contained in:
Florent Vilmart
2017-05-07 12:55:30 -04:00
committed by GitHub
parent 4f903952bf
commit 45a9d50110
3 changed files with 64 additions and 10 deletions

View File

@@ -106,7 +106,8 @@ var defaultConfiguration = {
facebook: mockFacebook(),
myoauth: {
module: path.resolve(__dirname, "myoauth") // relative path as it's run from src
}
},
shortLivedAuth: mockShortLivedAuth()
}
};
@@ -369,6 +370,25 @@ function mockFacebook() {
return mockFacebookAuthenticator('8675309', 'jenny');
}
function mockShortLivedAuth() {
const auth = {};
let accessToken;
auth.setValidAccessToken = function(validAccessToken) {
accessToken = validAccessToken;
}
auth.validateAuthData = function(authData) {
if (authData.access_token == accessToken) {
return Promise.resolve();
} else {
return Promise.reject('Invalid access token');
}
};
auth.validateAppId = function() {
return Promise.resolve();
};
return auth;
}
// This is polluting, but, it makes it way easier to directly port old tests.
global.Parse = Parse;