Download the PHP package sam-it/yii2-urlsigner without Composer
On this page you can find all versions of the php package sam-it/yii2-urlsigner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sam-it/yii2-urlsigner
More information about sam-it/yii2-urlsigner
Files in sam-it/yii2-urlsigner
Package yii2-urlsigner
Short Description Secure URL signing and validation for the Yii2 framework
License MIT
Informations about the package yii2-urlsigner
yii2-urlsigner Secure URL signing and validation.
The goal of this component is to enable stateless but secure URL validation. This can be useful, for example, when doing email validation or password reset.
The idea is simple, consider I want to change my email, the system could send me a link like this:
Of course, this is very insecure, and no one actually (hopefully) does it like this. One solution is to generate a random token:
This is secure, but requires keeping state on the server. This package solves the problem by signing the URL.
This allows us to verify that the URL was actually created by us therefore can be trusted.
Upgrade to v4
The Yii2 component and the actual signer have been split into two separate classes.
In my opinion, you should use the UrlSigner class directly, configuring it using a closure in your DI config.
If you need to use the component with array configuration, you may use the UrlSignerComponent class.
Deprecated function signParams has been removed, use sign instead.
UrlSigner::calculateHMAC() has been deprecated.
Upgrade to v5
In v5 for better static analysis we have removed configuration options. The names for query parameters are now fixed. If you previously customized them you cannot switch to v5 without breaking existing code.
Example
Do not share secrets across hosts
If you use this component in a multi-host application you must make sure each host uses a different secret. The URL signing takes into account the absolute route and all given parameters, anything else is excluded from the signature and from validation. This means that if you have a structure like this:
And they use the same route, for example /user/do-reset, for password resets, a normal user will be able to change the domain without invalidating the signature.
All versions of yii2-urlsigner with dependencies
yiisoft/yii2 Version ^2
psr/clock Version ^1.0
psr/clock-implementation Version *

