#Arrow Authentication Scheme
https://gist.github.com/lbrenman/f884ea1f43d75ed98deb
*Using Basic APIKey Authentication provides a single key for all users of the API
- What if want to provide a different API Key for different users/customers
- this is an API Management feature
- Today, we don’t support this but it can easily be built using Arrow Authentication Scheme
- Further, ArrowDB can be used to store the users and their keys for authentication
- Then, access to the API can use different keys (passed in a header) and the user API can use a separate private key that only the admin/Arrow project developer knows
- The user API will be used for creating users/keys as well for authentication during access. It can also be used for analytics, rate limiting, etc…
Blog post notes:
- reference Q&A posts from Fokke and Jeff on Auth Scheme
API’s:
User API’s are for admins only and require the adminsecret (from default.js) to be passed in header admin-secret
GET /api/users - get all users
POST /api/users - create a user. Provide only the username. Other fields will be auto populated, in particular an API Key. Will return the id of the user record
GET /api/users/:id - get user by id (and get key)
DELETE /api/users/:id - delete user by id
DELETE /api/users - delete all users
examples:
curl -is "http://127.0.0.1:8080/api/users" -H "admin-secret:adminsecret"
curl -is -X POST "http://127.0.0.1:8080/api/users" -d '{"username":"user1"}' -H "Content-Type: application/json" -H "admin-secret:adminsecret"
curl -is "http://127.0.0.1:8080/api/users/557b3bde1b40070b8900321f" -H "admin-secret:adminsecret"
Database API is an example API for users and requires an API Key that is unique to each user.
This key is created by the Arrow app during the user creation.
Pass it in the x-secret header on each API call. Each call to the database API will increment the user count.
This is an example of how you can track calls per user, do rate limiting (with more code, etc…).
examples:
curl "http://127.0.0.1:8080/api/database" -H "x-secret:nBT6G7XSJpE2guLEaDu3QKcasj5ejFnK"
curl "http://127.0.0.1:8080/api/database/5579d44d730b8233ab0f97b5" -H "x-secret:nBT6G7XSJpE2guLEaDu3QKcasj5ejFnK"
curl -is -X POST "http://127.0.0.1:8080/api/database" -d '{"fname":"John","lname":"Doe","title":"VP"}' -H "Content-Type: application/json" -H "x-secret:nBT6G7XSJpE2guLEaDu3QKcasj5ejFnK"