passport-openapi
v1.0.0
Published
OpenAPI authentication strategy for Passport and Node.js.
Downloads
9
Maintainers
Readme
passport-openapi
OpenAPI authentication strategy for Passport and Node.js.
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
- Register a new OAuth application on Github
- Launch demo server
git clone [email protected]: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
basic
apiKey + header
,apiKey + query
oauth2 + password
oauth2 + accessCode
Not supported
oauth2 + implicit
oauth2 + application
are not supported now.
see "Application access" Aaron Parecki