passport-openapi

1.0.0 • Public • Published

passport-openapi

OpenAPI authentication strategy for Passport and Node.js.

CircleCI Dependency Status codecov js-standard-style

Getting started

const passport = require('passport')
const OpenApiStrategy = require('passport-openapi')
 
// https://dev.twitter.com/oauth/reference/post/oauth2/token
const twitterSpec = {
  securityDefinitions: {
    '3-legged': {
      type: "oauth2",
      flow: "accessCode",
      authorizationUrl: 'https://api.twitter.com/oauth/authorize',
      tokenUrl: 'https://api.twitter.com/oauth2/token',
    }
  }
}
 
const securityDefinition = twitterSpec.securityDefinitions['3-legged']
passport.use('twitter', new OpenApiStrategy(securityDefinition, {
  clientID: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  clientSecret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
}))

Example

  1. Register a new OAuth application on Github
  2. Launch demo server
git clone git@github.com:blockenio/passport-openapi.git
cd passport-openapi
GITHUB_CLIENT_ID=xxxxx GITHUB_CLIENT_SECRET=xxxxx node --harmony_default_parameters --harmony_proxies example/server.js
open http://localhost:3000/auth/oauth2+github

more example, see test

Supported

see OpenAPI-Specification/2.0.md at master · OAI/OpenAPI-Specification · GitHub

Not supported

  • oauth2 + implicit
  • oauth2 + application

are not supported now.

see "Application access" Aaron Parecki

Package Sidebar

Install

npm i passport-openapi

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • lekoleko