Skip to content

Instantly share code, notes, and snippets.

@omerlh
Created May 9, 2018 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omerlh/6b99a5e2d08358ae814051585e6beb8b to your computer and use it in GitHub Desktop.
Save omerlh/6b99a5e2d08358ae814051585e6beb8b to your computer and use it in GitHub Desktop.
Validation JWT Bearer token issued by IdentityServer in NodeJS
import passport from 'passport'
import {BearerStrategy} from 'passport-azure-ad';
const options = {
clientID: 'x', //irelevant
identityMetadata: '<IDSrv URL>/.well-known/openid-configuration',
issuer: '<IDSrv issuer>',
audience: '<IDSrv audience>',
passReqToCallback: true
};
const clientAuthenticationStrategy = new BearerStrategy(options,
(req, token, done) => {
if (!token) return done("no token", null)
req.requestToken = token
return done(null, token);
});
const configure = app => {
passport.use('identity-server-authentication', clientAuthenticationStrategy);
app.use(passport.initialize());
return passport;
};
export default {configure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment