EventHub
EventHub is Northwestern’s enterprise messaging platform, combining an Amazon MQ (Apache ActiveMQ) message broker with a RESTful Messaging Center API. Applications communicate through topics (one-to-many message distribution), queues (per-consumer message storage), and webhooks (automated HTTP delivery).
EventHub supports many event types across Northwestern: identity lifecycle changes, student record updates, employee data changes, and custom application events. Access to specific topics is managed through the API Service Registry.
The starter includes a webhook endpoint that listens for NetID status changes from the etidentity.ldap.netid.term topic (deactivation, deprovisioning, and security holds) and adjusts user access in response.
The EventHub integration is provided by the northwestern-sysdev/laravel-soa package, which handles webhook route registration, HMAC signature verification, and queue integration.
How It Works
Section titled “How It Works”-
EventHub sends a webhook
When a NetID is deactivated, deprovisioned, or placed on security hold, Northwestern’s EventHub pushes a signed HTTP POST to the application’s webhook endpoint.
-
HMAC verification
The
eventhub_hmacmiddleware validates theX-HMAC-Signatureheader against the shared secret, rejecting tampered or unsigned requests. -
Payload parsing
NetIdUpdateControllerreads the URL-encoded body (netid=abc123&action=deactivate) and constructs aNetIdUpdatedevent object, which validates the action against known values. -
User lookup
The controller checks if the NetID belongs to an SSO user. Non-SSO users (local auth, API users) are ignored since their accounts are managed independently.
-
Asynchronous processing
The
NetIdUpdatedevent is dispatched, andProcessNetIdUpdatehandles it on the queue:- All roles except
Northwestern Userare removed - The user is marked as
netid_inactive = true
- All roles except
Customizing Deprovisioning Logic
Section titled “Customizing Deprovisioning Logic”The ProcessNetIdUpdate listener handles the default deprovisioning behavior (role removal and marking the NetID inactive) inside a database transaction. To add your own business logic, revoking API tokens, sending notifications, archiving data, etc., edit the transaction block in the listener:
DB::transaction(static function () use ($event) { $user = User::query() ->sso() ->lockForUpdate() ->with('roles') ->firstWhere('username', $event->netId);
if (! $user) { return; }
$user->roles ->reject(fn (Role $role) => $role->name === SystemRole::NorthwesternUser->value) ->whenNotEmpty(fn ($roles) => $user->removeRoleWithAudit( roles: $roles->all(), origin: RoleModificationOrigin::NetIdStatusChange, context: ['netid_action' => $event->action->value] ));
$user->update(['netid_inactive' => true]);
// Add custom deprovisioning logic here, if needed});Enabling the Webhook
Section titled “Enabling the Webhook”The EventHub webhook route is commented out by default in routes/api.php. To enable it:
Route::middleware(['eventhub_hmac'])->prefix('eventhub')->group(function () { Route::post('netid-update', NetIdUpdateController::class) ->eventHubWebhook('etidentity.ldap.netid.term') ->name('netid-update');});The ->eventHubWebhook() macro registers the route with EventHub’s webhook discovery system and associates it with the etidentity.ldap.netid.term topic. The eventhub_hmac middleware ensures all incoming requests carry a valid HMAC signature.
Testing
Section titled “Testing”The MocksEventHub trait allows you to send synthetic webhook payloads through the HTTP kernel with valid HMAC signatures in tests and Artisan commands:
use App\Domains\Core\Concerns\MocksEventHub;
class MyTest extends TestCase{ use MocksEventHub;
public function test_handles_netid_deactivation(): void { $user = User::factory()->create([ 'username' => 'abc123', 'auth_type' => AuthType::SSO, ]);
$this->send( queue: 'etidentity.ldap.netid.term', message: 'netid=abc123&action=deactivate', );
$user->refresh(); $this->assertTrue($user->netid_inactive); }}The trait reads HMAC configuration from config/nusoa.php to generate the correct signature header, matching the verification the eventhub_hmac middleware performs.
Environment Variables
Section titled “Environment Variables”EVENT_HUB_BASE_URL Required EventHub API base URL
EVENT_HUB_API_KEY Required Apigee API key for EventHub
EVENT_HUB_HMAC_VERIFICATION_HEADER X-HMAC-Signature HTTP header containing the HMAC signature
EVENT_HUB_HMAC_VERIFICATION_ALGORITHM_TYPE_REGISTRATION HmacSHA256 Algorithm name sent to EventHub during registration
EVENT_HUB_HMAC_VERIFICATION_ALGORITHM_TYPE_PHP sha256 PHP hash_hmac algorithm name
EVENT_HUB_MOCK_ENABLED true (local) Enable mock mode for local development