PHP 클래스 lithium\storage\session\strategy\Hmac
Example configuration:
Session::config(array('default' => array(
'adapter' => 'Cookie',
'strategies' => array('Hmac' => array('secret' => 'foobar'))
)));
This will configure the
HMAC strategy to be used for all
Session operations with the
default named configuration. A hash-based message authentication code (HMAC) will be
calculated for all data stored in your cookies, and will be compared to the signature
stored in your cookie data. If the two do not match, then your data has been tampered with
(or you have modified the data directly _without_ passing through the
Session class, which
amounts to the same), then a catchable
RuntimeException is thrown.
Please note that this strategy is very finnicky, and is so by design. If you attempt to access
or modify the stored data in any way other than through the
Session class configured with the
Hmac strategy with the properly configured
secret, then it will probably blow up.
파일 보기
프로젝트 열기: unionofrad/lithium
보호된 프로퍼티들
공개 메소드들
보호된 메소드들
메소드 상세
public __construct ( array $config = [] ) : void |
$config |
array |
Configuration array. Will throw an exception if the 'secret'
configuration key is not set. |
리턴 |
void |
|
Calculate the HMAC signature based on the data and a secret key.
Validates the HMAC signature of the stored data. If the signatures match, then the data
is safe and will be passed through as-is.
If the stored data being read does not contain a __signature field, a
MissingSignatureException is thrown. When catching this exception, you may choose
to handle it by either writing out a signature (e.g. in cases where you know that no
pre-existing signature may exist), or you can blackhole it as a possible tampering
attempt.
Adds an HMAC signature to the data. Note that this will transform the
passed $data to an array, and add a __signature key with the HMAC-calculated
value.
프로퍼티 상세
$_secret 보호되어 있는 정적으로 프로퍼티
protected static $_secret |