PHP 클래스 RKA\Middleware\IpAddress

파일 보기 프로젝트 열기: akrabat/rka-ip-address-middleware

보호된 프로퍼티들

프로퍼티 타입 설명
$attributeName string Name of the attribute added to the ServerRequest object
$checkProxyHeaders boolean Defaults to false as only $_SERVER['REMOTE_ADDR'] is a trustworthy source of IP address.
$headersToInspect array List of proxy headers inspected for the client IP address
$trustedProxies array If not empty, then one of these IP addresses must be in $_SERVER['REMOTE_ADDR'] in order for the proxy headers to be looked at.

공개 메소드들

메소드 설명
__construct ( boolean $checkProxyHeaders = false, array $trustedProxies = [], string $attributeName = null, array $headersToInspect = [] ) Constructor
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Set the "$attributeName" attribute to the client's IP address as determined from the proxy header (X-Forwarded-For or from $_SERVER['REMOTE_ADDR']

보호된 메소드들

메소드 설명
determineClientIpAddress ( Psr\Http\Message\ServerRequestInterface $request ) : string Find out the client's IP address from the headers available to us
isValidIpAddress ( string $ip ) : boolean Check that a given string is a valid IP address

비공개 메소드들

메소드 설명
getFirstIpAddressFromHeader ( Psr\Http\Message\ServerRequestInterface $request, string $header ) : string Find out the client's IP address from the headers available to us

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( boolean $checkProxyHeaders = false, array $trustedProxies = [], string $attributeName = null, array $headersToInspect = [] )
$checkProxyHeaders boolean Whether to use proxy headers to determine client IP
$trustedProxies array List of IP addresses of trusted proxies
$attributeName string Name of attribute added to ServerRequest object
$headersToInspect array List of headers to inspect

__invoke() 공개 메소드

Set the "$attributeName" attribute to the client's IP address as determined from the proxy header (X-Forwarded-For or from $_SERVER['REMOTE_ADDR']
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface PSR7 request
$response Psr\Http\Message\ResponseInterface PSR7 response
$next callable Next middleware
리턴 Psr\Http\Message\ResponseInterface

determineClientIpAddress() 보호된 메소드

Find out the client's IP address from the headers available to us
protected determineClientIpAddress ( Psr\Http\Message\ServerRequestInterface $request ) : string
$request Psr\Http\Message\ServerRequestInterface PSR-7 Request
리턴 string

isValidIpAddress() 보호된 메소드

Check that a given string is a valid IP address
protected isValidIpAddress ( string $ip ) : boolean
$ip string
리턴 boolean

프로퍼티 상세

$attributeName 보호되어 있는 프로퍼티

Name of the attribute added to the ServerRequest object
protected string $attributeName
리턴 string

$checkProxyHeaders 보호되어 있는 프로퍼티

Defaults to false as only $_SERVER['REMOTE_ADDR'] is a trustworthy source of IP address.
protected bool $checkProxyHeaders
리턴 boolean

$headersToInspect 보호되어 있는 프로퍼티

List of proxy headers inspected for the client IP address
protected array $headersToInspect
리턴 array

$trustedProxies 보호되어 있는 프로퍼티

If not empty, then one of these IP addresses must be in $_SERVER['REMOTE_ADDR'] in order for the proxy headers to be looked at.
protected array $trustedProxies
리턴 array