I must be missing something very obvious on this one.
I've been trying to trust/follow the official docs on this one but I'm noticing I'm not actually using that whole 'bearerStrategy' I'm defining anywhere. If I try to swap out oauth-bearer with bearerStrategy I'm getting the exact same result.
Setup:
const passport = require('passport');
const BearerStrategy = require('passport-azure-ad').BearerStrategy
Endpoint in index.js:
app.use("/andon", passport.authenticate('oauth-bearer', { session: false }), andon);
Configuration from the documentation files:
let options = {
identityMetadata: appconfig.get("creds.identityMetadata"),
clientID: appconfig.get("creds.clientID"),
passReqToCallback: appconfig.get("creds.passReqToCallback")
}
let bearerStrategy = new BearerStrategy(options,
function(token, done) {
log.info('verifying the user');
log.info(token, 'was the token retreived');
findById(token.oid, function(err, user) {
if (err) {
return done(err);
}
if (!user) {
// "Auto-registration"
log.info('User was added automatically as they were new. Their oid is: ', token.oid);
users.push(token);
owner = token.oid;
return done(null, token);
}
owner = token.oid;
return done(null, user, token);
});
}
);