1.0.0 • Published 9 years ago
passport-openapi v1.0.0
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 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+githubmore example, see test
Supported
see OpenAPI-Specification/2.0.md at master · OAI/OpenAPI-Specification · GitHub
basicapiKey + header,apiKey + queryoauth2 + passwordoauth2 + accessCode
Not supported
oauth2 + implicitoauth2 + application
are not supported now.
see "Application access" Aaron Parecki
1.0.0
9 years ago