mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Add WebHook connection callback
This commit is contained in:
31
app/Client/Callbacks/WebHookConnectionCallback.php
Normal file
31
app/Client/Callbacks/WebHookConnectionCallback.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Client\Callbacks;
|
||||
|
||||
use App\Server\Connections\ControlConnection;
|
||||
use Clue\React\Buzz\Browser;
|
||||
|
||||
class WebHookConnectionCallback
|
||||
{
|
||||
/** @var Browser */
|
||||
protected $browser;
|
||||
|
||||
public function __construct(Browser $browser)
|
||||
{
|
||||
$this->browser = $browser;
|
||||
}
|
||||
|
||||
public function handle(ControlConnection $connection)
|
||||
{
|
||||
$this->browser->post(config('expose.admin.connection_callbacks.webhook.url'), [
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
'X-Signature' => $this->generateWebhookSigningSecret($connection),
|
||||
], json_encode($connection->toArray()));
|
||||
}
|
||||
|
||||
protected function generateWebhookSigningSecret(ControlConnection $connection)
|
||||
{
|
||||
return hash_hmac('sha256', $connection->client_id, config('expose.admin.connection_callbacks.webhook.secret'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user