Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend and document the profile object #301

Merged
merged 1 commit into from
Sep 30, 2018
Merged
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ passport.use(new MultiSamlStrategy(
);
```

#### The profile object:

The profile object referenced above contains the following:

```typescript
type Profile = {
issuer?: string;
sessionIndex?: string;
nameID?: string;
nameIDFormat?: string;
nameQualifier?: string;
spNameQualifier?: string;
mail?: string; // InCommon Attribute urn:oid:0.9.2342.19200300.100.1.3
email?: string; // `mail` if not present in the assertion
getAssertionXml(): string; // get the raw assertion XML
getAssertion(): object; // get the assertion XML parsed as a JavaScript object
ID?: string;
} & {
[attributeName: string]: string; // arbitrary `AttributeValue`s
}
```

#### Config parameter details:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjbarth Thanks for this. Generally it looks good.

To check if this was correct, I reviewed the result of grep profile lib/passport-saml/saml.js. The results show that all these fields are present. Some recommended changes:

  • briefly document both getAssertionXml() and getAssertion()
  • From reading this code, it appears arbitrary name/value pairs of attributes may also be returned: https://github.com/bergie/passport-saml/blob/master/lib/passport-saml/saml.js#L851 this should also be documented.
  • The exceptional handling of "mail" and "email" mentioned above is perhaps also worth mentioning. The code shows that "mail" defaults to a particular field identified by OID, and that "email" will default to "mail" if not present. It's not clear to me why both exist, but with slightly different meanings.
  • squash commits into one

Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markstos I believe I've addressed your concerns here. Please let me know if there is more to do.


* **Core**
Expand Down
6 changes: 5 additions & 1 deletion lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,11 @@ SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callb
var nowMs = new Date().getTime();
var profile = {};
var assertion;
var parsedAssertion;
var parser = new xml2js.Parser(parserConfig);
Q.ninvoke(parser, 'parseString', xml)
.then(function(doc) {
parsedAssertion = doc;
assertion = doc.Assertion;

var issuer = assertion.Issuer;
Expand Down Expand Up @@ -858,7 +860,8 @@ SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callb
}

if (!profile.mail && profile['urn:oid:0.9.2342.19200300.100.1.3']) {
// See http://www.incommonfederation.org/attributesummary.html for definition of attribute OIDs
// See https://spaces.internet2.edu/display/InCFederation/Supported+Attribute+Summary
// for definition of attribute OIDs
profile.mail = profile['urn:oid:0.9.2342.19200300.100.1.3'];
}

Expand All @@ -867,6 +870,7 @@ SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callb
}

profile.getAssertionXml = function() { return xml; };
profile.getAssertion = function() { return parsedAssertion; };

callback(null, profile, false);
})
Expand Down