Commit 8fa3381d authored by Peter Loer's avatar Peter Loer
Browse files

Merge pull request #124 from ashimaathri/add_attributes_to_nameid

Add NameQualifier and SPNameQualifier to nameID
parents 97a94886 fadd3e4a
......@@ -226,6 +226,14 @@ SAML.prototype.generateLogoutRequest = function (req) {
}
};
if (typeof(req.user.nameQualifier) !== 'undefined') {
request['samlp:LogoutRequest']['saml:NameID']['@NameQualifier'] = req.user.nameQualifier;
}
if (typeof(req.user.spNameQualifier) !== 'undefined') {
request['samlp:LogoutRequest']['saml:NameID']['@SPNameQualifier'] = req.user.spNameQualifier;
}
if (req.user.sessionIndex) {
request['samlp:LogoutRequest']['saml2p:SessionIndex'] = {
'@xmlns:saml2p': 'urn:oasis:names:tc:SAML:2.0:protocol',
......@@ -598,6 +606,8 @@ SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callb
if (nameID[0].$ && nameID[0].$.Format) {
profile.nameIDFormat = nameID[0].$.Format;
profile.nameQualifier = nameID[0].$.NameQualifier;
profile.spNameQualifier = nameID[0].$.SPNameQualifier;
}
}
}
......
......@@ -452,6 +452,40 @@ describe( 'passport-saml /', function() {
});
});
it( 'generateLogoutRequest adds the NameQualifier and SPNameQualifier to the saml request', function( done ) {
var expectedRequest = {
'samlp:LogoutRequest':
{ '$':
{ 'xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
'xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
//ID: '_85ba0a112df1ffb57805',
Version: '2.0',
//IssueInstant: '2014-05-29T03:32:23Z',
Destination: 'foo' },
'saml:Issuer':
[ { _: 'onelogin_saml',
'$': { 'xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion' } } ],
'saml:NameID': [ { _: 'bar', '$': { Format: 'foo',
SPNameQualifier: 'Service Provider',
NameQualifier: 'Identity Provider' } } ] } };
var samlObj = new SAML( { entryPoint: "foo" } );
var logoutRequest = samlObj.generateLogoutRequest({
user: {
nameIDFormat: 'foo',
nameID: 'bar',
nameQualifier: 'Identity Provider',
spNameQualifier: 'Service Provider'
}
});
parseString( logoutRequest, function( err, doc ) {
delete doc['samlp:LogoutRequest']['$']["ID"];
delete doc['samlp:LogoutRequest']['$']["IssueInstant"];
doc.should.eql( expectedRequest );
done();
});
});
it( 'generateLogoutResponse', function( done ) {
var expectedResponse = {
'samlp:LogoutResponse':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment