PHP Class Spatie\UrlSigner\BaseUrlSigner

Inheritance: implements Spatie\UrlSigner\UrlSigner
显示文件 Open project: spatie/url-signer

Protected Properties

Property Type Description
$expiresParameter string The URL's query parameter name for the expiration.
$signatureKey string The key that is used to generate secure signatures.
$signatureParameter string The URL's query parameter name for the signature.

Public Methods

Method Description
__construct ( string $signatureKey, string $expiresParameter = 'expires', string $signatureParameter = 'signature' )
sign ( string $url, DateTime | integer $expiration ) : string Get a secure URL to a controller action.
validate ( string $url ) : boolean Validate a signed url.

Protected Methods

Method Description
getExpirationTimestamp ( DateTime | integer $expiration ) : string Retrieve the expiration timestamp for a link based on an absolute DateTime or a relative number of days.
getIntendedUrl ( League\Url\UrlImmutable $url ) : League\Url\UrlImmutable Retrieve the intended URL by stripping off the UrlSigner specific parameters.
hasValidSignature ( League\Url\UrlImmutable $url ) : boolean Determine if the url has a forged signature.
isFuture ( integer $timestamp ) : boolean Check if an a timestamp is in the past.
isMissingAQueryParameter ( League\Url\Components\QueryInterface $query ) : boolean Check if a query is missing a necessary parameter.
signUrl ( League\Url\UrlImmutable $url, string $expiration, string $signature ) : League\Url\UrlImmutable Add expiration and signature query parameters to an url.

Method Details

__construct() public method

public __construct ( string $signatureKey, string $expiresParameter = 'expires', string $signatureParameter = 'signature' )
$signatureKey string
$expiresParameter string
$signatureParameter string

getExpirationTimestamp() protected method

Retrieve the expiration timestamp for a link based on an absolute DateTime or a relative number of days.
protected getExpirationTimestamp ( DateTime | integer $expiration ) : string
$expiration DateTime | integer The expiration date of this link. - DateTime: The value will be used as expiration date - int: The expiration time will be set to X days from now
return string

getIntendedUrl() protected method

Retrieve the intended URL by stripping off the UrlSigner specific parameters.
protected getIntendedUrl ( League\Url\UrlImmutable $url ) : League\Url\UrlImmutable
$url League\Url\UrlImmutable
return League\Url\UrlImmutable

hasValidSignature() protected method

Determine if the url has a forged signature.
protected hasValidSignature ( League\Url\UrlImmutable $url ) : boolean
$url League\Url\UrlImmutable
return boolean

isFuture() protected method

Check if an a timestamp is in the past.
protected isFuture ( integer $timestamp ) : boolean
$timestamp integer
return boolean

isMissingAQueryParameter() protected method

Check if a query is missing a necessary parameter.
protected isMissingAQueryParameter ( League\Url\Components\QueryInterface $query ) : boolean
$query League\Url\Components\QueryInterface
return boolean

sign() public method

Get a secure URL to a controller action.
public sign ( string $url, DateTime | integer $expiration ) : string
$url string
$expiration DateTime | integer
return string

signUrl() protected method

Add expiration and signature query parameters to an url.
protected signUrl ( League\Url\UrlImmutable $url, string $expiration, string $signature ) : League\Url\UrlImmutable
$url League\Url\UrlImmutable
$expiration string
$signature string
return League\Url\UrlImmutable

validate() public method

Validate a signed url.
public validate ( string $url ) : boolean
$url string
return boolean

Property Details

$expiresParameter protected_oe property

The URL's query parameter name for the expiration.
protected string $expiresParameter
return string

$signatureKey protected_oe property

The key that is used to generate secure signatures.
protected string $signatureKey
return string

$signatureParameter protected_oe property

The URL's query parameter name for the signature.
protected string $signatureParameter
return string