Skip to content

Instantly share code, notes, and snippets.

@jcontonio
Last active August 29, 2015 14:09
Show Gist options
  • Save jcontonio/cc576395ef012773aabe to your computer and use it in GitHub Desktop.
Save jcontonio/cc576395ef012773aabe to your computer and use it in GitHub Desktop.
Strategy
// Web server does this, hits an endpoint
// { type: 'saml', strategy: company.strategy }
var company = Company.findByDomain(__domain);
if (company) {
var strategy = company.strategy;
}
var companyStrat = function() {
// it's a SAML type
if (strategy.type === 'saml') {
// that strategy object looks like this, specific to the company, stored in the company.
return (
{
path: '/login/callback',
entryPoint: '', //path to msdev-sts..../adfs/ls
issuer: __domain + '/login/callback',
callbackUrl: __domain + '/login/callback',
// We don't know what this CERT is, is it our SSL cert?
cert: 'MIICizCCAfQCCQCY8tKaMc0BMjANBgkqh ... W==',
identifierFormat: null
},
function(profile, done) {
// Web server request to API and do stuff here Dirk
if (profile) {
return done(null, apiCallToServerWithSecret)
// we want to pass profile data to the system? What if properties change?
}
});
}
}
// Web server - Setting it
passport.use(new companyStrat);
if (!fs.open('/adfs/FederationMetadata.xml','r')) {
var metaData = passport.generateServiceProviderMetadata(strategy.cert);
fs.write(__dir + '/adfs/FederationMetadata.xml', metaData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment