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

Usage no npm install needed!

<script type="module">
  import apierAccessverifier from 'https://cdn.skypack.dev/apier-accessverifier';
</script>

README

apier-accessverifier Build Status

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

Dev Dependencies

License

MIT

Generated by package-json-to-readme