apier-accessverifier
Checks if the incoming request has is allowed to access the endpoint.
It uses a configuration that must be an object with the following structure
var object = {
access: {
verifyOrigin: true,
apikeys: [{
origin: 'http://google.com',
key: '1234'
}, {
origin: 'http://bing.com',
key: '12345'
}]
}
}
Setting verifyOrigin to true, makes accessVerifier to check that not only the key exists in the configuration but also the request origin header matches the origin field.
Setting verifyOrigin to false, makes the accessVerifier to only search if the given api exists in the configuration.
Installation
Download node at nodejs.org and install it, if you haven't already.
npm install apier-accessverifier --save
API
init(configuration)
configuration
Type: object
Init method should be used on server start, to initialize the module.
Check for example configuration above.
verify()
Used as middleware to make the actual verification.
Tests
npm install
npm test
Dependencies
- apier-responsebuilder: Builds and sends the response of apier.
- reqlog: A simple Node.js logger. Very closely attached to a request.
Dev Dependencies
- eslint: An AST-based pattern checker for JavaScript.
- eslint-config-google: ESLint shareable config for the Google style
License
MIT
Generated by package-json-to-readme