Class BusWebSocketConfigurator
BusWebSockets.register(jakarta.servlet.ServletContext, org.apache.juneau.console.bus.ServerBus) installs it.
checkOrigin(String): runs before any upgrade, and a refusal is the container's403. Under aLoopbackBoundaryorallowedOriginsit is an exact match. Under aCsrfBoundaryit can only see theOriginvalue, so it refuses a missing value,null, and anything that is not a well-formed http(s) origin; a well-formed cross-site value passes it and is refused by the next step.modifyHandshake(jakarta.websocket.server.ServerEndpointConfig, jakarta.websocket.server.HandshakeRequest, jakarta.websocket.HandshakeResponse): under aLoopbackBoundary, Host against the boundary's authority; under aCsrfBoundary,CsrfBoundary.checkHandshake(String, HandshakeHosts, Map)with the scheme of the handshake's request URI and its headers (sotrusted forwarding, when set, sees the forwarded headers). Over HTTP/2 (RFC 8441), where the handshake has noHost,Sec-WebSocket-KeyorUpgrade, the request URI's authority stands in forHost(HandshakeHosts). OtherwiseSec-Fetch-Site(when present) must besame-origin. Last, the capability and principal. A failure is recorded in the per-connection user properties, andBusWebSocketEndpoint.onOpen(jakarta.websocket.Session, jakarta.websocket.EndpointConfig)closes at once with4403(bus:refused) or4401(bus:unknown-session).
The session id is read from the request path only. It is never logged.
The refusal and session are stored in the user-properties map of the handshake, which relies on the container giving each handshake its own copy of that map (WebSocket 2.1 and later; Jetty and Tomcat do). A container that shares one map across handshakes would mix up concurrent connections.
With trustedProxies set, the handshake's peer is read from the
Jetty user property jakarta.websocket.endpoint.remoteAddress. Jakarta WebSocket has no standard peer
address; a container that records none (Tomcat) leaves the peer unknown, and an unknown peer is not trusted, so a
handshake that carries a forwarded host is refused there. The property is believable only because Jetty writes it
into the per-handshake copy of the user properties; a container that copied client input into it would break that.
Trusted forwarding selects a hop by counting entries from the right, which relies on the container returning the repeated lines of a forwarded header in the order they arrived on the wire. Jetty and Tomcat both do. A container that reorders them would select the wrong hop.
Example:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleancheckOrigin(String originHeaderValue) <T> TgetEndpointInstance(Class<T> endpointClass) voidmodifyHandshake(jakarta.websocket.server.ServerEndpointConfig sec, jakarta.websocket.server.HandshakeRequest request, jakarta.websocket.HandshakeResponse response) Methods inherited from class jakarta.websocket.server.ServerEndpointConfig.Configurator
getContainerDefaultConfigurator, getNegotiatedExtensions, getNegotiatedSubprotocol
-
Method Details
-
checkOrigin
- Overrides:
checkOriginin classjakarta.websocket.server.ServerEndpointConfig.Configurator
-
modifyHandshake
public void modifyHandshake(jakarta.websocket.server.ServerEndpointConfig sec, jakarta.websocket.server.HandshakeRequest request, jakarta.websocket.HandshakeResponse response) - Overrides:
modifyHandshakein classjakarta.websocket.server.ServerEndpointConfig.Configurator
-
getEndpointInstance
- Overrides:
getEndpointInstancein classjakarta.websocket.server.ServerEndpointConfig.Configurator- Throws:
InstantiationException
-