https://github.com/benderthecrime/passport-rapid-api-auth
Provides an additional layer of security for RapidAPI APIs built on Node.js.
https://github.com/benderthecrime/passport-rapid-api-auth
authentication passport rapidapi security
Last synced: 9 months ago
JSON representation
Provides an additional layer of security for RapidAPI APIs built on Node.js.
- Host: GitHub
- URL: https://github.com/benderthecrime/passport-rapid-api-auth
- Owner: benderTheCrime
- Created: 2019-10-27T17:01:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:57:14.000Z (about 3 years ago)
- Last Synced: 2025-06-21T17:06:42.071Z (9 months ago)
- Topics: authentication, passport, rapidapi, security
- Language: JavaScript
- Size: 4.13 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# passport-rapid-api-auth
Provides an additional layer of security for RapidAPI APIs built on Node.js.
## Installation
```sh
npm i passport-rapid-api-auth
```
## Usage
```js
const passport = require('passport')
const {Strategy: RapidAPIPassportStrategy} = require('passport-rapid-api-auth')
const authParams = {
passReqToCallback: false,
proxySecret: 'RAPID_API_PROXY_SECRET',
}
passport.use('rapid-api', new Strategy(authParams, verify)
app.use(passport.initialize())
app.use(passport.session())
function verify(...args) {
const [user, id, next] = args
return next(null, {
id,
name: user.name,
subscription: user.subscription,
version: user.version,
})
}
```
### RapidAPI Proxy Secret
> For security, you should protect your API by blocking requests that are not from the RapidAPI infrastructure. RapidAPI adds the "X-RapidAPI-Proxy-Secret" header on every request. This header has a unique value for each API. if this header is missing or has a different value from the value specified below, you should assume the request is not from RapidAPI infrastructure.
This value can be found under the "Settings" tab in your RapidAPI configuration.