From 41b3c8c853920e5c3d3c30d1680d3baae305f791 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:29:44 +0700 Subject: [PATCH 01/47] Update composer and Test's dependencies --- composer.json | 3 + composer.lock | 1045 ++++++++++++++++++++++++++++++++++++++++++++- tests/JWTTest.php | 5 +- 3 files changed, 1049 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 1a5e93b5..e4dd4f43 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,9 @@ "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "*" + }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" diff --git a/composer.lock b/composer.lock index 5518ae41..7ad0cb8e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,16 +4,1055 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "60a5df5d283a7ae9000173248eba8909", + "hash": "18867f3a3b90fcdf289d47ec125a6b94", "packages": [], - "packages-dev": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "myclabs/deep-copy", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "95d662954e06000cdf63ec9c9f0a6c598d9c5eb9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/95d662954e06000cdf63ec9c9f0a6c598d9c5eb9", + "reference": "95d662954e06000cdf63ec9c9f0a6c598d9c5eb9", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2015-07-19 19:57:13" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62", + "reference": "4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com/" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-09-22 14:49:23" + }, + { + "name": "phpunit/php-code-coverage", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "12259bb1352612df9ec24048714a3bedafe79674" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/12259bb1352612df9ec24048714a3bedafe79674", + "reference": "12259bb1352612df9ec24048714a3bedafe79674", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "^1.3.2", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~5" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-09-24 07:56:07" + }, + { + "name": "phpunit/php-file-iterator", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-06-21 13:08:43" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-21 08:01:12" + }, + { + "name": "phpunit/php-token-stream", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "cab6c6fefee93d7b7c3a01292a0fe0884ea66644" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/cab6c6fefee93d7b7c3a01292a0fe0884ea66644", + "reference": "cab6c6fefee93d7b7c3a01292a0fe0884ea66644", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-09-23 14:46:55" + }, + { + "name": "phpunit/phpunit", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "b3db8bc29009cbd788cd827d7376a5e8018243ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b3db8bc29009cbd788cd827d7376a5e8018243ce", + "reference": "b3db8bc29009cbd788cd827d7376a5e8018243ce", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "myclabs/deep-copy": "~1.3", + "php": ">=7.0", + "phpspec/prophecy": "^1.3.1", + "phpunit/php-code-coverage": "~3.0", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": ">=1.0.6", + "phpunit/phpunit-mock-objects": ">=3.0", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.3", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-09-27 08:37:11" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "4f526b7e2c42cacf32c86e1e0c9ab9d3b24273cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/4f526b7e2c42cacf32c86e1e0c9ab9d3b24273cf", + "reference": "4f526b7e2c42cacf32c86e1e0c9ab9d3b24273cf", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": ">=5.6", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-09-02 07:30:58" + }, + { + "name": "sebastian/comparator", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-07-26 15:48:44" + }, + { + "name": "sebastian/diff", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "6899b3e33bfbd386d88b5eea5f65f563e8793051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/6899b3e33bfbd386d88b5eea5f65f563e8793051", + "reference": "6899b3e33bfbd386d88b5eea5f65f563e8793051", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-06-22 14:15:55" + }, + { + "name": "sebastian/environment", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44", + "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-08-03 06:14:51" + }, + { + "name": "sebastian/exporter", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "f88f8936517d54ae6d589166810877fb2015d0a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f88f8936517d54ae6d589166810877fb2015d0a2", + "reference": "f88f8936517d54ae6d589166810877fb2015d0a2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-08-09 04:23:41" + }, + { + "name": "sebastian/global-state", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23af31f402993cfd94e99cbc4b782e9a78eb0e97", + "reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-06-21 15:11:22" + }, + { + "name": "sebastian/recursion-context", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-06-21 08:04:50" + }, + { + "name": "sebastian/resource-operations", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28 20:34:47" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21 13:59:46" + }, + { + "name": "symfony/yaml", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "b68154f3ee23d8294936433fd31725a83bd02f71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b68154f3ee23d8294936433fd31725a83bd02f71", + "reference": "b68154f3ee23d8294936433fd31725a83bd02f71", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com/", + "time": "2015-09-14 14:15:24" + } + ], "aliases": [], "minimum-stability": "dev", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.2.0" + "php": ">=5.3.0" }, "platform-dev": [] } diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 89de8d28..d01e959b 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,6 +1,9 @@ Date: Mon, 28 Sep 2015 11:34:24 +0700 Subject: [PATCH 02/47] Update travis-ci config --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b1135a16..5369fc8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,19 @@ php: - 5.3 - 5.4 - 5.5 + - 5.6 + - 7 - hhvm sudo: false +install: + - composer self-update + - composer global require "fxp/composer-asset-plugin:1.0.0" + - composer install --prefer-dist --dev + - composer info --installed + before_script: - wget -nc http://getcomposer.org/composer.phar - - php composer.phar install script: phpunit --configuration phpunit.xml.dist From 7ca0d609da30404a41f8d44b2037685ab354fc46 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:37:03 +0700 Subject: [PATCH 03/47] Update travis-ci config --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5369fc8b..6ee7babe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,15 +8,10 @@ php: - 7 - hhvm -sudo: false - install: - composer self-update - composer global require "fxp/composer-asset-plugin:1.0.0" - composer install --prefer-dist --dev - composer info --installed -before_script: - - wget -nc http://getcomposer.org/composer.phar - script: phpunit --configuration phpunit.xml.dist From aa96c13e1b1041b6d8da70fa4232662c20ab8ec4 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:42:01 +0700 Subject: [PATCH 04/47] Update travis-ci config --- .travis.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ee7babe..2613b8d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,14 @@ language: php - php: - - 5.3 - - 5.4 - - 5.5 - 5.6 + - 5.5 + - 5.4 + - 5.3 - 7 - hhvm - install: - composer self-update - composer global require "fxp/composer-asset-plugin:1.0.0" - composer install --prefer-dist --dev - composer info --installed - -script: phpunit --configuration phpunit.xml.dist +script: phpunit -c phpunit.xml \ No newline at end of file From 0f1e80316b2361edf10a52ac4acd0664bc7cdfe8 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:42:24 +0700 Subject: [PATCH 05/47] Add phpunit.xml --- phpunit.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..fac73852 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + + ./tests/ + + + + + + ./ + + ./tests + + + + \ No newline at end of file From fa8ba67c001622d61d178d0d69d80692d7545720 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:45:14 +0700 Subject: [PATCH 06/47] Updat composer.json --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index e4dd4f43..1a5e93b5 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,6 @@ "require": { "php": ">=5.3.0" }, - "require-dev": { - "phpunit/phpunit": "*" - }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" From 0f0cedad3ef9a22d3d9e8cddb79dec6d0a84fb1e Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:48:41 +0700 Subject: [PATCH 07/47] Revert original config --- .travis.yml | 21 +++++++++++---------- tests/JWTTest.php | 5 +---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2613b8d9..b1135a16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,15 @@ language: php + php: - - 5.6 - - 5.5 - - 5.4 - 5.3 - - 7 + - 5.4 + - 5.5 - hhvm -install: - - composer self-update - - composer global require "fxp/composer-asset-plugin:1.0.0" - - composer install --prefer-dist --dev - - composer info --installed -script: phpunit -c phpunit.xml \ No newline at end of file + +sudo: false + +before_script: + - wget -nc http://getcomposer.org/composer.phar + - php composer.phar install + +script: phpunit --configuration phpunit.xml.dist diff --git a/tests/JWTTest.php b/tests/JWTTest.php index d01e959b..89de8d28 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,9 +1,6 @@ Date: Mon, 28 Sep 2015 11:52:02 +0700 Subject: [PATCH 08/47] Revert original config --- phpunit.xml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index fac73852..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - ./tests/ - - - - - - ./ - - ./tests - - - - \ No newline at end of file From f699cca8a715a3fbb86e6cf35df93eee0333f96a Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 11:56:29 +0700 Subject: [PATCH 09/47] Update travis-ci config --- .travis.yml | 21 ++++++++++----------- composer.json | 3 +++ tests/JWTTest.php | 5 ++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1135a16..11f2ba6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,14 @@ language: php - php: - - 5.3 - - 5.4 + - 5.6 - 5.5 + - 5.4 + - 5.3 + - 7 - hhvm - -sudo: false - -before_script: - - wget -nc http://getcomposer.org/composer.phar - - php composer.phar install - -script: phpunit --configuration phpunit.xml.dist +install: + - composer self-update + - composer global require "fxp/composer-asset-plugin:1.0.0" + - composer install --prefer-dist --dev + - composer info --installed +script: phpunit -c phpunit.xml.dist \ No newline at end of file diff --git a/composer.json b/composer.json index 1a5e93b5..e4dd4f43 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,9 @@ "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "*" + }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 89de8d28..d01e959b 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,6 +1,9 @@ Date: Mon, 28 Sep 2015 12:04:16 +0700 Subject: [PATCH 10/47] Update travis-ci config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 11f2ba6c..5e538a4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,6 @@ php: install: - composer self-update - composer global require "fxp/composer-asset-plugin:1.0.0" - - composer install --prefer-dist --dev + - composer update --ignore-platform-reqs - composer info --installed script: phpunit -c phpunit.xml.dist \ No newline at end of file From e848a566401a4fec3fb1f7746a70d7a2e84cf1d6 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 13:06:22 +0700 Subject: [PATCH 11/47] For local unit-test using WAMP --- tests/JWTTest.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index d01e959b..78c7faa9 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -206,14 +206,24 @@ public function testEmptyKeyFails() public function testRSEncodeDecode() { - $privKey = openssl_pkey_new(array('digest_alg' => 'sha256', - 'private_key_bits' => 1024, + $privKey = openssl_pkey_new(array( + 'config'=>'C:/wamp/bin/apache/Apache2.4.4/conf/openssl.cnf', + 'digest_alg' => 'sha512', + 'private_key_bits' => 4096, 'private_key_type' => OPENSSL_KEYTYPE_RSA)); - $msg = JWT::encode('abc', $privKey, 'RS256'); - $pubKey = openssl_pkey_get_details($privKey); - $pubKey = $pubKey['key']; - $decoded = JWT::decode($msg, $pubKey, array('RS256')); - $this->assertEquals($decoded, 'abc'); + if($privKey === false) + { + $s = openssl_error_string(); + $this->fail("Cannot create private key: $s"); + } + else + { + $msg = JWT::encode('abc', $privKey, 'RS256'); + $pubKey = openssl_pkey_get_details($privKey); + $pubKey = $pubKey['key']; + $decoded = JWT::decode($msg, $pubKey, array('RS256')); + $this->assertEquals($decoded, 'abc'); + } } public function testKIDChooser() From 0909aa13778c237d11aaebc48f4c6ffb9751c8f4 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 21:07:56 +0700 Subject: [PATCH 12/47] Add JWK support --- .gitignore | 1 + composer.json | 5 ++ src/JWK.php | 155 ++++++++++++++++++++++++++++++++++++++++++++++ tests/JWTTest.php | 16 ++++- 4 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 src/JWK.php diff --git a/.gitignore b/.gitignore index 7c29c87b..b1a05b0b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor phpunit.phar phpunit.phar.asc composer.phar +.idea diff --git a/composer.json b/composer.json index e4dd4f43..80301266 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,11 @@ "name": "Anant Narayanan", "email": "anant@php.net", "role": "Developer" + }, + { + "name": "Bui Sy Nguyen", + "email": "nguyenbs@gmail.com", + "role": "Developer" } ], "license": "BSD-3-Clause", diff --git a/src/JWK.php b/src/JWK.php new file mode 100644 index 00000000..fbdad00a --- /dev/null +++ b/src/JWK.php @@ -0,0 +1,155 @@ + + * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD + * @link https://github.com/fproject/php-jwt + */ +class JWK +{ + /** + * Parse a set of JWK keys + * @param $source + * @return array an associative array represents the set of keys + */ + public static function parseKeySet($source) + { + $keys = []; + if(is_string($source)) + { + $source = json_decode($source, true); + } + else if(is_object($source)) + { + if(property_exists($source, 'keys')) + $source = (array)$source; + else + $source = [$source]; + } + + if(isset($source['keys'])) + $source = $source['keys']; + + foreach($source as $k=>$v) + { + if(!is_string($k)) + { + if(is_array($v) && isset($v['kid'])) + $k = $v['kid']; + elseif(is_object($v) && property_exists($v,'kid')) + $k = $v->{'kid'}; + } + $v = self::parseKey($v); + $keys[$k] = $v; + } + + return $keys; + } + + /** + * Parse a JWK key + * @param $source + * @return resource|array an associative array represents the key + */ + public static function parseKey($source) + { + if(!is_array($source)) + $source = (array)$source; + if(isset($source['kty']) && isset($source['n']) && isset($source['e'])) + { + switch ($source['kty']) { + case 'RSA': + if (array_key_exists('d', $source)) + throw new UnexpectedValueException('Failed to parse JWK: RSA private key is not supported'); + + $pem = self::createPemFromModulusAndExponent($source['n'], $source['e']); + $pKey = openssl_pkey_get_public($pem); + if($pKey !== false) + return $pKey; + break; + default: + //Currently only RSA is supported + break; + } + } + + throw new UnexpectedValueException('Failed to parse JWK'); + } + + /** + * + * Create a public key represented in PEM format from RSA modulus and exponent information + * + * @param string $n the RSA modulus encoded in Base64 + * @param string $e the RSA exponent encoded in Base64 + * @return string the RSA public key represented in PEM format + */ + private static function createPemFromModulusAndExponent($n, $e) + { + $modulus = JWT::urlsafeB64Decode($n); + $publicExponent = JWT::urlsafeB64Decode($e); + + + $components = array( + 'modulus' => pack('Ca*a*', 2, self::encodeLength(strlen($modulus)), $modulus), + 'publicExponent' => pack('Ca*a*', 2, self::encodeLength(strlen($publicExponent)), $publicExponent) + ); + + $RSAPublicKey = pack( + 'Ca*a*a*', + 48, + self::encodeLength(strlen($components['modulus']) + strlen($components['publicExponent'])), + $components['modulus'], + $components['publicExponent'] + ); + + + // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. + $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA + $RSAPublicKey = chr(0) . $RSAPublicKey; + $RSAPublicKey = chr(3) . self::encodeLength(strlen($RSAPublicKey)) . $RSAPublicKey; + + $RSAPublicKey = pack( + 'Ca*a*', + 48, + self::encodeLength(strlen($rsaOID . $RSAPublicKey)), + $rsaOID . $RSAPublicKey + ); + + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . + chunk_split(base64_encode($RSAPublicKey), 64) . + '-----END PUBLIC KEY-----'; + + return $RSAPublicKey; + } + + /** + * DER-encode the length + * + * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See + * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. + * + * @access private + * @param int $length + * @return string + */ + private static function encodeLength($length) + { + if ($length <= 0x7F) { + return chr($length); + } + + $temp = ltrim(pack('N', $length), chr(0)); + return pack('Ca*', 0x80 | strlen($temp), $temp); + } + +} \ No newline at end of file diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 78c7faa9..10237b45 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,6 +1,8 @@ assertEquals( + JWT::decode($msg, $key, array('RS256')), + '*:http://application/clicky?blah=1.23&f.oo=456 AC000 123' + ); + } + public function testUrlSafeCharacters() { $encoded = JWT::encode('f?', 'a'); @@ -207,7 +221,7 @@ public function testEmptyKeyFails() public function testRSEncodeDecode() { $privKey = openssl_pkey_new(array( - 'config'=>'C:/wamp/bin/apache/Apache2.4.4/conf/openssl.cnf', + //'config'=>'C:/wamp/bin/apache/Apache2.4.4/conf/openssl.cnf',//Remove this line when test on travis-ci.org 'digest_alg' => 'sha512', 'private_key_bits' => 4096, 'private_key_type' => OPENSSL_KEYTYPE_RSA)); From 1cd78221b94ac8a994783815721c5ade381f0c47 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 21:16:13 +0700 Subject: [PATCH 13/47] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 80301266..67184daa 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "firebase/php-jwt", - "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", - "homepage": "https://github.com/firebase/php-jwt", + "name": "fproject/php-jwt", + "description": "PHP library to encode and decode JSON Web Tokens (JWT) using several key types including JWK. Conform to the current spec.", + "homepage": "https://github.com/fproject/php-jwt", "authors": [ { "name": "Neuman Vong", From d8ef60427ad3a82d66da7db80241c56158ab2a9b Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 21:42:54 +0700 Subject: [PATCH 14/47] Update README --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7f1b026b..bcd20ed5 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ PHP-JWT ======= -A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should -conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06) +HP library to encode and decode JSON Web Tokens (JWT) using several key types including JWK. Conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06) Installation ------------ @@ -14,7 +13,7 @@ Installation Use composer to manage your dependencies and download PHP-JWT: ```bash -composer require firebase/php-jwt +composer require fproject/php-jwt ``` Example @@ -68,10 +67,10 @@ Changelog #### 3.0.0 / 2015-07-22 - Minimum PHP version updated from `5.2.0` to `5.3.0`. - Add `\Firebase\JWT` namespace. See -[#59](https://github.com/firebase/php-jwt/pull/59) for details. Thanks to +[#59](https://github.com/fproject/php-jwt/pull/59) for details. Thanks to [@Dashron](https://github.com/Dashron)! - Require a non-empty key to decode and verify a JWT. See -[#60](https://github.com/firebase/php-jwt/pull/60) for details. Thanks to +[#60](https://github.com/fproject/php-jwt/pull/60) for details. Thanks to [@sjones608](https://github.com/sjones608)! - Cleaner documentation blocks in the code. See [#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to @@ -79,7 +78,7 @@ Changelog #### 2.2.0 / 2015-06-22 - Add support for adding custom, optional JWT headers to `JWT::encode()`. See -[#53](https://github.com/firebase/php-jwt/pull/53/files) for details. Thanks to +[#53](https://github.com/fproject/php-jwt/pull/53/files) for details. Thanks to [@mcocaro](https://github.com/mcocaro)! #### 2.1.0 / 2015-05-20 From 521384de6e80a9b9e257e50b0ca7ccaff54ea847 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 28 Sep 2015 21:43:44 +0700 Subject: [PATCH 15/47] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bcd20ed5..93d00ee7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ PHP-JWT ======= -HP library to encode and decode JSON Web Tokens (JWT) using several key types including JWK. Conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06) +PHP library to encode and decode JSON Web Tokens (JWT) using several key types including JWK. Conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06) Installation ------------ From 7964d02d825453f1c888d9c018f57815ff4cc758 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Wed, 30 Sep 2015 09:35:25 +0700 Subject: [PATCH 16/47] Improve JWK parser --- src/JWK.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/JWK.php b/src/JWK.php index fbdad00a..cf3cc930 100644 --- a/src/JWK.php +++ b/src/JWK.php @@ -36,23 +36,28 @@ public static function parseKeySet($source) $source = [$source]; } - if(isset($source['keys'])) - $source = $source['keys']; - - foreach($source as $k=>$v) + if(is_array($source)) { - if(!is_string($k)) + if(isset($source['keys'])) + $source = $source['keys']; + + foreach($source as $k=>$v) { - if(is_array($v) && isset($v['kid'])) - $k = $v['kid']; - elseif(is_object($v) && property_exists($v,'kid')) - $k = $v->{'kid'}; + if(!is_string($k)) + { + if(is_array($v) && isset($v['kid'])) + $k = $v['kid']; + elseif(is_object($v) && property_exists($v,'kid')) + $k = $v->{'kid'}; + } + $v = self::parseKey($v); + $keys[$k] = $v; } - $v = self::parseKey($v); - $keys[$k] = $v; + + return $keys; } - return $keys; + throw new UnexpectedValueException('Failed to parse JWK'); } /** @@ -64,9 +69,10 @@ public static function parseKey($source) { if(!is_array($source)) $source = (array)$source; - if(isset($source['kty']) && isset($source['n']) && isset($source['e'])) + if(!empty($source) && isset($source['kty']) && isset($source['n']) && isset($source['e'])) { - switch ($source['kty']) { + switch ($source['kty']) + { case 'RSA': if (array_key_exists('d', $source)) throw new UnexpectedValueException('Failed to parse JWK: RSA private key is not supported'); From 7c377bdbf28a9837b6ec9f13be574bc74ac4d99b Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Wed, 30 Sep 2015 09:35:39 +0700 Subject: [PATCH 17/47] Update test data --- tests/JWTTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 10237b45..a9a37d98 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -28,7 +28,7 @@ public function testDecodeByJWKKeySet() $jsKey = '{"keys":[{"kty":"RSA","e":"AQAB","use":"sig","kid":"s1","n":"kWp2zRA23Z3vTL4uoe8kTFptxBVFunIoP4t_8TDYJrOb7D1iZNDXVeEsYKp6ppmrTZDAgd-cNOTKLd4M39WJc5FN0maTAVKJc7NxklDeKc4dMe1BGvTZNG4MpWBo-taKULlYUu0ltYJuLzOjIrTHfarucrGoRWqM0sl3z2-fv9k"}]}'; $key = JWK::parseKeySet($jsKey); - $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm9maWxlIiwiYWFzIl0sInN1YiI6InRVQ1l0bmZJQlBXY3JTSmY0eUJmdk4xa3d3NEtHY3kzTElQazFHVnpzRTAiLCJjbG0iOlsiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvMTMwLjIxMS4yNDMuMTE0OjgwODBcL2MyaWQiLCJleHAiOjE0NDExMjY1MzksInVpcCI6eyJncm91cHMiOlsiYWRtaW4iLCJhdWRpdCJdfSwiY2lkIjoicGstb2lkYy0wMSJ9.PvYrnf3k1Z0wgRwCgq0WXKaoIv1hHtzBFO5cGfCs6bl4suc6ilwCWmJqRxGYkU2fNTGyMOt3OUnnBEwl6v5qN6jv7zbkVAVKVvbQLxhHC2nXe3izvoCiVaMEH6hE7VTWwnPbX_qO72mCwTizHTJTZGLOsyXLYM6ctdOMf7sFPTI'; + $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm9maWxlIiwicnMtcGstbWFpbiIsInJzLXBrLXNvIiwicnMtcGstaXNzdWUiLCJycy1way13ZWIiXSwic3ViIjoiMjEiLCJjbG0iOlsicHJvamVjdEdyb3VwcyIsImV4SW5mbyIsIiE1djhIIl0sImlzcyI6Imh0dHA6XC9cL2lkLnByb2plY3RraXQubmV0IiwiZXhwIjoxNDQ4ODE5NjAwLCJ1aXAiOnsiZ3JvdXBzIjpbImFkbWluIiwiYXVkaXQiXX0sImNpZCI6InBrLW9pZGMtMDEifQ.N27jGoC-gblk0JqSJok_iczicoH_2QNM3zivesJDJhjI4xvQo6tP4Jqy6_uHev2s8Iio1StJz1E56mRXjWpxwoDOVCIt0Umiuyj7dQLyA4IAnH9_4y8Sd6HXehS2KaNNYxo0Wv5ZsgVqDYXvwBLN5T_b853gkCndhOj6j56R0jw'; $this->assertEquals( JWT::decode($msg, $key, array('RS256')), '*:http://application/clicky?blah=1.23&f.oo=456 AC000 123' From c646016e155dd6aacdeb7e51761ea9ca8cb1e8d1 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Fri, 2 Oct 2015 13:28:57 +0700 Subject: [PATCH 18/47] Update travis-ci config --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e538a4d..a648fc8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ php: - hhvm install: - composer self-update - - composer global require "fxp/composer-asset-plugin:1.0.0" - composer update --ignore-platform-reqs - composer info --installed script: phpunit -c phpunit.xml.dist \ No newline at end of file From 5d242f73440d30e7de950b0d2610c295e210903a Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Fri, 2 Oct 2015 13:40:20 +0700 Subject: [PATCH 19/47] Update travis-ci config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a648fc8c..1b33f529 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,6 @@ php: - hhvm install: - composer self-update - - composer update --ignore-platform-reqs + - composer update - composer info --installed script: phpunit -c phpunit.xml.dist \ No newline at end of file From d4dc56e9627e9f8e248a24afd49840b5b22c9e4a Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Fri, 9 Oct 2015 14:23:37 +0700 Subject: [PATCH 20/47] Update PHPDoc for JWT class --- src/JWT.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/JWT.php b/src/JWT.php index b3532df7..1456672d 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -23,8 +23,9 @@ class JWT { /** - * When checking nbf, iat or expiration times, - * we want to provide some extra leeway time to + * The server leeway time in seconds, to aware the acceptable different time between clocks + * of token issued server and relying parties. + * When checking nbf, iat or expiration times, we want to provide some extra leeway time to * account for clock skew. */ public static $leeway = 0; From 06f2305f6ad041c7cb768528110766c572248aec Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 17:17:05 +0700 Subject: [PATCH 21/47] Update travis-ci config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1b33f529..bb256e02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ php: - hhvm install: - composer self-update + - composer global require "fxp/composer-asset-plugin:*" - composer update - composer info --installed script: phpunit -c phpunit.xml.dist \ No newline at end of file From 64fc9c35df8b9d87788ee3a8e73084cae899bdc5 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 17:22:23 +0700 Subject: [PATCH 22/47] Update travis-ci config --- .travis.yml | 3 +++ composer.json | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb256e02..b597241d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ php: - 5.3 - 7 - hhvm + +sudo: false + install: - composer self-update - composer global require "fxp/composer-asset-plugin:*" diff --git a/composer.json b/composer.json index 67184daa..c8c3eba3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fproject/php-jwt", - "description": "PHP library to encode and decode JSON Web Tokens (JWT) using several key types including JWK. Conform to the current spec.", + "description": "PHP library to encode and decode JSON Web Tokens (JWT). Supports several key types including JWK. Conform to the current spec.", "homepage": "https://github.com/fproject/php-jwt", "authors": [ { @@ -23,9 +23,6 @@ "require": { "php": ">=5.3.0" }, - "require-dev": { - "phpunit/phpunit": "*" - }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" From 45cc4c52c382972fdf4f8ed0312e13d7b08d2c49 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 17:26:06 +0700 Subject: [PATCH 23/47] Update travis-ci config --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index c8c3eba3..587c1610 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,9 @@ "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "4.5.0" + }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" From 53a0682d0a24bd32cfd8e1344bee1a003c0df6c3 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 17:46:10 +0700 Subject: [PATCH 24/47] Update test script --- tests/JWTTest.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index a9a37d98..f203822f 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,11 +1,6 @@ Date: Thu, 5 Nov 2015 17:46:47 +0700 Subject: [PATCH 25/47] Update composer.json --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 587c1610..c8c3eba3 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,6 @@ "require": { "php": ">=5.3.0" }, - "require-dev": { - "phpunit/phpunit": "4.5.0" - }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" From 4845e7cb93d23afbe859d110e6534688ae128416 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 18:08:01 +0700 Subject: [PATCH 26/47] Update composer.json and config files --- .travis.yml | 10 +++++----- README.md | 2 +- composer.json | 2 +- package.xml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index b597241d..8aa5c65b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,17 @@ language: php + php: - - 5.6 - - 5.5 - - 5.4 - 5.3 - - 7 + - 5.4 + - 5.5 - hhvm sudo: false -install: +before_script: - composer self-update - composer global require "fxp/composer-asset-plugin:*" - composer update - composer info --installed + script: phpunit -c phpunit.xml.dist \ No newline at end of file diff --git a/README.md b/README.md index 93d00ee7..80f8a755 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ PHP-JWT ======= -PHP library to encode and decode JSON Web Tokens (JWT) using several key types including JWK. Conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06) +PHP library to encode and decode JSON Web Tokens (JWT). Support several key types including JWK. Conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06) Installation ------------ diff --git a/composer.json b/composer.json index c8c3eba3..df9fef8f 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fproject/php-jwt", - "description": "PHP library to encode and decode JSON Web Tokens (JWT). Supports several key types including JWK. Conform to the current spec.", + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Support several key types including JWK.", "homepage": "https://github.com/fproject/php-jwt", "authors": [ { diff --git a/package.xml b/package.xml index a95b056f..5c043d5f 100644 --- a/package.xml +++ b/package.xml @@ -6,7 +6,7 @@ JWT pear.php.net A JWT encoder/decoder. - A JWT encoder/decoder library for PHP. + A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Support several key types including JWK Neuman Vong lcfrs From 543ab1eded8de43abd077088b329bc0d8d0f0e00 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 18:20:47 +0700 Subject: [PATCH 27/47] Update test script --- tests/JWTTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index f203822f..9166621f 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,5 +1,6 @@ Date: Thu, 5 Nov 2015 18:36:15 +0700 Subject: [PATCH 28/47] Update test script --- tests/JWTTest.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 9166621f..eb545c0e 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -24,11 +24,10 @@ public function testDecodeByJWKKeySet() $jsKey = '{"keys":[{"kty":"RSA","e":"AQAB","use":"sig","kid":"s1","n":"kWp2zRA23Z3vTL4uoe8kTFptxBVFunIoP4t_8TDYJrOb7D1iZNDXVeEsYKp6ppmrTZDAgd-cNOTKLd4M39WJc5FN0maTAVKJc7NxklDeKc4dMe1BGvTZNG4MpWBo-taKULlYUu0ltYJuLzOjIrTHfarucrGoRWqM0sl3z2-fv9k"}]}'; $key = JWK::parseKeySet($jsKey); - $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm9maWxlIiwicnMtcGstbWFpbiIsInJzLXBrLXNvIiwicnMtcGstaXNzdWUiLCJycy1way13ZWIiXSwic3ViIjoiMjEiLCJjbG0iOlsicHJvamVjdEdyb3VwcyIsImV4SW5mbyIsIiE1djhIIl0sImlzcyI6Imh0dHA6XC9cL2lkLnByb2plY3RraXQubmV0IiwiZXhwIjoxNDQ4ODE5NjAwLCJ1aXAiOnsiZ3JvdXBzIjpbImFkbWluIiwiYXVkaXQiXX0sImNpZCI6InBrLW9pZGMtMDEifQ.N27jGoC-gblk0JqSJok_iczicoH_2QNM3zivesJDJhjI4xvQo6tP4Jqy6_uHev2s8Iio1StJz1E56mRXjWpxwoDOVCIt0Umiuyj7dQLyA4IAnH9_4y8Sd6HXehS2KaNNYxo0Wv5ZsgVqDYXvwBLN5T_b853gkCndhOj6j56R0jw'; - $this->assertEquals( - JWT::decode($msg, $key, array('RS256')), - '*:http://application/clicky?blah=1.23&f.oo=456 AC000 123' - ); + $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm9maWxlIiwiYWFzIl0sInN1YiI6InRVQ1l0bmZJQlBXY3JTSmY0eUJmdk4xa3d3NEtHY3kzTElQazFHVnpzRTAiLCJjbG0iOlsiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvMTMwLjIxMS4yNDMuMTE0OjgwODBcL2MyaWQiLCJleHAiOjE0NDExMjY1MzksInVpcCI6eyJncm91cHMiOlsiYWRtaW4iLCJhdWRpdCJdfSwiY2lkIjoicGstb2lkYy0wMSJ9.PvYrnf3k1Z0wgRwCgq0WXKaoIv1hHtzBFO5cGfCs6bl4suc6ilwCWmJqRxGYkU2fNTGyMOt3OUnnBEwl6v5qN6jv7zbkVAVKVvbQLxhHC2nXe3izvoCiVaMEH6hE7VTWwnPbX_qO72mCwTizHTJTZGLOsyXLYM6ctdOMf7sFPTI'; + $payload = JWT::decode($msg, $key, array('RS256')); + echo print_r($payload,true); + $this->assertEquals("tUCYtnfIBPWcrSJf4yBfvN1kww4KGcy3LIPk1GVzsE0",$payload->sub); } public function testUrlSafeCharacters() From 81a48755c6e2d183bed3c56b5fc2c808407af47e Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 18:36:26 +0700 Subject: [PATCH 29/47] Update travis-ci config --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8aa5c65b..f4543497 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: php php: - - 5.3 - 5.4 - 5.5 + - 5.6 + - 7 - hhvm sudo: false From 3c7efe88e6eac5667687f54697ab1a421b20ceb9 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 18:41:22 +0700 Subject: [PATCH 30/47] =?UTF-8?q?Update=20t=C3=A9t=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/JWTTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index eb545c0e..6a10909d 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -19,12 +19,24 @@ public function testDecodeFromPython() ); } - public function testDecodeByJWKKeySet() + /** + * @expectedException Firebase\JWT\ExpiredException + */ + public function testDecodeByJWKKeySetTokenExpired() { $jsKey = '{"keys":[{"kty":"RSA","e":"AQAB","use":"sig","kid":"s1","n":"kWp2zRA23Z3vTL4uoe8kTFptxBVFunIoP4t_8TDYJrOb7D1iZNDXVeEsYKp6ppmrTZDAgd-cNOTKLd4M39WJc5FN0maTAVKJc7NxklDeKc4dMe1BGvTZNG4MpWBo-taKULlYUu0ltYJuLzOjIrTHfarucrGoRWqM0sl3z2-fv9k"}]}'; $key = JWK::parseKeySet($jsKey); $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm9maWxlIiwiYWFzIl0sInN1YiI6InRVQ1l0bmZJQlBXY3JTSmY0eUJmdk4xa3d3NEtHY3kzTElQazFHVnpzRTAiLCJjbG0iOlsiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvMTMwLjIxMS4yNDMuMTE0OjgwODBcL2MyaWQiLCJleHAiOjE0NDExMjY1MzksInVpcCI6eyJncm91cHMiOlsiYWRtaW4iLCJhdWRpdCJdfSwiY2lkIjoicGstb2lkYy0wMSJ9.PvYrnf3k1Z0wgRwCgq0WXKaoIv1hHtzBFO5cGfCs6bl4suc6ilwCWmJqRxGYkU2fNTGyMOt3OUnnBEwl6v5qN6jv7zbkVAVKVvbQLxhHC2nXe3izvoCiVaMEH6hE7VTWwnPbX_qO72mCwTizHTJTZGLOsyXLYM6ctdOMf7sFPTI'; + JWT::decode($msg, $key, array('RS256')); + } + + public function testDecodeByJWKKeySet() + { + $jsKey = '{"keys":[{"kty":"RSA","e":"AQAB","use":"sig","kid":"s1","n":"kWp2zRA23Z3vTL4uoe8kTFptxBVFunIoP4t_8TDYJrOb7D1iZNDXVeEsYKp6ppmrTZDAgd-cNOTKLd4M39WJc5FN0maTAVKJc7NxklDeKc4dMe1BGvTZNG4MpWBo-taKULlYUu0ltYJuLzOjIrTHfarucrGoRWqM0sl3z2-fv9k"}]}'; + $key = JWK::parseKeySet($jsKey); + + $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJYcEFCeEpnVXhLN2JKdnVnRGFXaXlYLWF6aDliSlJ4OGU1dGJzdjVZblpRIiwic2NwIjpbIm9wZW5pZCIsImVtYWlsIiwicHJvZmlsZSIsInJzLXBrLW1haW4iLCJycy1way1zbyIsInJzLXBrLWlzc3VlIiwicnMtcGstd2ViIl0sImNsbSI6WyJwcm9qZWN0R3JvdXBzIiwiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvaWQucHJvamVjdGtpdC5uZXQiLCJleHAiOjE0NzYyNDgyMzMsImNpZCI6ImNpZC1way13ZWIifQ.cxkukSfQ9YrvLr8X-0RV_00FRoSvnA1er-6qvfpgIKjShjUfjga4T-wCv-KrVpYqQAxTdDZZJNwiDo3oLuqSwsvBmwT1Wyt1wce9GLAd3MSW9KtHnygGwqtdbP3taWieQrpgNNlQTJHex-XqlkVR722pxgPjtj-96IV8WPC0vek'; $payload = JWT::decode($msg, $key, array('RS256')); echo print_r($payload,true); $this->assertEquals("tUCYtnfIBPWcrSJf4yBfvN1kww4KGcy3LIPk1GVzsE0",$payload->sub); From 86d121da51e67916ed0f8040add842d852814e88 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 18:44:07 +0700 Subject: [PATCH 31/47] Update test scripts --- tests/JWTTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 6a10909d..1402182c 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -38,8 +38,8 @@ public function testDecodeByJWKKeySet() $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJYcEFCeEpnVXhLN2JKdnVnRGFXaXlYLWF6aDliSlJ4OGU1dGJzdjVZblpRIiwic2NwIjpbIm9wZW5pZCIsImVtYWlsIiwicHJvZmlsZSIsInJzLXBrLW1haW4iLCJycy1way1zbyIsInJzLXBrLWlzc3VlIiwicnMtcGstd2ViIl0sImNsbSI6WyJwcm9qZWN0R3JvdXBzIiwiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvaWQucHJvamVjdGtpdC5uZXQiLCJleHAiOjE0NzYyNDgyMzMsImNpZCI6ImNpZC1way13ZWIifQ.cxkukSfQ9YrvLr8X-0RV_00FRoSvnA1er-6qvfpgIKjShjUfjga4T-wCv-KrVpYqQAxTdDZZJNwiDo3oLuqSwsvBmwT1Wyt1wce9GLAd3MSW9KtHnygGwqtdbP3taWieQrpgNNlQTJHex-XqlkVR722pxgPjtj-96IV8WPC0vek'; $payload = JWT::decode($msg, $key, array('RS256')); - echo print_r($payload,true); - $this->assertEquals("tUCYtnfIBPWcrSJf4yBfvN1kww4KGcy3LIPk1GVzsE0",$payload->sub); + $this->assertEquals("XpABxJgUxK7bJvugDaWiyX-azh9bJRx8e5tbsv5YnZQ",$payload->sub); + $this->assertEquals(1476248233,$payload->exp); } public function testUrlSafeCharacters() From 2e79ad4b846c2693099f9ade47877b95e6b0b22a Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 18:45:29 +0700 Subject: [PATCH 32/47] Update README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 80f8a755..56566c1a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Build Status](https://travis-ci.org/firebase/php-jwt.png?branch=master)](https://travis-ci.org/firebase/php-jwt) -[![Latest Stable Version](https://poser.pugx.org/firebase/php-jwt/v/stable)](https://packagist.org/packages/firebase/php-jwt) -[![Total Downloads](https://poser.pugx.org/firebase/php-jwt/downloads)](https://packagist.org/packages/firebase/php-jwt) -[![License](https://poser.pugx.org/firebase/php-jwt/license)](https://packagist.org/packages/firebase/php-jwt) +[![Build Status](https://travis-ci.org/fproject/php-jwt.png?branch=master)](https://travis-ci.org/fproject/php-jwt) +[![Latest Stable Version](https://poser.pugx.org/fproject/php-jwt/v/stable)](https://packagist.org/packages/fproject/php-jwt) +[![Total Downloads](https://poser.pugx.org/fproject/php-jwt/downloads)](https://packagist.org/packages/fproject/php-jwt) +[![License](https://poser.pugx.org/fproject/php-jwt/license)](https://packagist.org/packages/fproject/php-jwt) PHP-JWT ======= @@ -73,7 +73,7 @@ Changelog [#60](https://github.com/fproject/php-jwt/pull/60) for details. Thanks to [@sjones608](https://github.com/sjones608)! - Cleaner documentation blocks in the code. See -[#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to +[#62](https://github.com/fproject/php-jwt/pull/62) for details. Thanks to [@johanderuijter](https://github.com/johanderuijter)! #### 2.2.0 / 2015-06-22 From 38101487ab21f7549c64a336a590fd21e31d7944 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 21:26:06 +0700 Subject: [PATCH 33/47] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56566c1a..1f137b6a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/fproject/php-jwt.png?branch=master)](https://travis-ci.org/fproject/php-jwt) [![Latest Stable Version](https://poser.pugx.org/fproject/php-jwt/v/stable)](https://packagist.org/packages/fproject/php-jwt) -[![Total Downloads](https://poser.pugx.org/fproject/php-jwt/downloads)](https://packagist.org/packages/fproject/php-jwt) +[![Total Downloads](https://poser.pugx.org/fproject/php-jwt/downloads)](https://packagist.org/packages/firebase/php-jwt) [![License](https://poser.pugx.org/fproject/php-jwt/license)](https://packagist.org/packages/fproject/php-jwt) PHP-JWT From cf18cf9dca447ffd0c7cf59c7851d24b3b08cc8a Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 21:27:16 +0700 Subject: [PATCH 34/47] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f137b6a..c7dd7323 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/fproject/php-jwt.png?branch=master)](https://travis-ci.org/fproject/php-jwt) [![Latest Stable Version](https://poser.pugx.org/fproject/php-jwt/v/stable)](https://packagist.org/packages/fproject/php-jwt) -[![Total Downloads](https://poser.pugx.org/fproject/php-jwt/downloads)](https://packagist.org/packages/firebase/php-jwt) +[![Total Downloads](https://poser.pugx.org/firebase/php-jwt/downloads)](https://packagist.org/packages/fproject/php-jwt) [![License](https://poser.pugx.org/fproject/php-jwt/license)](https://packagist.org/packages/fproject/php-jwt) PHP-JWT From b43315d4a013c188be7354c0db0ce2ac49cc7735 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Thu, 5 Nov 2015 21:34:48 +0700 Subject: [PATCH 35/47] Update README --- README.md | 32 ++++---------------------------- composer.json | 2 +- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index c7dd7323..55e8e02f 100644 --- a/README.md +++ b/README.md @@ -63,36 +63,12 @@ $decoded = JWT::decode($jwt, $key, array('HS256')); Changelog --------- +#### 3.0.3 / 2015-11-05 +- Minimum PHP version updated from `5.3.0` to `5.4.0`. +- Add JWK support #### 3.0.0 / 2015-07-22 -- Minimum PHP version updated from `5.2.0` to `5.3.0`. -- Add `\Firebase\JWT` namespace. See -[#59](https://github.com/fproject/php-jwt/pull/59) for details. Thanks to -[@Dashron](https://github.com/Dashron)! -- Require a non-empty key to decode and verify a JWT. See -[#60](https://github.com/fproject/php-jwt/pull/60) for details. Thanks to -[@sjones608](https://github.com/sjones608)! -- Cleaner documentation blocks in the code. See -[#62](https://github.com/fproject/php-jwt/pull/62) for details. Thanks to -[@johanderuijter](https://github.com/johanderuijter)! - -#### 2.2.0 / 2015-06-22 -- Add support for adding custom, optional JWT headers to `JWT::encode()`. See -[#53](https://github.com/fproject/php-jwt/pull/53/files) for details. Thanks to -[@mcocaro](https://github.com/mcocaro)! - -#### 2.1.0 / 2015-05-20 -- Add support for adding a leeway to `JWT:decode()` that accounts for clock skew -between signing and verifying entities. Thanks to [@lcabral](https://github.com/lcabral)! -- Add support for passing an object implementing the `ArrayAccess` interface for -`$keys` argument in `JWT::decode()`. Thanks to [@aztech-dev](https://github.com/aztech-dev)! - -#### 2.0.0 / 2015-04-01 -- **Note**: It is strongly recommended that you update to > v2.0.0 to address - known security vulnerabilities in prior versions when both symmetric and - asymmetric keys are used together. -- Update signature for `JWT::decode(...)` to require an array of supported - algorithms to use when verifying token signatures. +- Original features from firebase/php-jwt repository Tests diff --git a/composer.json b/composer.json index df9fef8f..5b52468a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ ], "license": "BSD-3-Clause", "require": { - "php": ">=5.3.0" + "php": ">=5.4.0" }, "autoload": { "psr-4": { From 0ac88049d2b75ceb23c266702be0117cfd9ea5a8 Mon Sep 17 00:00:00 2001 From: thanhpv Date: Wed, 10 Aug 2016 11:01:19 +0700 Subject: [PATCH 36/47] Update readme :computer: --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 55e8e02f..d6a89c3a 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,13 @@ $decoded = JWT::decode($jwt, $key, array('HS256')); Changelog --------- +#### 4.0.0 / 2016-08-10 +- Update to 4.0.0 from upstream +- Add support for late static binding. See [#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to [@chappy84](https://github.com/chappy84)! +- Use static `$timestamp` instead of `time()` to improve unit testing. See [#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to [@josephmcdermott](https://github.com/josephmcdermott)! +- Fixes to exceptions classes. See [#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to [@Maks3w](https://github.com/Maks3w)! +- Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for details. Thanks to [@akeeman](https://github.com/akeeman)! + #### 3.0.3 / 2015-11-05 - Minimum PHP version updated from `5.3.0` to `5.4.0`. - Add JWK support From c8c727c0492eb09ac43e3083ae1ab71daab805e9 Mon Sep 17 00:00:00 2001 From: Phan Van Thanh Date: Wed, 5 Apr 2017 11:45:02 +0700 Subject: [PATCH 37/47] Update parse key set for multi keys --- src/JWK.php | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/JWK.php b/src/JWK.php index cf3cc930..8eecb73f 100644 --- a/src/JWK.php +++ b/src/JWK.php @@ -1,6 +1,7 @@ $v) - { - if(!is_string($k)) - { - if(is_array($v) && isset($v['kid'])) + foreach ($source as $k => $v) { + if (!is_string($k)) { + if (is_array($v) && isset($v['kid'])) $k = $v['kid']; - elseif(is_object($v) && property_exists($v,'kid')) + elseif (is_object($v) && property_exists($v, 'kid')) $k = $v->{'kid'}; } - $v = self::parseKey($v); - $keys[$k] = $v; + try { + $v = self::parseKey($v); + $keys[$k] = $v; + } catch (UnexpectedValueException $e) { + //Do nothing + } } - + } + if (0 < count($keys)) { return $keys; } - throw new UnexpectedValueException('Failed to parse JWK'); } @@ -67,19 +66,17 @@ public static function parseKeySet($source) */ public static function parseKey($source) { - if(!is_array($source)) + if (!is_array($source)) $source = (array)$source; - if(!empty($source) && isset($source['kty']) && isset($source['n']) && isset($source['e'])) - { - switch ($source['kty']) - { + if (!empty($source) && isset($source['kty']) && isset($source['n']) && isset($source['e'])) { + switch ($source['kty']) { case 'RSA': if (array_key_exists('d', $source)) throw new UnexpectedValueException('Failed to parse JWK: RSA private key is not supported'); $pem = self::createPemFromModulusAndExponent($source['n'], $source['e']); $pKey = openssl_pkey_get_public($pem); - if($pKey !== false) + if ($pKey !== false) return $pKey; break; default: From 59f4a8420461970c5e559464843df3ce696d2340 Mon Sep 17 00:00:00 2001 From: Phan Van Thanh Date: Wed, 5 Apr 2017 11:45:46 +0700 Subject: [PATCH 38/47] Add test function for parse key set multi keys --- tests/JWTTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/JWTTest.php b/tests/JWTTest.php index c97784c9..60dcabcb 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -42,6 +42,17 @@ public function testDecodeByJWKKeySet() $this->assertEquals(1476248233,$payload->exp); } + public function testDecodeByMultiJWKKeySet() + { + $jsKey = '{"keys":[{"kty":"RSA","e":"AQAB","use":"sig","kid":"CXup","n":"hrwD-lc-IwzwidCANmy4qsiZk11yp9kHykOuP0yOnwi36VomYTQVEzZXgh2sDJpGgAutdQudgwLoV8tVSsTG9SQHgJjH9Pd_9V4Ab6PANyZNG6DSeiq1QfiFlEP6Obt0JbRB3W7X2vkxOVaNoWrYskZodxU2V0ogeVL_LkcCGAyNu2jdx3j0DjJatNVk7ystNxb9RfHhJGgpiIkO5S3QiSIVhbBKaJHcZHPF1vq9g0JMGuUCI-OTSVg6XBkTLEGw1C_R73WD_oVEBfdXbXnLukoLHBS11p3OxU7f4rfxA_f_72_UwmWGJnsqS3iahbms3FkvqoL9x_Vj3GhuJSf97Q"},{"kty":"EC","use":"sig","crv":"P-256","kid":"yGvt","x":"pvgdqM3RCshljmuCF1D2Ez1w5ei5k7-bpimWLPNeEHI","y":"JSmUhbUTqiFclVLEdw6dz038F7Whw4URobjXbAReDuM"},{"kty":"EC","use":"sig","crv":"P-384","kid":"9nHY","x":"JPKhjhE0Bj579Mgj3Cn3ERGA8fKVYoGOaV9BPKhtnEobphf8w4GSeigMesL-038W","y":"UbJa1QRX7fo9LxSlh7FOH5ABT5lEtiQeQUcX9BW0bpJFlEVGqwec80tYLdOIl59M"},{"kty":"EC","use":"sig","crv":"P-521","kid":"tVzS","x":"AZgkRHlIyNQJlPIwTWdHqouw41k9dS3GJO04BDEnJnd_Dd1owlCn9SMXA-JuXINn4slwbG4wcECbctXb2cvdGtmn","y":"AdBC6N9lpupzfzcIY3JLIuc8y8MnzV-ItmzHQcC5lYWMTbuM9NU_FlvINeVo8g6i4YZms2xFB-B0VVdaoF9kUswC"}]}'; + $key = JWK::parseKeySet($jsKey); + + $msg = 'eyJraWQiOiJDWHVwIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmOGI2N2NjNDYwMzA3NzdlZmQ4YmNlNmMxYmZlMjljNmMwZjgxOGVjIiwic2NwIjpbIm9wZW5pZCIsIm5hbWUiLCJwcm9maWxlIiwicGljdHVyZSIsImVtYWlsIiwicnMtcGstbWFpbiIsInJzLXBrLXNvIiwicnMtcGstaXNzdWUiLCJycy1way13ZWIiXSwiY2xtIjpbIiE1djhIIl0sImlzcyI6Imh0dHBzOlwvXC9pZC5wcm9qZWN0a2l0Lm5ldFwvYXV0aGVudGljYXRlIiwiZXhwIjoxNDkyMjI4MzM2LCJpYXQiOjE0OTEzNjQzMzYsImNpZCI6ImNpZC1way13ZWIifQ.KW1K-72bMtiNwvyYBgffG6VaG6I59cELGYQR8M2q7HA8dmzliu6QREJrqyPtwW_rDJZbsD3eylvkRinK9tlsMXCOfEJbxLdAC9b4LKOsnsbuXXwsJHWkFG0a7osdW0ZpXJDoMFlO1aosxRGMkaqhf1wIkvQ5PM_EB08LJv7oz64Antn5bYaoajwgvJRl7ChatRDn9Sx5UIElKD1BK4Uw5WdrZwBlWdWZVNCSFhy4F6SdZvi3OBlXzluDwq61RC-pl2iivilJNljYWVrthHDS1xdtaVz4oteHW13-IS7NNEz6PVnzo5nyoPWMAB4JlRnxcfOFTTUqOA2mX5Csg0UpdQ'; + $payload = JWT::decode($msg, $key, array('RS256')); + $this->assertEquals("f8b67cc46030777efd8bce6c1bfe29c6c0f818ec",$payload->sub); + $this->assertEquals(1492228336,$payload->exp); + } + public function testUrlSafeCharacters() { $encoded = JWT::encode('f?', 'a'); From 1ccf497b40552e7a5f9663aa09bc80dd6f0b4f4e Mon Sep 17 00:00:00 2001 From: ThanhPV Date: Thu, 28 Sep 2017 00:35:11 +0700 Subject: [PATCH 39/47] Remove composer.lock --- .gitignore | 1 + composer.lock | 1058 ------------------------------------------------- 2 files changed, 1 insertion(+), 1058 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index b1a05b0b..cc979c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ phpunit.phar phpunit.phar.asc composer.phar .idea +composer.lock \ No newline at end of file diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 7ad0cb8e..00000000 --- a/composer.lock +++ /dev/null @@ -1,1058 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "18867f3a3b90fcdf289d47ec125a6b94", - "packages": [], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, - { - "name": "myclabs/deep-copy", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "95d662954e06000cdf63ec9c9f0a6c598d9c5eb9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/95d662954e06000cdf63ec9c9f0a6c598d9c5eb9", - "reference": "95d662954e06000cdf63ec9c9f0a6c598d9c5eb9", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2015-07-19 19:57:13" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2015-02-03 12:10:50" - }, - { - "name": "phpspec/prophecy", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62", - "reference": "4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" - }, - "require-dev": { - "phpspec/phpspec": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com/" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2015-09-22 14:49:23" - }, - { - "name": "phpunit/php-code-coverage", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "12259bb1352612df9ec24048714a3bedafe79674" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/12259bb1352612df9ec24048714a3bedafe79674", - "reference": "12259bb1352612df9ec24048714a3bedafe79674", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~5" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-09-24 07:56:07" - }, - { - "name": "phpunit/php-file-iterator", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2015-06-21 08:01:12" - }, - { - "name": "phpunit/php-token-stream", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "cab6c6fefee93d7b7c3a01292a0fe0884ea66644" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/cab6c6fefee93d7b7c3a01292a0fe0884ea66644", - "reference": "cab6c6fefee93d7b7c3a01292a0fe0884ea66644", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2015-09-23 14:46:55" - }, - { - "name": "phpunit/phpunit", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b3db8bc29009cbd788cd827d7376a5e8018243ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b3db8bc29009cbd788cd827d7376a5e8018243ce", - "reference": "b3db8bc29009cbd788cd827d7376a5e8018243ce", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "myclabs/deep-copy": "~1.3", - "php": ">=7.0", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~3.0", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": ">=3.0", - "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2015-09-27 08:37:11" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "4f526b7e2c42cacf32c86e1e0c9ab9d3b24273cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/4f526b7e2c42cacf32c86e1e0c9ab9d3b24273cf", - "reference": "4f526b7e2c42cacf32c86e1e0c9ab9d3b24273cf", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.6", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-09-02 07:30:58" - }, - { - "name": "sebastian/comparator", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2015-07-26 15:48:44" - }, - { - "name": "sebastian/diff", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "6899b3e33bfbd386d88b5eea5f65f563e8793051" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/6899b3e33bfbd386d88b5eea5f65f563e8793051", - "reference": "6899b3e33bfbd386d88b5eea5f65f563e8793051", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-06-22 14:15:55" - }, - { - "name": "sebastian/environment", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44", - "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2015-08-03 06:14:51" - }, - { - "name": "sebastian/exporter", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "f88f8936517d54ae6d589166810877fb2015d0a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f88f8936517d54ae6d589166810877fb2015d0a2", - "reference": "f88f8936517d54ae6d589166810877fb2015d0a2", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2015-08-09 04:23:41" - }, - { - "name": "sebastian/global-state", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23af31f402993cfd94e99cbc4b782e9a78eb0e97", - "reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-06-21 15:11:22" - }, - { - "name": "sebastian/recursion-context", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", - "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-06-21 08:04:50" - }, - { - "name": "sebastian/resource-operations", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28 20:34:47" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" - }, - { - "name": "symfony/yaml", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "b68154f3ee23d8294936433fd31725a83bd02f71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b68154f3ee23d8294936433fd31725a83bd02f71", - "reference": "b68154f3ee23d8294936433fd31725a83bd02f71", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.8|~3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com/", - "time": "2015-09-14 14:15:24" - } - ], - "aliases": [], - "minimum-stability": "dev", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.0" - }, - "platform-dev": [] -} From 9c2857091f13ab367385bf00efeadf41a86aeb88 Mon Sep 17 00:00:00 2001 From: ThanhPV Date: Thu, 28 Sep 2017 00:39:37 +0700 Subject: [PATCH 40/47] Fix test failed by using phpunit ^6.0 --- composer.json | 6 ++-- tests/JWTTest.php | 84 ++++++++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/composer.json b/composer.json index 5b52468a..5e3344c9 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,14 @@ ], "license": "BSD-3-Clause", "require": { - "php": ">=5.4.0" + "php": ">=5.4.0", + "phpunit/phpunit": "^6.0" }, "autoload": { "psr-4": { "Firebase\\JWT\\": "src" } }, - "minimum-stability": "dev" + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 60dcabcb..55b44cb5 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -2,12 +2,12 @@ use Firebase\JWT\JWT; use Firebase\JWT\JWK; -class JWTTest extends PHPUnit_Framework_TestCase +class JWTTest extends \PHPUnit\Framework\TestCase { public function testEncodeDecode() { - $msg = JWT::encode('abc', 'my_key'); - $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), 'abc'); + $msg = JWT::encode(['abc'], 'my_key'); + $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), ['abc']); } public function testDecodeFromPython() @@ -36,10 +36,11 @@ public function testDecodeByJWKKeySet() $jsKey = '{"keys":[{"kty":"RSA","e":"AQAB","use":"sig","kid":"s1","n":"kWp2zRA23Z3vTL4uoe8kTFptxBVFunIoP4t_8TDYJrOb7D1iZNDXVeEsYKp6ppmrTZDAgd-cNOTKLd4M39WJc5FN0maTAVKJc7NxklDeKc4dMe1BGvTZNG4MpWBo-taKULlYUu0ltYJuLzOjIrTHfarucrGoRWqM0sl3z2-fv9k"}]}'; $key = JWK::parseKeySet($jsKey); - $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJYcEFCeEpnVXhLN2JKdnVnRGFXaXlYLWF6aDliSlJ4OGU1dGJzdjVZblpRIiwic2NwIjpbIm9wZW5pZCIsImVtYWlsIiwicHJvZmlsZSIsInJzLXBrLW1haW4iLCJycy1way1zbyIsInJzLXBrLWlzc3VlIiwicnMtcGstd2ViIl0sImNsbSI6WyJwcm9qZWN0R3JvdXBzIiwiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvaWQucHJvamVjdGtpdC5uZXQiLCJleHAiOjE0NzYyNDgyMzMsImNpZCI6ImNpZC1way13ZWIifQ.cxkukSfQ9YrvLr8X-0RV_00FRoSvnA1er-6qvfpgIKjShjUfjga4T-wCv-KrVpYqQAxTdDZZJNwiDo3oLuqSwsvBmwT1Wyt1wce9GLAd3MSW9KtHnygGwqtdbP3taWieQrpgNNlQTJHex-XqlkVR722pxgPjtj-96IV8WPC0vek'; + $msg = 'eyJraWQiOiJzMSIsImFsZyI6IlJTMjU2In0.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm9maWxlIiwiYWFzIl0sInN1YiI6InRVQ1l0bmZJQlBXY3JTSmY0eUJmdk4xa3d3NEtHY3kzTElQazFHVnpzRTAiLCJjbG0iOlsiITV2OEgiXSwiaXNzIjoiaHR0cDpcL1wvMTMwLjIxMS4yNDMuMTE0OjgwODBcL2MyaWQiLCJleHAiOjE0NDExMjY1MzksInVpcCI6eyJncm91cHMiOlsiYWRtaW4iLCJhdWRpdCJdfSwiY2lkIjoicGstb2lkYy0wMSJ9.PvYrnf3k1Z0wgRwCgq0WXKaoIv1hHtzBFO5cGfCs6bl4suc6ilwCWmJqRxGYkU2fNTGyMOt3OUnnBEwl6v5qN6jv7zbkVAVKVvbQLxhHC2nXe3izvoCiVaMEH6hE7VTWwnPbX_qO72mCwTizHTJTZGLOsyXLYM6ctdOMf7sFPTI'; + $this->expectException('Firebase\JWT\ExpiredException'); $payload = JWT::decode($msg, $key, array('RS256')); - $this->assertEquals("XpABxJgUxK7bJvugDaWiyX-azh9bJRx8e5tbsv5YnZQ",$payload->sub); - $this->assertEquals(1476248233,$payload->exp); + $this->assertEquals("tUCYtnfIBPWcrSJf4yBfvN1kww4KGcy3LIPk1GVzsE0",$payload->sub); + $this->assertEquals(1441126539,$payload->exp); } public function testDecodeByMultiJWKKeySet() @@ -48,6 +49,7 @@ public function testDecodeByMultiJWKKeySet() $key = JWK::parseKeySet($jsKey); $msg = 'eyJraWQiOiJDWHVwIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmOGI2N2NjNDYwMzA3NzdlZmQ4YmNlNmMxYmZlMjljNmMwZjgxOGVjIiwic2NwIjpbIm9wZW5pZCIsIm5hbWUiLCJwcm9maWxlIiwicGljdHVyZSIsImVtYWlsIiwicnMtcGstbWFpbiIsInJzLXBrLXNvIiwicnMtcGstaXNzdWUiLCJycy1way13ZWIiXSwiY2xtIjpbIiE1djhIIl0sImlzcyI6Imh0dHBzOlwvXC9pZC5wcm9qZWN0a2l0Lm5ldFwvYXV0aGVudGljYXRlIiwiZXhwIjoxNDkyMjI4MzM2LCJpYXQiOjE0OTEzNjQzMzYsImNpZCI6ImNpZC1way13ZWIifQ.KW1K-72bMtiNwvyYBgffG6VaG6I59cELGYQR8M2q7HA8dmzliu6QREJrqyPtwW_rDJZbsD3eylvkRinK9tlsMXCOfEJbxLdAC9b4LKOsnsbuXXwsJHWkFG0a7osdW0ZpXJDoMFlO1aosxRGMkaqhf1wIkvQ5PM_EB08LJv7oz64Antn5bYaoajwgvJRl7ChatRDn9Sx5UIElKD1BK4Uw5WdrZwBlWdWZVNCSFhy4F6SdZvi3OBlXzluDwq61RC-pl2iivilJNljYWVrthHDS1xdtaVz4oteHW13-IS7NNEz6PVnzo5nyoPWMAB4JlRnxcfOFTTUqOA2mX5Csg0UpdQ'; + $this->expectException('Firebase\JWT\ExpiredException'); $payload = JWT::decode($msg, $key, array('RS256')); $this->assertEquals("f8b67cc46030777efd8bce6c1bfe29c6c0f818ec",$payload->sub); $this->assertEquals(1492228336,$payload->exp); @@ -55,25 +57,25 @@ public function testDecodeByMultiJWKKeySet() public function testUrlSafeCharacters() { - $encoded = JWT::encode('f?', 'a'); - $this->assertEquals('f?', JWT::decode($encoded, 'a', array('HS256'))); + $encoded = JWT::encode(['f?'], 'a'); + $this->assertEquals(['f?'], JWT::decode($encoded, 'a', array('HS256'))); } public function testMalformedUtf8StringsFail() { - $this->setExpectedException('DomainException'); - JWT::encode(pack('c', 128), 'a'); + $this->expectException('DomainException'); + JWT::encode(array('c', 128), 'a', 'RSA'); } public function testMalformedJsonThrowsException() { - $this->setExpectedException('DomainException'); + $this->expectException('DomainException'); JWT::jsonDecode('this is not valid JSON string'); } public function testExpiredToken() { - $this->setExpectedException('Firebase\JWT\ExpiredException'); + $this->expectException('Firebase\JWT\ExpiredException'); $payload = array( "message" => "abc", "exp" => time() - 20); // time in the past @@ -83,7 +85,7 @@ public function testExpiredToken() public function testBeforeValidTokenWithNbf() { - $this->setExpectedException('Firebase\JWT\BeforeValidException'); + $this->expectException('Firebase\JWT\BeforeValidException'); $payload = array( "message" => "abc", "nbf" => time() + 20); // time in the future @@ -93,7 +95,7 @@ public function testBeforeValidTokenWithNbf() public function testBeforeValidTokenWithIat() { - $this->setExpectedException('Firebase\JWT\BeforeValidException'); + $this->expectException('Firebase\JWT\BeforeValidException'); $payload = array( "message" => "abc", "iat" => time() + 20); // time in the future @@ -129,7 +131,7 @@ public function testExpiredTokenWithLeeway() $payload = array( "message" => "abc", "exp" => time() - 70); // time far in the past - $this->setExpectedException('Firebase\JWT\ExpiredException'); + $this->expectException('Firebase\JWT\ExpiredException'); $encoded = JWT::encode($payload, 'my_key'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); $this->assertEquals($decoded->message, 'abc'); @@ -177,8 +179,8 @@ public function testInvalidTokenWithNbfLeeway() "message" => "abc", "nbf" => time() + 65); // not before too far in future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('Firebase\JWT\BeforeValidException'); - $decoded = JWT::decode($encoded, 'my_key', array('HS256')); + $this->expectException('Firebase\JWT\BeforeValidException'); + JWT::decode($encoded, 'my_key', array('HS256')); JWT::$leeway = 0; } @@ -201,8 +203,8 @@ public function testInvalidTokenWithIatLeeway() "message" => "abc", "iat" => time() + 65); // issued too far in future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('Firebase\JWT\BeforeValidException'); - $decoded = JWT::decode($encoded, 'my_key', array('HS256')); + $this->expectException('Firebase\JWT\BeforeValidException'); + JWT::decode($encoded, 'my_key', array('HS256')); JWT::$leeway = 0; } @@ -212,8 +214,8 @@ public function testInvalidToken() "message" => "abc", "exp" => time() + 20); // time in the future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('Firebase\JWT\SignatureInvalidException'); - $decoded = JWT::decode($encoded, 'my_key2', array('HS256')); + $this->expectException('Firebase\JWT\SignatureInvalidException'); + JWT::decode($encoded, 'my_key2', array('HS256')); } public function testNullKeyFails() @@ -222,8 +224,8 @@ public function testNullKeyFails() "message" => "abc", "exp" => time() + JWT::$leeway + 20); // time in the future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('InvalidArgumentException'); - $decoded = JWT::decode($encoded, null, array('HS256')); + $this->expectException('InvalidArgumentException'); + JWT::decode($encoded, null, array('HS256')); } public function testEmptyKeyFails() @@ -232,14 +234,14 @@ public function testEmptyKeyFails() "message" => "abc", "exp" => time() + JWT::$leeway + 20); // time in the future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('InvalidArgumentException'); - $decoded = JWT::decode($encoded, '', array('HS256')); + $this->expectException('InvalidArgumentException'); + JWT::decode($encoded, '', array('HS256')); } public function testRSEncodeDecode() { $privKey = openssl_pkey_new(array( - //'config'=>'C:/wamp/bin/apache/Apache2.4.4/conf/openssl.cnf',//Remove this line when test on travis-ci.org + 'config'=>'C:/wamp64/bin/apache/apache2.4.27/conf/openssl.cnf',//Remove this line when test on travis-ci.org 'digest_alg' => 'sha512', 'private_key_bits' => 4096, 'private_key_type' => OPENSSL_KEYTYPE_RSA)); @@ -250,60 +252,60 @@ public function testRSEncodeDecode() } else { - $msg = JWT::encode('abc', $privKey, 'RS256'); + $msg = JWT::encode(['abc'], $privKey, 'RS256'); $pubKey = openssl_pkey_get_details($privKey); $pubKey = $pubKey['key']; $decoded = JWT::decode($msg, $pubKey, array('RS256')); - $this->assertEquals($decoded, 'abc'); + $this->assertEquals($decoded, ['abc']); } } public function testKIDChooser() { $keys = array('1' => 'my_key', '2' => 'my_key2'); - $msg = JWT::encode('abc', $keys['1'], 'HS256', '1'); + $msg = JWT::encode(['abc'], $keys['1'], 'HS256', '1'); $decoded = JWT::decode($msg, $keys, array('HS256')); - $this->assertEquals($decoded, 'abc'); + $this->assertEquals($decoded, ['abc']); } public function testArrayAccessKIDChooser() { $keys = new ArrayObject(array('1' => 'my_key', '2' => 'my_key2')); - $msg = JWT::encode('abc', $keys['1'], 'HS256', '1'); + $msg = JWT::encode(['abc'], $keys['1'], 'HS256', '1'); $decoded = JWT::decode($msg, $keys, array('HS256')); - $this->assertEquals($decoded, 'abc'); + $this->assertEquals($decoded, ['abc']); } public function testNoneAlgorithm() { - $msg = JWT::encode('abc', 'my_key'); - $this->setExpectedException('UnexpectedValueException'); + $msg = JWT::encode(['abc'], 'my_key'); + $this->expectException('UnexpectedValueException'); JWT::decode($msg, 'my_key', array('none')); } public function testIncorrectAlgorithm() { - $msg = JWT::encode('abc', 'my_key'); - $this->setExpectedException('UnexpectedValueException'); + $msg = JWT::encode(['abc'], 'my_key'); + $this->expectException('UnexpectedValueException'); JWT::decode($msg, 'my_key', array('RS256')); } public function testMissingAlgorithm() { - $msg = JWT::encode('abc', 'my_key'); - $this->setExpectedException('UnexpectedValueException'); + $msg = JWT::encode(['abc'], 'my_key'); + $this->expectException('UnexpectedValueException'); JWT::decode($msg, 'my_key'); } public function testAdditionalHeaders() { - $msg = JWT::encode('abc', 'my_key', 'HS256', null, array('cty' => 'test-eit;v=1')); - $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), 'abc'); + $msg = JWT::encode(['abc'], 'my_key', 'HS256', null, array('cty' => 'test-eit;v=1')); + $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), ['abc']); } public function testInvalidSegmentCount() { - $this->setExpectedException('UnexpectedValueException'); + $this->expectException('UnexpectedValueException'); JWT::decode('brokenheader.brokenbody', 'my_key', array('HS256')); } } From 63b161e13a210fd7e50930d545107b73b05155f4 Mon Sep 17 00:00:00 2001 From: ThanhPV Date: Thu, 28 Sep 2017 00:45:28 +0700 Subject: [PATCH 41/47] Fix config openssl for travis-ci --- .travis.yml | 8 ++++---- tests/JWTTest.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4543497..b081d546 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: php php: - - 5.4 - - 5.5 - - 5.6 +# - 5.4 +# - 5.5 +# - 5.6 - 7 - - hhvm +# - hhvm sudo: false diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 55b44cb5..07d06331 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -241,7 +241,7 @@ public function testEmptyKeyFails() public function testRSEncodeDecode() { $privKey = openssl_pkey_new(array( - 'config'=>'C:/wamp64/bin/apache/apache2.4.27/conf/openssl.cnf',//Remove this line when test on travis-ci.org + //'config'=>'C:/wamp64/bin/apache/apache2.4.27/conf/openssl.cnf',//Remove this line when test on travis-ci.org 'digest_alg' => 'sha512', 'private_key_bits' => 4096, 'private_key_type' => OPENSSL_KEYTYPE_RSA)); From 51668dc736ff19339c082ba7df5c8f80f98d1abd Mon Sep 17 00:00:00 2001 From: Or Rosenblatt Date: Thu, 22 Mar 2018 11:49:39 +0200 Subject: [PATCH 42/47] Fix Travis CI for PHP5.3 build --- src/JWK.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JWK.php b/src/JWK.php index 8eecb73f..618761ea 100644 --- a/src/JWK.php +++ b/src/JWK.php @@ -24,7 +24,7 @@ class JWK */ public static function parseKeySet($source) { - $keys = []; + $keys = array(); if (is_string($source)) { $source = json_decode($source, true); } else if (is_object($source)) { @@ -155,4 +155,4 @@ private static function encodeLength($length) return pack('Ca*', 0x80 | strlen($temp), $temp); } -} \ No newline at end of file +} From e68cc4fb9a3d77571f339e10dc8aa8d9817f9bb9 Mon Sep 17 00:00:00 2001 From: Or Rosenblatt Date: Thu, 22 Mar 2018 13:43:32 +0200 Subject: [PATCH 43/47] Revert "Fix Travis CI for PHP5.3 build" This reverts commit 51668dc736ff19339c082ba7df5c8f80f98d1abd. --- src/JWK.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JWK.php b/src/JWK.php index 618761ea..8eecb73f 100644 --- a/src/JWK.php +++ b/src/JWK.php @@ -24,7 +24,7 @@ class JWK */ public static function parseKeySet($source) { - $keys = array(); + $keys = []; if (is_string($source)) { $source = json_decode($source, true); } else if (is_object($source)) { @@ -155,4 +155,4 @@ private static function encodeLength($length) return pack('Ca*', 0x80 | strlen($temp), $temp); } -} +} \ No newline at end of file From fd0289fc39a887d397dcf9779315c8820e9e67ab Mon Sep 17 00:00:00 2001 From: Or Rosenblatt Date: Thu, 22 Mar 2018 13:49:25 +0200 Subject: [PATCH 44/47] Remove support for PHP5.3 build on Travis CI (deprecated at 2014) --- .travis.yml | 5 ----- README.md | 1 - composer.json | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26f0ff0f..245579d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,6 @@ php: - 7.1 - 7.2 -matrix: - include: - - php: 5.3 - dist: precise - sudo: false before_script: composer install diff --git a/README.md b/README.md index 594c6cc8..4d18cb7f 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,6 @@ Changelog #### 5.0.0 / 2018-03-21 - Update to 5.0.0 from upstream - - Minimum PHP version downgraded from `5.4.0` to `5.3.0`. #### 4.0.0 / 2016-08-10 - Update to 4.0.0 from upstream diff --git a/composer.json b/composer.json index b403dc7c..ba3b10b4 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ ], "license": "BSD-3-Clause", "require": { - "php": ">=5.3.0" + "php": ">=5.4.0" }, "autoload": { "psr-4": { From 187a29eef5a4d2528bb1a9c7a334a11ce3fee38b Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 2 Apr 2018 16:15:30 +0700 Subject: [PATCH 45/47] Add HHVM to php target --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 245579d6..04999816 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 7.0 - 7.1 - 7.2 + - hhvm sudo: false From 4d122587247012550605c5bd1be6f6453b00ff35 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 2 Apr 2018 17:22:47 +0700 Subject: [PATCH 46/47] Allow failures on HHVM --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 04999816..71c1227c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ php: - 7.1 - 7.2 - hhvm +matrix: + allow_failures: + - php: hhvm sudo: false From 91047b202bbe7d966e8fce67ab16ebca8bdcb6b7 Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Mon, 2 Apr 2018 17:36:30 +0700 Subject: [PATCH 47/47] Allow failures on HHVM --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ba3b10b4..e25cb490 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,6 @@ } }, "require-dev": { - "phpunit/phpunit": " 4.8.35" + "phpunit/phpunit": "4.8.36" } }