- You have an existing Hasura project, cluster
- You have a microservice running where you can add a webhook
- You have kubectl installed. Check by running:
kubectl get pods -n hasura
which should list all the hasura microservices
Check your platform version:
$ hasura cluster status
Cluster name: altar40
Cluster alias: hasura
Kubectl context: altar40
Platform version: v0.15.31
Cluster state: Synced
If the platform version is below v0.15.34 run the following command to update the platform:
kubectl set image -n hasura deployment/platform-sync shukra=hasuraci/shukra:v0.15.34
Add a webhook to your microservice (you could even use any public endpoint):
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.post('/hook', (req, res) => {
// req.body contains the entire signup/login request payload
console.log(req.body);
// return the roles you'd like to assign
// return content-type: application/json roles array
res.json({roles: ["somerole"]);
});
Add the following block to your conf/auth.yaml
file:
authorizationHooks:
preSignupHook: "http://api.default/hook"
This assumes that you have a microservice called api
running in the default
namespace running a POST
webhook at /hook
.
You can replace this with any HTTP/HTTPS url.
git add conf/auth.yaml microservices/api
git commit -am 'adds hook'
git push hasura master