express-userinfo
v0.0.5
Published
Express middleware to retrieve OIDC userinfo
Downloads
13
Readme
Purpose
Use this express middleware to retrieve information about the user, when an OAuth2 access token is given.
The userinfo would typically adhere to OIDC's userinfo.
How
(Note: You need promises and ES6 support for const
keyword; if this is an
issue, it should be easy enough to downgrade; pull requests welcome.)
Assuming an existing expressjs application, install this middleware
npm install express-userinfo isomorphic-fetch
, then configure and use it in a route, e.g.
const expressUserinfo = require('express-userinfo')
const getUserinfo = expressUserinfo({
site: 'http://my-oidc-provider.com'
})
app.get('/something-with-userinfo', getUserinfo, (req, res, next) => {
res.send(`sub=${ req.userinfo.sub }, token=${ req.access_token }`)
})