Last active
August 29, 2015 14:09
-
-
Save jcontonio/cc576395ef012773aabe to your computer and use it in GitHub Desktop.
Strategy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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