0.0.5 • Published 6 years ago

express-userinfo v0.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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 }`)
})