passport-entra
v0.1.1
Published
Microsoft Entra authentication strategy for passport
Downloads
788
Readme
README
What is this repository for?
This is a replacement for passport-azure-ad.
How do I get set up?
Set up authentication:
const clientID = ...
const scope = ...
const tenantID = ...
const issuer = `https://login.microsoftonline.com/${tenantID}/v2.0`;
const options: BearerOptions = {
clientID,
identityMetadata: `${issuer}/.well-known/openid-configuration`,
issuer,
scope: [scope],
};
const bearerStrategy = new BearerStrategy(
options,
(token: object, done: AuthenticateCallback) => { done(null, {}, token); },
);
passport.use(bearerStrategy);
const authenticate = passport.authenticate(
'oauth-bearer',
{ session: false },
);Use with express:
const app = express();
// all calls require user authentication
app.all('/api/*splat', authenticate);
// authentication passed
app.all('/api/*splat', async (req, res, next) => {
logger.info(`${req.method} ${req.path}`);
logger.info(req.authInfo);
next();
});Contribution guidelines
Feel free to raise an issue at https://bitbucket.org/janbakker/passport-entra
Who do I talk to?
Kind regards, Jan Bakker
