Skip to content

Instantly share code, notes, and snippets.

@travist
Last active April 17, 2023 16:17
Show Gist options
  • Save travist/0a2bb69ac14bb3229e358c58eaacfc5f to your computer and use it in GitHub Desktop.
Save travist/0a2bb69ac14bb3229e358c58eaacfc5f to your computer and use it in GitHub Desktop.
Convert XML to Passport Configurations

Usage

Copy contents of your Passport XML into the config.xml file, then run the following.

node index.js

Take the result of the console, and then add the following to the top of the JSON it provides to you.

{
  "issuer": "--- ADD YOUR ISSUER HERE ---",
  --- REST OF PASSPORT JSON HERE ---
}
const fs = require('fs');
const {MetadataReader, toPassportConfig} = require('passport-saml-metadata');
const settings = toPassportConfig(new MetadataReader(fs.readFileSync('./config.xml', {encoding: 'utf-8'})));
settings.wantAuthnResponseSigned = false;
console.log(JSON.stringify(settings, null, 2));
{
"name": "xml-to-passport",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"passport-saml-metadata": "^3.1.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment