Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions lib/saml11.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var path = require('path');
var utils = require('./utils');
var Parser = require('@xmldom/xmldom').DOMParser;
var xmlenc = require('xml-encryption');
Expand All @@ -9,7 +8,31 @@ var crypto = require('crypto');
var EncryptXml = require('./xml/encrypt');
var SignXml = require('./xml/sign');

var newSaml11Document = utils.factoryForNode(path.join(__dirname, 'saml11.template'));
var template = `<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" MajorVersion="1" MinorVersion="1" AssertionID="" IssueInstant="">
<saml:Conditions>
<saml:AudienceRestrictionCondition />
</saml:Conditions>
<saml:AttributeStatement>
<saml:Subject>
<saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" />
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
</saml:AttributeStatement>
<saml:AuthenticationStatement
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password">
<saml:Subject>
<saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">
</saml:NameIdentifier>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
</saml:AuthenticationStatement>
</saml:Assertion>`;

var newSaml11Document = utils.factoryForNode(template);

var NAMESPACE = 'urn:oasis:names:tc:SAML:1.0:assertion';

Expand Down
23 changes: 0 additions & 23 deletions lib/saml11.template

This file was deleted.

19 changes: 17 additions & 2 deletions lib/saml20.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var path = require('path');
var async = require('async');
var moment = require('moment');
var xmlNameValidator = require('xml-name-validator');
Expand All @@ -8,7 +7,23 @@ var EncryptXml = require('./xml/encrypt');
var SignXml = require('./xml/sign');
var utils = require('./utils');

var newSaml20Document = utils.factoryForNode(path.join(__dirname, 'saml20.template'));
const template = `<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" ID="" IssueInstant="">
<saml:Issuer></saml:Issuer>
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" />
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData />
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions />
<saml:AuthnStatement AuthnInstant="">
<saml:AuthnContext>
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
</saml:Assertion>`;

var newSaml20Document = utils.factoryForNode(template);

var NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion';

Expand Down
15 changes: 0 additions & 15 deletions lib/saml20.template

This file was deleted.

3 changes: 1 addition & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ function getRandomInt(min, max) {
* @param {string} pathToTemplate an absolute path to a template file
* @return {function(): Node}
*/
exports.factoryForNode = function factoryForNode(pathToTemplate) {
const template = fs.readFileSync(pathToTemplate);
exports.factoryForNode = function factoryForNode(template) {
const prototypeDoc = new Parser().parseFromString(template.toString());

return function () {
Expand Down
Loading