https://github.com/kth/kth-node-api-key-strategy
A api key strategy for Node.js applications.
https://github.com/kth/kth-node-api-key-strategy
Last synced: 4 months ago
JSON representation
A api key strategy for Node.js applications.
- Host: GitHub
- URL: https://github.com/kth/kth-node-api-key-strategy
- Owner: KTH
- License: mit
- Created: 2016-08-31T14:10:14.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2025-05-01T04:19:41.000Z (about 1 year ago)
- Last Synced: 2025-08-14T14:55:17.149Z (10 months ago)
- Language: JavaScript
- Size: 1.09 MB
- Stars: 0
- Watchers: 21
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kth-node-api-key-strategy [](https://travis-ci.org/KTH/kth-node-api-key-strategy)
A api key strategy for Node applications.
## Configure
#### serverSettings.js
```
module.exports = {
secure: {
api_keys: [
{name: 'devClient', apikey: '1234567', scope: ['write', 'read']},
{name: 'testClient', apikey: '891011', scope: ['read']}
{name: 'publicClient', apikey: '0000', scope: ['readPublic']}
],
}
};
```
#### swagger.js
**Setting security on a route**
```
"/v1/some/route/{id}": {
"get": {
"operationId": "",
"summary": "",
"description": "",
"parameters": [],
"tags": [
"v1"
],
"responses": { ... },
"security": {
"api_key": [
"read"
]
}
}
}
```
**Defining security definition**
```
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header",
"scopes": {
"read": "Read access to data",
"write": "Write access to data",
"readPublic": "Read only access to publicly visible data",
}
}
}
```