Created
May 9, 2018 10:02
-
-
Save omerlh/6b99a5e2d08358ae814051585e6beb8b to your computer and use it in GitHub Desktop.
Validation JWT Bearer token issued by IdentityServer in NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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