Nexus API Reference

HandshakeGate
in package

Read onlyYes
FinalYes
Tags
psalm-api

Pre-upgrade authorization gate for WebSocket connections.

Runs the WebSocket route's PSR-15 middleware pipeline (global WS middleware first, then per-route middleware) against the HTTP upgrade request BEFORE the 101 protocol switch. The same middleware used on HTTP routes works unchanged: the gate stamps _nexus.routed and _resolvedHandlerClass exactly like RouterMiddleware does, so AuthenticationMiddleware resolves the principal and AuthorizationMiddleware enforces #[RequiresAuth] / #[RequiresScope] / #[RequiresRole] attributes declared on the WebSocket handler or channel-actor class.

A pipeline that completes yields the authorized upgrade request — including the principal attribute — which the server passes to dispatchOpen so #[FromPrincipal] parameters resolve after the upgrade. A pipeline that short-circuits (401/403/...) yields a rejection response the server must send instead of upgrading. Unmatched paths are rejected with 404 before any upgrade happens.

Table of Contents

Methods

__construct()  : mixed
evaluate()  : HandshakeResult

Methods

__construct()

public __construct(WebSocketRouter $router, array<int, MiddlewareInterface|MiddlewareInterface>$globalMiddleware, MiddlewareResolver $resolver[, LoggerInterface|null $logger = null ]) : mixed
Parameters
$router : WebSocketRouter
$globalMiddleware : array<int, MiddlewareInterface|MiddlewareInterface>>
$resolver : MiddlewareResolver
$logger : LoggerInterface|null = null
On this page

Search results