Skip to content

Webhook Authenticator #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Auth/NullAuthenticator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Workflow\Auth;

use Illuminate\Http\Request;

class NullAuthenticator implements WebhookAuthenticator
{
public function validate(Request $request): bool
{
return true;
}
}
18 changes: 18 additions & 0 deletions src/Auth/SignatureAuthenticator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Workflow\Auth;

use Illuminate\Http\Request;

class SignatureAuthenticator implements WebhookAuthenticator
{
public function validate(Request $request): bool
{
return hash_equals(
$request->header(config('workflows.webhook_auth.signature.header')) ?? '',
hash_hmac('sha256', $request->getContent(), config('workflows.webhook_auth.signature.secret'))
);
}
}
17 changes: 17 additions & 0 deletions src/Auth/TokenAuthenticator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Workflow\Auth;

use Illuminate\Http\Request;

class TokenAuthenticator implements WebhookAuthenticator
{
public function validate(Request $request): bool
{
return $request->header(config('workflows.webhook_auth.token.header')) === config(
'workflows.webhook_auth.token.token'
);
}
}
12 changes: 12 additions & 0 deletions src/Auth/WebhookAuthenticator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Workflow\Auth;

use Illuminate\Http\Request;

interface WebhookAuthenticator
{
public function validate(Request $request): bool;
}
37 changes: 0 additions & 37 deletions src/Listeners/MonitorActivityCompleted.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/Listeners/MonitorActivityFailed.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/Listeners/MonitorActivityStarted.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/Listeners/MonitorWorkflowCompleted.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/Listeners/MonitorWorkflowFailed.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/Listeners/MonitorWorkflowStarted.php

This file was deleted.

27 changes: 0 additions & 27 deletions src/Providers/WorkflowServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,10 @@
namespace Workflow\Providers;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Laravel\SerializableClosure\SerializableClosure;
use Workflow\Commands\ActivityMakeCommand;
use Workflow\Commands\WorkflowMakeCommand;
use Workflow\Events\ActivityCompleted;
use Workflow\Events\ActivityFailed;
use Workflow\Events\ActivityStarted;
use Workflow\Events\WorkflowCompleted;
use Workflow\Events\WorkflowFailed;
use Workflow\Events\WorkflowStarted;
use Workflow\Listeners\MonitorActivityCompleted;
use Workflow\Listeners\MonitorActivityFailed;
use Workflow\Listeners\MonitorActivityStarted;
use Workflow\Listeners\MonitorWorkflowCompleted;
use Workflow\Listeners\MonitorWorkflowFailed;
use Workflow\Listeners\MonitorWorkflowStarted;

final class WorkflowServiceProvider extends ServiceProvider
{
Expand All @@ -33,15 +20,6 @@ class_alias(config('workflows.base_model', Model::class), 'Workflow\Models\Model

SerializableClosure::setSecretKey(config('app.key'));

if (config('workflows.monitor', false)) {
Event::listen(WorkflowStarted::class, [MonitorWorkflowStarted::class, 'handle']);
Event::listen(WorkflowCompleted::class, [MonitorWorkflowCompleted::class, 'handle']);
Event::listen(WorkflowFailed::class, [MonitorWorkflowFailed::class, 'handle']);
Event::listen(ActivityStarted::class, [MonitorActivityStarted::class, 'handle']);
Event::listen(ActivityCompleted::class, [MonitorActivityCompleted::class, 'handle']);
Event::listen(ActivityFailed::class, [MonitorActivityFailed::class, 'handle']);
}

$this->publishes([
__DIR__ . '/../config/workflows.php' => config_path('workflows.php'),
], 'config');
Expand All @@ -52,9 +30,4 @@ class_alias(config('workflows.base_model', Model::class), 'Workflow\Models\Model

$this->commands([ActivityMakeCommand::class, WorkflowMakeCommand::class]);
}

public function register(): void
{
//
}
}
20 changes: 0 additions & 20 deletions src/Traits/FetchesMonitorAuth.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Traits/MonitorQueueConnection.php

This file was deleted.

Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy