TrustedProxiesMiddleware
class TrustedProxiesMiddleware implements MiddlewareInterface (View source)
Middleware that checks request headers against a configured list of trusted proxy IP addresses.
Constants
HEADER_CLIENT_IP |
|
HEADER_HOST |
|
HEADER_PORT |
|
HEADER_PROTOCOL |
|
FOR_PATTERN |
|
PROTO_PATTERN |
|
HOST_PATTERN |
|
Properties
protected array | $settings |
Methods
Injects the configuration settings
No description
No description
No description
Get the values of trusted proxy header.
Convenience getter for the first value of a given trusted proxy header.
Check if the given IP address is from a trusted proxy.
Check if the given request is from a trusted proxy.
Get the most trusted client's IP address.
Details
void
injectSettings(array $settings)
Injects the configuration settings
ResponseInterface
process(ServerRequestInterface $request, RequestHandlerInterface $handler)
No description
protected array
unquoteArray(array $array)
No description
protected array|null
getForwardedHeader(string $type, array $headerValues)
No description
protected Generator<array|null>
getTrustedProxyHeaderValues(string $type, ServerRequestInterface $request)
Get the values of trusted proxy header.
protected mixed|null
getFirstTrustedProxyHeaderValue(string $type, ServerRequestInterface $request)
Convenience getter for the first value of a given trusted proxy header.
protected bool
ipIsTrustedProxy(string $ipAddress)
Check if the given IP address is from a trusted proxy.
protected bool
isFromTrustedProxy(ServerRequestInterface $request)
Check if the given request is from a trusted proxy.
protected string|bool
getTrustedClientIpAddress(ServerRequestInterface $request)
Get the most trusted client's IP address.
This is the right-most address in the trusted client IP header, that is not a trusted proxy address. If all proxies are trusted, this is the left-most address in the header. If no proxies are trusted or no client IP header is trusted, this is the remote address of the machine directly connected to the server.