Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Websocket Server Laravel Package

babdev/websocket-server

View on GitHub
Deep Wiki
Context7

Reject Blocked IP Address Middleware

The BabDev\WebSocket\Server\Http\Middleware\RestrictToAllowedOrigins class is a server middleware which can be used to reject connections based on the Origin header from the HTTP request.

The allowed origin list can be updated at any time, including while the server is running.

Allowing an Origin

To allow a origin, you can use the middleware's allowOrigin() method:

<?php declare(strict_types=1);

use BabDev\WebSocket\Server\Http\Middleware\RestrictToAllowedOrigins;

$middleware = new RestrictToAllowedOrigins($decoratedMiddleware);
$middleware->allowOrigin('babdev.com');

Removing a Previously Allowed Origin

To allow a previously blocked IP address, you can use the middleware's removeAllowedOrigin() method:

<?php declare(strict_types=1);

use BabDev\WebSocket\Server\Http\Middleware\RestrictToAllowedOrigins;

$middleware = new RestrictToAllowedOrigins($decoratedMiddleware);
$middleware->allowOrigin('babdev.com');
$middleware->allowOrigin('github.com');
$middleware->removeAllowedOrigin('github.com');

Position in Middleware Stack

It is recommended that this middleware is decorated by the BabDev\WebSocket\Server\Http\Middleware\ParseHttpRequest middleware in your application (see the message flow section from the architecture documentation to see the recommended stack with all optional middleware), however it can be placed anywhere after the HTTP request has been parsed and does not expect one of the server middleware sub-interfaces.

It is also recommended that this middleware decorates the BabDev\WebSocket\Server\WebSocket\Middleware\EstablishWebSocketConnection middleware, but it can decorate any server middleware.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky