Parse SAML authentication response to filtered/custom JSON.
npm install saml2fjsaml2fj 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.
});
`$3
`
saml2FJ.newToFiltredJSON(response,function(data){
// Data might be an error if there is, or SAML as JSON.
});
`$3
##### Success:
``
{
"firstName": "
"lastName": "
"uid": "
"email": "
"fullName": "
"Groups": [
{
"name": "
}
]
}
> Confirm that the JSON's keys are equals to your user register structure
#### Error:
`
{
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.