2.0.3 • Published 8 years ago
@leisurelink/magicbus-middleware-authentic v2.0.3
Magicbus Authentic Middleware
This is middleware for magicbus. This allows apiKey authentication on the publisher side and authorization on the subscrier side.
How to use
There are two things that need to take place for this middleware to work.
- First, you will need to first add an api key for your endpoint to authentic using authentic.
authentic -H "$host" -K ../authentic-api/test/test-key.pub -k ../authentic-api/test/test-key.pem -u admin -p @ssw0rD add-apikey "$principal" "MyApiKey"
- You will then need to add the
'#/sys/auth'
claim and set it totrue
authentic -H "$host" -K ../authentic-api/test/test-key.pub -k ../authentic-api/test/test-key.pem -u admin -p @ssw0rD set-endpoint-claim "$principal" '#/sys/auth' true
Using with magicbus
Takes two steps 1. import 2. use
For publishers
import { pubMiddleware } from '@leisurelink/magicbus-authentic-middleware';
import AuthenticClient from '@leisurelink/authentic-client';
// Setup magic bus and create your subscriber
let authenticClient = new AuthenticClient(/* params for authentic */);
publisher.use(pubMiddleware(authenticClient));
For subscribers:
import { subMiddleware } from '@leisurelink/magicbus-authentic-middleware';
import AuthenticClient from '@leisurelink/authentic-client';
// Setup magic bus and create your subscriber
let authenticClient = new AuthenticClient(/* params for authentic */);
subscriber.use(subMiddleware(authenticClient));