diff --git a/composer.lock b/composer.lock index 18b6801d..2bd0c827 100644 --- a/composer.lock +++ b/composer.lock @@ -1401,16 +1401,16 @@ }, { "name": "symfony/config", - "version": "v3.1.2", + "version": "v3.1.3", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc" + "reference": "a7630397b91be09cdd2fe57fd13612e258700598" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/bcf5aebabc95b56e370e13d78565f74c7d8726dc", - "reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc", + "url": "https://api.github.com/repos/symfony/config/zipball/a7630397b91be09cdd2fe57fd13612e258700598", + "reference": "a7630397b91be09cdd2fe57fd13612e258700598", "shasum": "" }, "require": { @@ -1450,20 +1450,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" + "time": "2016-07-26 08:04:17" }, { "name": "symfony/console", - "version": "v2.8.8", + "version": "v2.8.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c392a6ec72f2122748032c2ad6870420561ffcfa" + "reference": "36e62335caca8a6e909c5c5bac4a8128149911c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c392a6ec72f2122748032c2ad6870420561ffcfa", - "reference": "c392a6ec72f2122748032c2ad6870420561ffcfa", + "url": "https://api.github.com/repos/symfony/console/zipball/36e62335caca8a6e909c5c5bac4a8128149911c9", + "reference": "36e62335caca8a6e909c5c5bac4a8128149911c9", "shasum": "" }, "require": { @@ -1510,20 +1510,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-06-29 07:02:14" + "time": "2016-07-30 07:20:35" }, { "name": "symfony/dependency-injection", - "version": "v3.1.2", + "version": "v3.1.3", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "b7272b65f2f46cbe77def7d33916f2613669c508" + "reference": "6abd4952d07042d11bbb8122f3b57469691acdb5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/b7272b65f2f46cbe77def7d33916f2613669c508", - "reference": "b7272b65f2f46cbe77def7d33916f2613669c508", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6abd4952d07042d11bbb8122f3b57469691acdb5", + "reference": "6abd4952d07042d11bbb8122f3b57469691acdb5", "shasum": "" }, "require": { @@ -1532,7 +1532,7 @@ "require-dev": { "symfony/config": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", - "symfony/yaml": "~2.8|~3.0" + "symfony/yaml": "~2.8.7|~3.0.7|~3.1.1|~3.2" }, "suggest": { "symfony/config": "", @@ -1570,20 +1570,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:42:25" + "time": "2016-07-28 11:13:48" }, { "name": "symfony/filesystem", - "version": "v3.1.2", + "version": "v3.1.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890" + "reference": "bb29adceb552d202b6416ede373529338136e84f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/322da5f0910d8aa0b25fa65ffccaba68dbddb890", - "reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/bb29adceb552d202b6416ede373529338136e84f", + "reference": "bb29adceb552d202b6416ede373529338136e84f", "shasum": "" }, "require": { @@ -1619,7 +1619,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" + "time": "2016-07-20 05:44:26" }, { "name": "symfony/polyfill-mbstring", @@ -1682,16 +1682,16 @@ }, { "name": "symfony/yaml", - "version": "v3.1.2", + "version": "v3.1.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de" + "reference": "1819adf2066880c7967df7180f4f662b6f0567ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de", - "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de", + "url": "https://api.github.com/repos/symfony/yaml/zipball/1819adf2066880c7967df7180f4f662b6f0567ac", + "reference": "1819adf2066880c7967df7180f4f662b6f0567ac", "shasum": "" }, "require": { @@ -1727,32 +1727,33 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" + "time": "2016-07-17 14:02:08" }, { "name": "webmozart/assert", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde" + "reference": "bb2d123231c095735130cc8f6d31385a44c7b308" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bb2d123231c095735130cc8f6d31385a44c7b308", + "reference": "bb2d123231c095735130cc8f6d31385a44c7b308", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3|^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -1776,7 +1777,7 @@ "check", "validate" ], - "time": "2015-08-24 13:29:44" + "time": "2016-08-09 15:02:57" } ], "aliases": [], diff --git a/src/Signer/Ecdsa/KeyParser.php b/src/Signer/Ecdsa/KeyParser.php index 167939b1..f18952df 100644 --- a/src/Signer/Ecdsa/KeyParser.php +++ b/src/Signer/Ecdsa/KeyParser.php @@ -88,7 +88,7 @@ private function getKeyContent(Key $key, $header) $match = null; preg_match( - '/^[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}$/', + '/[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}/', str_replace([PHP_EOL, "\n", "\r"], '', $key->getContent()), $match ); diff --git a/test/functional/EcdsaTokenTest.php b/test/functional/EcdsaTokenTest.php index dee2bdcd..1e20f813 100644 --- a/test/functional/EcdsaTokenTest.php +++ b/test/functional/EcdsaTokenTest.php @@ -249,6 +249,36 @@ public function verifyShouldReturnTrueWhenKeyIsRight(Token $token) $this->assertTrue($token->verify($this->signer, static::$ecdsaKeys['public1'])); } + /** + * @test + * + * @covers Lcobucci\JWT\Builder + * @covers Lcobucci\JWT\Token + * @covers Lcobucci\JWT\Signature + * @covers Lcobucci\JWT\Claim\Factory + * @covers Lcobucci\JWT\Claim\Basic + * @covers Lcobucci\JWT\Parsing\Encoder + * @covers Lcobucci\JWT\Signer\Key + * @covers Lcobucci\JWT\Signer\BaseSigner + * @covers Lcobucci\JWT\Signer\Ecdsa + * @covers Lcobucci\JWT\Signer\Ecdsa\KeyParser + * @covers Lcobucci\JWT\Signer\Ecdsa\Sha256 + */ + public function everythingShouldWorkWithAKeyWithParams() + { + $user = (object) ['name' => 'testing', 'email' => 'testing@abc.com']; + + $token = (new Builder())->setId(1) + ->setAudience('http://client.abc.com') + ->setIssuer('http://api.abc.com') + ->set('user', $user) + ->setHeader('jki', '1234') + ->sign($this->signer, static::$ecdsaKeys['private-params']) + ->getToken(); + + $this->assertTrue($token->verify($this->signer, static::$ecdsaKeys['public-params'])); + } + /** * @test * diff --git a/test/functional/Keys.php b/test/functional/Keys.php index 583801a8..f3a83d2c 100644 --- a/test/functional/Keys.php +++ b/test/functional/Keys.php @@ -44,8 +44,10 @@ public static function createEcdsaKeys() static::$ecdsaKeys = [ 'private' => $keychain->getPrivateKey($dir . '/ecdsa/private.key'), + 'private-params' => $keychain->getPrivateKey($dir . '/ecdsa/private2.key'), 'public1' => $keychain->getPublicKey($dir . '/ecdsa/public1.key'), 'public2' => $keychain->getPublicKey($dir . '/ecdsa/public2.key'), + 'public-params' => $keychain->getPublicKey($dir . '/ecdsa/public3.key'), ]; } } diff --git a/test/functional/ecdsa/private2.key b/test/functional/ecdsa/private2.key new file mode 100644 index 00000000..7c4e1316 --- /dev/null +++ b/test/functional/ecdsa/private2.key @@ -0,0 +1,8 @@ +-----BEGIN EC PARAMETERS----- +BggqhkjOPQMBBw== +-----END EC PARAMETERS----- +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIM6G7WZ6SqoPwrHwGXhOJkYD+ErT8dfRvrNifgBQvSb7oAoGCCqGSM49 +AwEHoUQDQgAE09Hkp/u0tIGdzlQ99R/sXCOr9DTZAfLex4D4Po0C1L3qUqHrzZ0m +B3bAhe+pwEDQ/jqVqdzxhA9i4PqT7F4Aew== +-----END EC PRIVATE KEY----- diff --git a/test/functional/ecdsa/public3.key b/test/functional/ecdsa/public3.key new file mode 100644 index 00000000..3bf5cd79 --- /dev/null +++ b/test/functional/ecdsa/public3.key @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE09Hkp/u0tIGdzlQ99R/sXCOr9DTZ +AfLex4D4Po0C1L3qUqHrzZ0mB3bAhe+pwEDQ/jqVqdzxhA9i4PqT7F4Aew== +-----END PUBLIC KEY-----