const sp = new saml2.ServiceProvider(sso_options.sp_options);
const params = querystring.parse(event.body);
// Our field from the request.
const samlResponse = params['SAMLResponse'];
log.debug(samlResponse);
const req ={};
req.SAMLResponse = samlResponse;
const options = {request_body:req};
const idp = new saml2.IdentityProvider(sso_options.idp_options);
log.debug(options);
sp.post_assert(idp,options,function(err, assertionResponse){
if(err){
log.error(err);
throw(err);
} else {
log.debug(assertionResponse);
const userId = assertionResponse.user.name_id;
const firstName = assertionResponse.user.attributes.firstName[0];
const lastName = assertionResponse.user.attributes.lastName[0];
const email = assertionResponse.user.attributes.email[0];
const accessToken = auth.createAccessToken(userId,firstName,lastName,email,'User');
}})})
I get the below error after i receive the assertionResponse and see the log statement. It seems the callback is invoked before completion of the async calls. What could be the issue ?
2017-09-29T16:58:01.202Z 58dea4fa-a537-11e7-ac37-2b1c78b060d2 Error: Callback was already called.
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:903:32
at /var/task/node_modules/saml2-js/lib-js/saml2.js:658:16
at nextTask (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5297:14)
at next (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5304:9)
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:906:16
at /var/task/node_modules/saml2-js/lib-js/saml2.js:633:20
at nextTask (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5297:14)
at next (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5304:9)
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:906:16
at /var/task/node_modules/saml2-js/lib-js/saml2.js:607:16
const sp = new saml2.ServiceProvider(sso_options.sp_options);
const params = querystring.parse(event.body);
log.debug(samlResponse);
const req ={};
req.SAMLResponse = samlResponse;
const options = {request_body:req};
const idp = new saml2.IdentityProvider(sso_options.idp_options);
log.debug(options);
sp.post_assert(idp,options,function(err, assertionResponse){
if(err){
log.error(err);
throw(err);
} else {
}})})
I get the below error after i receive the assertionResponse and see the log statement. It seems the callback is invoked before completion of the async calls. What could be the issue ?
2017-09-29T16:58:01.202Z 58dea4fa-a537-11e7-ac37-2b1c78b060d2 Error: Callback was already called.
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:903:32
at /var/task/node_modules/saml2-js/lib-js/saml2.js:658:16
at nextTask (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5297:14)
at next (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5304:9)
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:906:16
at /var/task/node_modules/saml2-js/lib-js/saml2.js:633:20
at nextTask (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5297:14)
at next (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5304:9)
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:906:16
at /var/task/node_modules/saml2-js/lib-js/saml2.js:607:16