Parses SAML responses into JS objects you can read and manipulate.
$ yarn add https://github.com/bgshacklett/libsaml.git
$ npm install git+https://github.com/bgshacklett/libsaml.git --save
LibSaml was designed for use in any Node.js environment whether that's a web app or a standalone script.
const express = ;const LibSaml = ;const app = ;app;app;
To instantiate a new SAML parser:
const LibSaml = ;const parser = SAMLResponse;
After passing your SAML response as a string to the constructor you now have access to the following methods.
var parsedObject = parser.toObject();
Returns parsed SAML as a JSON string. Once you've instantiated the module and
passed it raw SAML you can get its value as a JSON string with
Returns an array containing the value(s) of any SAML attribute(s) by name. The name you pass to this function should be the same as what the attribute value in your SAML is. For example, given this SAML:
To get the value of
First Name you would call it like this:
// assuming you've instantiated the library as `parser` with// `new LibSaml(SAMLResponse)`...var firstName = parser;console; //=> 'John'
You don't need to worry about case sensitivity. Internally the case of the string you pass is normalized so when it is compared against the parsed SAML it will automagically match the name of the key as its stored internally if it exists.
This is a private method. It is called internally when you pass your SAML to the constructor. You should never need to call this manually. See the source code if you want to know more about it.
Testing requires Mocha and Unexpected. Both will be installed with your preferred package manager.
- Clone the repository
- Finally, run
Contributions are welcome. Pull requests without corresponding tests will not be merged outside of exceptional circumstances.
This is a fork of saml2js by Bill Patrianakos, which is, in turn, a fork of saml2json by John Flesch. Thanks for your original work!