saml2fj is a simple javascript file that converts SAML xml's
response to JSON using xml2json package and it offers customizable
methods for its repsonse.
Import saml2fj to your js code.
var saml2FJ = require('saml2fj')
In the /assert path or whatever you configure your w3id
application target, get the SAMLResponse or SAMLRequest
and send it to the saml2fj parser.
var response = req.body.SAMLResponse || req.body.SAMLRequest
saml2FJ.toFiltredJSON(response,function(data){
// Data might be an error if there is, or SAML as JSON.
});
saml2FJ.newToFiltredJSON(response,function(data){
// Data might be an error if there is, or SAML as JSON.
});
{
"firstName": "<First name>",
"lastName": "<Last name>",
"uid": "<uid>",
"email": "<Email>",
"fullName": "<Full name>",
"Groups": [
{
"name": "<Group Name>"
}
]
}
Confirm that the JSON's keys are equals to your user register structure
{
error: true,
description: "Null parameters"
}
saml2FJ.toJSON(response, function (data) {
// Data might be an error if there is, or SAML as JSON.
});
You can check the response keys and manipulate it as you want.