Skip to content

Commit

Permalink
Support redirect flows
Browse files Browse the repository at this point in the history
  • Builds on node-saml#16
  • Reverts 638ce6e
  • Implements node-saml#191
  • Loading branch information
stavros-wb committed Apr 4, 2018
1 parent 20aa0a9 commit 81903ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
25 changes: 25 additions & 0 deletions lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,31 @@ SAML.prototype.validatePostResponse = function (container, callback) {
.done();
};

SAML.prototype.validateRedirectResponse = function (container, callback) {
var data = new Buffer(container.SAMLResponse, "base64");
var signature = null; //new Buffer(container.Signature, 'base64').toString('ascii');
this.validateRedirect(data, signature, validateResponse, callback);
};

SAML.prototype.validateRedirectRequest = function (container, callback) {
var data = new Buffer(container.SAMLRequest, "base64");
var signature = null; //new Buffer(container.Signature, 'base64').toString('ascii');
this.validateRedirect(data, signature, validateRequest, callback);
};

SAML.prototype.validateRedirect = function(data, signature, validate, callback) {
var self = this;
// TODO verify redirect

zlib.inflateRaw(data, function(err, inflated) {
if (err) {
return callback(err);
}

self.validateXML(inflated.toString("utf8"), "", validate, callback);
});
};

SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callback) {
var self = this;
var msg;
Expand Down
10 changes: 7 additions & 3 deletions lib/passport-saml/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ Strategy.prototype.authenticate = function (req, options) {
}
}

if (req.body && req.body.SAMLResponse) {
this._saml.validatePostResponse(req.body, validateCallback);
if (req.query && req.query.SAMLResponse) {
this._saml.validateRedirectResponse(req.query, validateCallback);
} else if (req.query && req.query.SAMLRequest) {
this._saml.validateRedirectRequest(req.query, validateCallback);
} else if (req.body && req.body.SAMLResponse) {
this._saml.validatePostResponse(req.body, validateCallback);
} else if (req.body && req.body.SAMLRequest) {
this._saml.validatePostRequest(req.body, validateCallback);
this._saml.validatePostRequest(req.body, validateCallback);
} else {
var requestHandler = {
'login-request': function() {
Expand Down

0 comments on commit 81903ab

Please sign in to comment.