mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 13:09:44 +05:30
Merge pull request #370 from michaelhogg/fix-bug-hmac-encoding
Fix bug: hash_hmac() should output raw binary data, not hexits
This commit is contained in:
commit
c3457107ee
@ -118,7 +118,14 @@ class MAC extends AbstractTokenType implements TokenTypeInterface
|
||||
$calculatedSignatureParts[] = $params->get('ext');
|
||||
}
|
||||
|
||||
$calculatedSignature = base64_encode(hash_hmac('sha256', implode("\n", $calculatedSignatureParts), $macKey));
|
||||
$calculatedSignature = base64_encode(
|
||||
hash_hmac(
|
||||
'sha256',
|
||||
implode("\n", $calculatedSignatureParts),
|
||||
$macKey,
|
||||
true // raw_output: outputs raw binary data
|
||||
)
|
||||
);
|
||||
|
||||
// Return the access token if the signature matches
|
||||
return ($this->hash_equals($calculatedSignature, $signature)) ? $accessToken : null;
|
||||
|
@ -57,7 +57,7 @@ class MacTest extends \PHPUnit_Framework_TestCase
|
||||
$request->getPort(),
|
||||
'ext'
|
||||
];
|
||||
$calculatedSignature = base64_encode(hash_hmac('sha256', implode("\n", $calculatedSignatureParts), 'abcdef'));
|
||||
$calculatedSignature = base64_encode(hash_hmac('sha256', implode("\n", $calculatedSignatureParts), 'abcdef', true));
|
||||
|
||||
$request->headers->set('Authorization', sprintf('MAC id="foo", nonce="foo", ts="%s", mac="%s", ext="ext"', $ts, $calculatedSignature));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user