passport‐azure‐ad - GluuFederation/tutorials GitHub Wiki

Overview

Currently, gluu-passport is not supporting passport-azure-ad. You need to manually install, configure it and add little code patch in it.

  1. Install passport-azure-ad. Run below command inside chroot
# service passport stop
# cd /opt/gluu/node/passport
# npm i 
# npm i passport-azure-ad
  1. Add mapping file
# cd /opt/gluu/node/passport
# touch server/mappings/azure-ad.js

add the below content in the azure-ad.js file.

module.exports = profile => {
  return {
    uid: profile.username || profile.oid,
    mail: profile.emails && profile.emails[0] && profile.emails[0].value,
    cn: profile.displayName,
    displayName: profile.displayName,
    givenName: profile.name.givenName,
    sn: profile.name.familyName
  }
}
  1. Add JS Code in provider.js at line no. 71 to add support for passport-azure-ad strategy
// Before

    if (provider.type === 'oauth' && Strategy.OAuth2Strategy) {
      Strategy = Strategy.OAuth2Strategy
    } else {
      Strategy = Strategy.Strategy
    }

// After
    if (provider.type === 'oauth' && Strategy.OAuth2Strategy) {
      Strategy = Strategy.OAuth2Strategy
    } else if (provider.type === 'oauth' && Strategy.OIDCStrategy) {
      Strategy = Strategy.OIDCStrategy
    } else {
      Strategy = Strategy.Strategy
    }
  1. Add provider

image

More settings and configurations

  1. Restart passport service passport restart and check service status service passport status

  2. Check passport.log for any error