Webhooks are a great way to integrate all sorts of apps in an easy way. KeyHub pushes all events that take place via webhooks, enabling you to link KeyHub to your favourite tools with little effort. Webhooks pave the way to make your organisation even more aware of security. How about connecting KeyHub to Slack to give your team insights in authorisation events? This blog shows exactly that use case to demonstrate the use of KeyHub webhooks.
Connect KeyHub with Slack using Zapier
Of course you can write your own scripts to consume webhooks of KeyHub. But to get you started we show you a simple way to connect KeyHub to tons of apps by using Zapier. In this example we’ll send a message to a Slack channel whenever someone accesses a high profile server.
1. Make a Zap that connects to KeyHub
Start by making a Zap in Zapier. In step 1 of your Zap, choose “Webhooks by Zapier”:
Choose the trigger event “Catch Hook” and click Continue:
Now Zapier generates a Custome Webhook URL for you to receive the messages of KeyHub. Copy this URL. For this example you don’t need to set anything else in this step.
Now open KeyHub in another tab of your browser. You need to have KeyHub admin rights for this step. Go to Administration -> Groups. Select the Group of which you want to receive events. Now go to the tab Webhooks and click Add:
Now you need to configure the connection from the KeyHub end. Paste the url and set “Trusted certificate” to “No certificate / Use the OS truststore”. Leave the TLS setting to “Yes” and “Authentication scheme” to “None”:
Now select the event that you want Zapier to consume. It is possible to push all events, but for this example we select “Choose specific events” and under provisioning select “Group for account enabled on linked system“:
Now click “Save”.
2. Test the connection
Now go back to Zapier and click “Test & Review”:
Now go back to KeyHub to push your first webhook. Just go to the Dashboard and activate the group that you just configured to push webhooks:
Go back to Zapier to see if your Zap received the push. You might see a screen in Zapier saying “We couldn’t find a request“, because Zapier only waits a few seconds for the test. If this happens just click “Test trigger” and Zapier will look again and pick up the event you just sent. You end up with a message “We found a request!” and the content of the webhook message is shown:
3. Add a Slack message to your Zap
Now KeyHub is connected to Zap, let’s tell Zap what to do with the messages. In the “Do this step” of your Zap add Slack:
As Action Event choose: “Send Channel Message”:
Choose the Slack channel you want to send messages to whenever the Group is activated. And compose the message that you want to send when that happens. In the message text you can use the fields that are contained in the KeyHub-message. For this example we use the account name of the person that activated the group:
Now turn the Zap by clicking the toggle at the bottom of the screen:
4. See it in action
Open Slack and go to the channel. You now receive messages whenever someone uses the group to access the high profile resource:
In this example a message is sent to Slack every time a specific group is activated. And it took not one line of code! But of course if you want to create a more advanced script you can use your favourite language to do that. And if you want to push all events instead of events of a single group: you can set that up through Administration -> Settings -> Webhooks.
Have fun connecting apps to KeyHub! Let us know what you created.