wikijs-fork/server/modules/authentication/azure/authentication.js

33 lines
987 B
JavaScript
Raw Normal View History

/* global WIKI */
2017-07-29 21:33:08 +00:00
// ------------------------------------
// Azure AD Account
// ------------------------------------
const AzureAdOAuth2Strategy = require('passport-azure-ad-oauth2').Strategy
module.exports = {
init (passport, conf) {
const jwt = require('jsonwebtoken')
passport.use('azure_ad_oauth2',
new AzureAdOAuth2Strategy({
clientID: conf.clientId,
clientSecret: conf.clientSecret,
callbackURL: conf.callbackURL,
resource: conf.resource,
tenant: conf.tenant
}, (accessToken, refreshToken, params, profile, cb) => {
2019-04-29 00:25:19 +00:00
console.info(params, profile)
let waadProfile = jwt.decode(params.id_token)
waadProfile.id = waadProfile.oid
waadProfile.provider = 'azure'
2019-04-29 00:25:19 +00:00
// WIKI.models.users.processProfile(waadProfile).then((user) => {
// return cb(null, user) || true
// }).catch((err) => {
// return cb(err, null) || true
// })
}
))
}
2017-07-29 21:33:08 +00:00
}