├── .env.example ├── .gitignore ├── LICENSE ├── README.md ├── bootstrap.php ├── composer.json ├── composer.lock ├── dbseed.php ├── public ├── client.php └── index.php └── src ├── Controller └── PersonController.php ├── System └── DatabaseConnector.php └── TableGateways └── PersonGateway.php /.env.example: -------------------------------------------------------------------------------- 1 | OKTAAUDIENCE=api://default 2 | OKTAISSUER= 3 | SCOPE= 4 | OKTACLIENTID= 5 | OKTASECRET= 6 | 7 | DB_HOST=localhost 8 | DB_PORT=3306 9 | DB_DATABASE= 10 | DB_USERNAME= 11 | DB_PASSWORD= 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | .env 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build a Simple REST API in PHP 2 | 3 | This example shows how to build a simple REST API in core PHP and secure it with Okta using OAuth 2.0 Client Credentials Flow. 4 | 5 | Please read https://developer.okta.com/blog/2019/03/08/simple-rest-api-php to see how this application was built. 6 | 7 | **Prerequisites:** PHP, Composer, MySQL, [Okta developer account](https://developer.okta.com/) 8 | 9 | > [Okta](https://developer.okta.com) has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage, and secure users and roles in any application. 10 | 11 | ## Getting Started 12 | 13 | Sign up for an [Okta developer account](https://developer.okta.com) and create a new application. Make note of the Client ID and Issuer values for your application. 14 | 15 | Clone this project using the following commands: 16 | 17 | ``` 18 | git@github.com:oktadeveloper/okta-php-core-rest-api-example.git 19 | cd okta-php-core-rest-api-example 20 | ``` 21 | 22 | ### Configure the application 23 | 24 | Create the database and user for the project: 25 | 26 | ``` 27 | mysql -uroot -p 28 | CREATE DATABASE api_example CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 29 | CREATE USER 'api_user'@'localhost' identified by 'api_password'; 30 | GRANT ALL on api_example.* to 'api_user'@'localhost'; 31 | quit 32 | ``` 33 | 34 | Copy and edit the `.env` file and enter your database details and Okta details there: 35 | 36 | ``` 37 | cp .env.example .env 38 | ``` 39 | 40 | Install the project dependencies and start the PHP server: 41 | 42 | ``` 43 | composer install 44 | cd public 45 | php -S 127.0.0.1:8000 46 | ``` 47 | 48 | Loading [127.0.0.1:8000/person](127.0.0.1:8000/person) should return a 401 Unauthorized response now. 49 | 50 | NOTE: if using a virtual machine and NAT, you might need to run the server as `php -S 0.0.0.0:8000 -t public` instead. 51 | 52 | ### Run the client application 53 | 54 | In the public directory, simply run: 55 | 56 | ``` 57 | php client.php 58 | ``` 59 | 60 | If you see 'Obtaining token...success!' on the first line then Okta authentication is working correctly. After that, you should see the client app execute some API requests and dump the output. 61 | 62 | ## Help 63 | 64 | Please post any questions as comments on the
, or visit our [Okta Developer Forums](https://devforum.okta.com/). You can also email developers@okta.com if would like to create a support ticket. 65 | 66 | ## License 67 | 68 | Apache 2.0, see [LICENSE](LICENSE). 69 | -------------------------------------------------------------------------------- /bootstrap.php: -------------------------------------------------------------------------------- 1 | load(); 9 | 10 | $dbConnection = (new DatabaseConnector())->getConnection(); 11 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "vlucas/phpdotenv": "^2.4", 4 | "okta/jwt-verifier": "^0.2.1", 5 | "spomky-labs/jose": "^7.1", 6 | "guzzlehttp/psr7": "^1.4" 7 | }, 8 | "autoload": { 9 | "psr-4": { 10 | "Src\\": "src/" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "61dec1b9c9bbdebe9f373df9a30dd145", 8 | "packages": [ 9 | { 10 | "name": "beberlei/assert", 11 | "version": "v2.9.6", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/beberlei/assert.git", 15 | "reference": "ec9e4cf0b63890edce844ee3922e2b95a526e936" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/beberlei/assert/zipball/ec9e4cf0b63890edce844ee3922e2b95a526e936", 20 | "reference": "ec9e4cf0b63890edce844ee3922e2b95a526e936", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-mbstring": "*", 25 | "php": ">=5.3" 26 | }, 27 | "require-dev": { 28 | "friendsofphp/php-cs-fixer": "^2.1.1", 29 | "phpunit/phpunit": "^4.8.35|^5.7" 30 | }, 31 | "type": "library", 32 | "autoload": { 33 | "psr-4": { 34 | "Assert\\": "lib/Assert" 35 | }, 36 | "files": [ 37 | "lib/Assert/functions.php" 38 | ] 39 | }, 40 | "notification-url": "https://packagist.org/downloads/", 41 | "license": [ 42 | "BSD-2-Clause" 43 | ], 44 | "authors": [ 45 | { 46 | "name": "Benjamin Eberlei", 47 | "email": "kontakt@beberlei.de", 48 | "role": "Lead Developer" 49 | }, 50 | { 51 | "name": "Richard Quadling", 52 | "email": "rquadling@gmail.com", 53 | "role": "Collaborator" 54 | } 55 | ], 56 | "description": "Thin assertion library for input validation in business models.", 57 | "keywords": [ 58 | "assert", 59 | "assertion", 60 | "validation" 61 | ], 62 | "time": "2018-06-11T17:15:25+00:00" 63 | }, 64 | { 65 | "name": "clue/stream-filter", 66 | "version": "v1.4.0", 67 | "source": { 68 | "type": "git", 69 | "url": "https://github.com/clue/php-stream-filter.git", 70 | "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0" 71 | }, 72 | "dist": { 73 | "type": "zip", 74 | "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", 75 | "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", 76 | "shasum": "" 77 | }, 78 | "require": { 79 | "php": ">=5.3" 80 | }, 81 | "require-dev": { 82 | "phpunit/phpunit": "^5.0 || ^4.8" 83 | }, 84 | "type": "library", 85 | "autoload": { 86 | "psr-4": { 87 | "Clue\\StreamFilter\\": "src/" 88 | }, 89 | "files": [ 90 | "src/functions.php" 91 | ] 92 | }, 93 | "notification-url": "https://packagist.org/downloads/", 94 | "license": [ 95 | "MIT" 96 | ], 97 | "authors": [ 98 | { 99 | "name": "Christian Lück", 100 | "email": "christian@lueck.tv" 101 | } 102 | ], 103 | "description": "A simple and modern approach to stream filtering in PHP", 104 | "homepage": "https://github.com/clue/php-stream-filter", 105 | "keywords": [ 106 | "bucket brigade", 107 | "callback", 108 | "filter", 109 | "php_user_filter", 110 | "stream", 111 | "stream_filter_append", 112 | "stream_filter_register" 113 | ], 114 | "time": "2017-08-18T09:54:01+00:00" 115 | }, 116 | { 117 | "name": "fgrosse/phpasn1", 118 | "version": "v2.1.1", 119 | "source": { 120 | "type": "git", 121 | "url": "https://github.com/fgrosse/PHPASN1.git", 122 | "reference": "7ebf2a09084a7bbdb7b879c66fdf7ad80461bbe8" 123 | }, 124 | "dist": { 125 | "type": "zip", 126 | "url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/7ebf2a09084a7bbdb7b879c66fdf7ad80461bbe8", 127 | "reference": "7ebf2a09084a7bbdb7b879c66fdf7ad80461bbe8", 128 | "shasum": "" 129 | }, 130 | "require": { 131 | "php": ">=7.0.0" 132 | }, 133 | "require-dev": { 134 | "phpunit/phpunit": "~6.3", 135 | "satooshi/php-coveralls": "~2.0" 136 | }, 137 | "suggest": { 138 | "ext-gmp": "GMP is the preferred extension for big integer calculations", 139 | "php-curl": "For loading OID information from the web if they have not bee defined statically" 140 | }, 141 | "type": "library", 142 | "extra": { 143 | "branch-alias": { 144 | "dev-master": "2.0.x-dev" 145 | } 146 | }, 147 | "autoload": { 148 | "psr-4": { 149 | "FG\\": "lib/" 150 | } 151 | }, 152 | "notification-url": "https://packagist.org/downloads/", 153 | "license": [ 154 | "MIT" 155 | ], 156 | "authors": [ 157 | { 158 | "name": "Friedrich Große", 159 | "email": "friedrich.grosse@gmail.com", 160 | "homepage": "https://github.com/FGrosse", 161 | "role": "Author" 162 | }, 163 | { 164 | "name": "All contributors", 165 | "homepage": "https://github.com/FGrosse/PHPASN1/contributors" 166 | } 167 | ], 168 | "description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.", 169 | "homepage": "https://github.com/FGrosse/PHPASN1", 170 | "keywords": [ 171 | "DER", 172 | "asn.1", 173 | "asn1", 174 | "ber", 175 | "binary", 176 | "decoding", 177 | "encoding", 178 | "x.509", 179 | "x.690", 180 | "x509", 181 | "x690" 182 | ], 183 | "time": "2018-12-02T01:34:34+00:00" 184 | }, 185 | { 186 | "name": "guzzlehttp/psr7", 187 | "version": "1.4.2", 188 | "source": { 189 | "type": "git", 190 | "url": "https://github.com/guzzle/psr7.git", 191 | "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" 192 | }, 193 | "dist": { 194 | "type": "zip", 195 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", 196 | "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", 197 | "shasum": "" 198 | }, 199 | "require": { 200 | "php": ">=5.4.0", 201 | "psr/http-message": "~1.0" 202 | }, 203 | "provide": { 204 | "psr/http-message-implementation": "1.0" 205 | }, 206 | "require-dev": { 207 | "phpunit/phpunit": "~4.0" 208 | }, 209 | "type": "library", 210 | "extra": { 211 | "branch-alias": { 212 | "dev-master": "1.4-dev" 213 | } 214 | }, 215 | "autoload": { 216 | "psr-4": { 217 | "GuzzleHttp\\Psr7\\": "src/" 218 | }, 219 | "files": [ 220 | "src/functions_include.php" 221 | ] 222 | }, 223 | "notification-url": "https://packagist.org/downloads/", 224 | "license": [ 225 | "MIT" 226 | ], 227 | "authors": [ 228 | { 229 | "name": "Michael Dowling", 230 | "email": "mtdowling@gmail.com", 231 | "homepage": "https://github.com/mtdowling" 232 | }, 233 | { 234 | "name": "Tobias Schultze", 235 | "homepage": "https://github.com/Tobion" 236 | } 237 | ], 238 | "description": "PSR-7 message implementation that also provides common utility methods", 239 | "keywords": [ 240 | "http", 241 | "message", 242 | "request", 243 | "response", 244 | "stream", 245 | "uri", 246 | "url" 247 | ], 248 | "time": "2017-03-20T17:10:46+00:00" 249 | }, 250 | { 251 | "name": "mdanter/ecc", 252 | "version": "v0.5.1", 253 | "source": { 254 | "type": "git", 255 | "url": "https://github.com/phpecc/phpecc.git", 256 | "reference": "9a3aca17c6dfc04bdaad2e7ddab3b8df656ffc5b" 257 | }, 258 | "dist": { 259 | "type": "zip", 260 | "url": "https://api.github.com/repos/phpecc/phpecc/zipball/9a3aca17c6dfc04bdaad2e7ddab3b8df656ffc5b", 261 | "reference": "9a3aca17c6dfc04bdaad2e7ddab3b8df656ffc5b", 262 | "shasum": "" 263 | }, 264 | "require": { 265 | "ext-gmp": "*", 266 | "fgrosse/phpasn1": "^2.0", 267 | "php": "^7.0" 268 | }, 269 | "require-dev": { 270 | "phpunit/phpunit": "^6.0", 271 | "squizlabs/php_codesniffer": "^2.0", 272 | "symfony/yaml": "^2.6|^3.0" 273 | }, 274 | "type": "library", 275 | "autoload": { 276 | "psr-4": { 277 | "Mdanter\\Ecc\\": "src/" 278 | } 279 | }, 280 | "notification-url": "https://packagist.org/downloads/", 281 | "license": [ 282 | "MIT" 283 | ], 284 | "authors": [ 285 | { 286 | "name": "Matyas Danter", 287 | "homepage": "http://matejdanter.com/", 288 | "role": "Author" 289 | }, 290 | { 291 | "name": "Thibaud Fabre", 292 | "email": "thibaud@aztech.io", 293 | "homepage": "http://aztech.io", 294 | "role": "Maintainer" 295 | }, 296 | { 297 | "name": "Thomas Kerin", 298 | "email": "afk11@users.noreply.github.com", 299 | "role": "Maintainer" 300 | } 301 | ], 302 | "description": "PHP Elliptic Curve Cryptography library", 303 | "homepage": "https://github.com/phpecc/phpecc", 304 | "keywords": [ 305 | "Diffie", 306 | "ECDSA", 307 | "Hellman", 308 | "curve", 309 | "ecdh", 310 | "elliptic", 311 | "nistp192", 312 | "nistp224", 313 | "nistp256", 314 | "nistp384", 315 | "nistp521", 316 | "phpecc", 317 | "secp256k1", 318 | "secp256r1" 319 | ], 320 | "time": "2018-12-01T23:35:23+00:00" 321 | }, 322 | { 323 | "name": "nesbot/carbon", 324 | "version": "1.36.1", 325 | "source": { 326 | "type": "git", 327 | "url": "https://github.com/briannesbitt/Carbon.git", 328 | "reference": "63da8cdf89d7a5efe43aabc794365f6e7b7b8983" 329 | }, 330 | "dist": { 331 | "type": "zip", 332 | "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/63da8cdf89d7a5efe43aabc794365f6e7b7b8983", 333 | "reference": "63da8cdf89d7a5efe43aabc794365f6e7b7b8983", 334 | "shasum": "" 335 | }, 336 | "require": { 337 | "php": ">=5.3.9", 338 | "symfony/translation": "~2.6 || ~3.0 || ~4.0" 339 | }, 340 | "require-dev": { 341 | "phpunit/phpunit": "^4.8.35 || ^5.7" 342 | }, 343 | "suggest": { 344 | "friendsofphp/php-cs-fixer": "Needed for the `composer phpcs` command. Allow to automatically fix code style.", 345 | "phpstan/phpstan": "Needed for the `composer phpstan` command. Allow to detect potential errors." 346 | }, 347 | "type": "library", 348 | "extra": { 349 | "laravel": { 350 | "providers": [ 351 | "Carbon\\Laravel\\ServiceProvider" 352 | ] 353 | } 354 | }, 355 | "autoload": { 356 | "psr-4": { 357 | "": "src/" 358 | } 359 | }, 360 | "notification-url": "https://packagist.org/downloads/", 361 | "license": [ 362 | "MIT" 363 | ], 364 | "authors": [ 365 | { 366 | "name": "Brian Nesbitt", 367 | "email": "brian@nesbot.com", 368 | "homepage": "http://nesbot.com" 369 | } 370 | ], 371 | "description": "A simple API extension for DateTime.", 372 | "homepage": "http://carbon.nesbot.com", 373 | "keywords": [ 374 | "date", 375 | "datetime", 376 | "time" 377 | ], 378 | "time": "2018-11-22T18:23:02+00:00" 379 | }, 380 | { 381 | "name": "okta/jwt-verifier", 382 | "version": "0.2.1", 383 | "source": { 384 | "type": "git", 385 | "url": "https://github.com/okta/okta-jwt-verifier-php.git", 386 | "reference": "0afbcc6406ddeb82913a6abba1aafbc1dc44d237" 387 | }, 388 | "dist": { 389 | "type": "zip", 390 | "url": "https://api.github.com/repos/okta/okta-jwt-verifier-php/zipball/0afbcc6406ddeb82913a6abba1aafbc1dc44d237", 391 | "reference": "0afbcc6406ddeb82913a6abba1aafbc1dc44d237", 392 | "shasum": "" 393 | }, 394 | "require": { 395 | "nesbot/carbon": "^1.22", 396 | "php": "^7.0", 397 | "php-http/client-common": "^1.1", 398 | "php-http/curl-client": "^1.7", 399 | "php-http/discovery": "^1.2", 400 | "php-http/httplug": "^1.1", 401 | "php-http/message": "^1.5", 402 | "psr/http-message": "^1.0", 403 | "symfony/yaml": "^3.2|^4.0" 404 | }, 405 | "require-dev": { 406 | "firebase/php-jwt": "^5.0", 407 | "guzzlehttp/psr7": "^1.4", 408 | "php-http/mock-client": "^1.0", 409 | "phpunit/phpunit": "^6.2", 410 | "spomky-labs/jose": "^6.1", 411 | "squizlabs/php_codesniffer": "3.0.1", 412 | "symfony/var-dumper": "^3.2" 413 | }, 414 | "type": "library", 415 | "autoload": { 416 | "psr-4": { 417 | "Okta\\JwtVerifier\\": "src/" 418 | } 419 | }, 420 | "notification-url": "https://packagist.org/downloads/", 421 | "license": [ 422 | "Apache-2.0" 423 | ], 424 | "authors": [ 425 | { 426 | "name": "Brian Retterer", 427 | "email": "brian.retterer@okta.com" 428 | } 429 | ], 430 | "description": "A verifier library for working with Okta JWT's", 431 | "time": "2018-05-19T01:39:03+00:00" 432 | }, 433 | { 434 | "name": "php-http/client-common", 435 | "version": "1.8.1", 436 | "source": { 437 | "type": "git", 438 | "url": "https://github.com/php-http/client-common.git", 439 | "reference": "0b9ce659aa46aee106f8c66597ea0c070fcd9dff" 440 | }, 441 | "dist": { 442 | "type": "zip", 443 | "url": "https://api.github.com/repos/php-http/client-common/zipball/0b9ce659aa46aee106f8c66597ea0c070fcd9dff", 444 | "reference": "0b9ce659aa46aee106f8c66597ea0c070fcd9dff", 445 | "shasum": "" 446 | }, 447 | "require": { 448 | "php": "^5.4 || ^7.0", 449 | "php-http/httplug": "^1.1", 450 | "php-http/message": "^1.6", 451 | "php-http/message-factory": "^1.0", 452 | "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" 453 | }, 454 | "require-dev": { 455 | "guzzlehttp/psr7": "^1.4", 456 | "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2" 457 | }, 458 | "suggest": { 459 | "php-http/cache-plugin": "PSR-6 Cache plugin", 460 | "php-http/logger-plugin": "PSR-3 Logger plugin", 461 | "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" 462 | }, 463 | "type": "library", 464 | "extra": { 465 | "branch-alias": { 466 | "dev-master": "1.8-dev" 467 | } 468 | }, 469 | "autoload": { 470 | "psr-4": { 471 | "Http\\Client\\Common\\": "src/" 472 | } 473 | }, 474 | "notification-url": "https://packagist.org/downloads/", 475 | "license": [ 476 | "MIT" 477 | ], 478 | "authors": [ 479 | { 480 | "name": "Márk Sági-Kazár", 481 | "email": "mark.sagikazar@gmail.com" 482 | } 483 | ], 484 | "description": "Common HTTP Client implementations and tools for HTTPlug", 485 | "homepage": "http://httplug.io", 486 | "keywords": [ 487 | "client", 488 | "common", 489 | "http", 490 | "httplug" 491 | ], 492 | "time": "2018-10-09T06:46:29+00:00" 493 | }, 494 | { 495 | "name": "php-http/curl-client", 496 | "version": "v1.7.1", 497 | "source": { 498 | "type": "git", 499 | "url": "https://github.com/php-http/curl-client.git", 500 | "reference": "6341a93d00e5d953fc868a3928b5167e6513f2b6" 501 | }, 502 | "dist": { 503 | "type": "zip", 504 | "url": "https://api.github.com/repos/php-http/curl-client/zipball/6341a93d00e5d953fc868a3928b5167e6513f2b6", 505 | "reference": "6341a93d00e5d953fc868a3928b5167e6513f2b6", 506 | "shasum": "" 507 | }, 508 | "require": { 509 | "ext-curl": "*", 510 | "php": "^5.5 || ^7.0", 511 | "php-http/discovery": "^1.0", 512 | "php-http/httplug": "^1.0", 513 | "php-http/message": "^1.2", 514 | "php-http/message-factory": "^1.0.2" 515 | }, 516 | "provide": { 517 | "php-http/async-client-implementation": "1.0", 518 | "php-http/client-implementation": "1.0" 519 | }, 520 | "require-dev": { 521 | "guzzlehttp/psr7": "^1.0", 522 | "php-http/client-integration-tests": "^0.6", 523 | "phpunit/phpunit": "^4.8.27", 524 | "zendframework/zend-diactoros": "^1.0" 525 | }, 526 | "type": "library", 527 | "autoload": { 528 | "psr-4": { 529 | "Http\\Client\\Curl\\": "src/" 530 | } 531 | }, 532 | "notification-url": "https://packagist.org/downloads/", 533 | "license": [ 534 | "MIT" 535 | ], 536 | "authors": [ 537 | { 538 | "name": "Михаил Красильников", 539 | "email": "m.krasilnikov@yandex.ru" 540 | } 541 | ], 542 | "description": "cURL client for PHP-HTTP", 543 | "homepage": "http://php-http.org", 544 | "keywords": [ 545 | "curl", 546 | "http" 547 | ], 548 | "time": "2018-03-26T19:21:48+00:00" 549 | }, 550 | { 551 | "name": "php-http/discovery", 552 | "version": "1.4.0", 553 | "source": { 554 | "type": "git", 555 | "url": "https://github.com/php-http/discovery.git", 556 | "reference": "9a6cb24de552bfe1aa9d7d1569e2d49c5b169a33" 557 | }, 558 | "dist": { 559 | "type": "zip", 560 | "url": "https://api.github.com/repos/php-http/discovery/zipball/9a6cb24de552bfe1aa9d7d1569e2d49c5b169a33", 561 | "reference": "9a6cb24de552bfe1aa9d7d1569e2d49c5b169a33", 562 | "shasum": "" 563 | }, 564 | "require": { 565 | "php": "^5.5 || ^7.0" 566 | }, 567 | "require-dev": { 568 | "henrikbjorn/phpspec-code-coverage": "^2.0.2", 569 | "php-http/httplug": "^1.0", 570 | "php-http/message-factory": "^1.0", 571 | "phpspec/phpspec": "^2.4", 572 | "puli/composer-plugin": "1.0.0-beta10" 573 | }, 574 | "suggest": { 575 | "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", 576 | "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." 577 | }, 578 | "type": "library", 579 | "extra": { 580 | "branch-alias": { 581 | "dev-master": "1.3-dev" 582 | } 583 | }, 584 | "autoload": { 585 | "psr-4": { 586 | "Http\\Discovery\\": "src/" 587 | } 588 | }, 589 | "notification-url": "https://packagist.org/downloads/", 590 | "license": [ 591 | "MIT" 592 | ], 593 | "authors": [ 594 | { 595 | "name": "Márk Sági-Kazár", 596 | "email": "mark.sagikazar@gmail.com" 597 | } 598 | ], 599 | "description": "Finds installed HTTPlug implementations and PSR-7 message factories", 600 | "homepage": "http://php-http.org", 601 | "keywords": [ 602 | "adapter", 603 | "client", 604 | "discovery", 605 | "factory", 606 | "http", 607 | "message", 608 | "psr7" 609 | ], 610 | "time": "2018-02-06T10:55:24+00:00" 611 | }, 612 | { 613 | "name": "php-http/httplug", 614 | "version": "v1.1.0", 615 | "source": { 616 | "type": "git", 617 | "url": "https://github.com/php-http/httplug.git", 618 | "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" 619 | }, 620 | "dist": { 621 | "type": "zip", 622 | "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", 623 | "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", 624 | "shasum": "" 625 | }, 626 | "require": { 627 | "php": ">=5.4", 628 | "php-http/promise": "^1.0", 629 | "psr/http-message": "^1.0" 630 | }, 631 | "require-dev": { 632 | "henrikbjorn/phpspec-code-coverage": "^1.0", 633 | "phpspec/phpspec": "^2.4" 634 | }, 635 | "type": "library", 636 | "extra": { 637 | "branch-alias": { 638 | "dev-master": "1.1-dev" 639 | } 640 | }, 641 | "autoload": { 642 | "psr-4": { 643 | "Http\\Client\\": "src/" 644 | } 645 | }, 646 | "notification-url": "https://packagist.org/downloads/", 647 | "license": [ 648 | "MIT" 649 | ], 650 | "authors": [ 651 | { 652 | "name": "Eric GELOEN", 653 | "email": "geloen.eric@gmail.com" 654 | }, 655 | { 656 | "name": "Márk Sági-Kazár", 657 | "email": "mark.sagikazar@gmail.com" 658 | } 659 | ], 660 | "description": "HTTPlug, the HTTP client abstraction for PHP", 661 | "homepage": "http://httplug.io", 662 | "keywords": [ 663 | "client", 664 | "http" 665 | ], 666 | "time": "2016-08-31T08:30:17+00:00" 667 | }, 668 | { 669 | "name": "php-http/message", 670 | "version": "1.7.2", 671 | "source": { 672 | "type": "git", 673 | "url": "https://github.com/php-http/message.git", 674 | "reference": "b159ffe570dffd335e22ef0b91a946eacb182fa1" 675 | }, 676 | "dist": { 677 | "type": "zip", 678 | "url": "https://api.github.com/repos/php-http/message/zipball/b159ffe570dffd335e22ef0b91a946eacb182fa1", 679 | "reference": "b159ffe570dffd335e22ef0b91a946eacb182fa1", 680 | "shasum": "" 681 | }, 682 | "require": { 683 | "clue/stream-filter": "^1.4", 684 | "php": "^5.4 || ^7.0", 685 | "php-http/message-factory": "^1.0.2", 686 | "psr/http-message": "^1.0" 687 | }, 688 | "provide": { 689 | "php-http/message-factory-implementation": "1.0" 690 | }, 691 | "require-dev": { 692 | "akeneo/phpspec-skip-example-extension": "^1.0", 693 | "coduo/phpspec-data-provider-extension": "^1.0", 694 | "ext-zlib": "*", 695 | "guzzlehttp/psr7": "^1.0", 696 | "henrikbjorn/phpspec-code-coverage": "^1.0", 697 | "phpspec/phpspec": "^2.4", 698 | "slim/slim": "^3.0", 699 | "zendframework/zend-diactoros": "^1.0" 700 | }, 701 | "suggest": { 702 | "ext-zlib": "Used with compressor/decompressor streams", 703 | "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", 704 | "slim/slim": "Used with Slim Framework PSR-7 implementation", 705 | "zendframework/zend-diactoros": "Used with Diactoros Factories" 706 | }, 707 | "type": "library", 708 | "extra": { 709 | "branch-alias": { 710 | "dev-master": "1.6-dev" 711 | } 712 | }, 713 | "autoload": { 714 | "psr-4": { 715 | "Http\\Message\\": "src/" 716 | }, 717 | "files": [ 718 | "src/filters.php" 719 | ] 720 | }, 721 | "notification-url": "https://packagist.org/downloads/", 722 | "license": [ 723 | "MIT" 724 | ], 725 | "authors": [ 726 | { 727 | "name": "Márk Sági-Kazár", 728 | "email": "mark.sagikazar@gmail.com" 729 | } 730 | ], 731 | "description": "HTTP Message related tools", 732 | "homepage": "http://php-http.org", 733 | "keywords": [ 734 | "http", 735 | "message", 736 | "psr-7" 737 | ], 738 | "time": "2018-11-01T09:32:41+00:00" 739 | }, 740 | { 741 | "name": "php-http/message-factory", 742 | "version": "v1.0.2", 743 | "source": { 744 | "type": "git", 745 | "url": "https://github.com/php-http/message-factory.git", 746 | "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" 747 | }, 748 | "dist": { 749 | "type": "zip", 750 | "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", 751 | "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", 752 | "shasum": "" 753 | }, 754 | "require": { 755 | "php": ">=5.4", 756 | "psr/http-message": "^1.0" 757 | }, 758 | "type": "library", 759 | "extra": { 760 | "branch-alias": { 761 | "dev-master": "1.0-dev" 762 | } 763 | }, 764 | "autoload": { 765 | "psr-4": { 766 | "Http\\Message\\": "src/" 767 | } 768 | }, 769 | "notification-url": "https://packagist.org/downloads/", 770 | "license": [ 771 | "MIT" 772 | ], 773 | "authors": [ 774 | { 775 | "name": "Márk Sági-Kazár", 776 | "email": "mark.sagikazar@gmail.com" 777 | } 778 | ], 779 | "description": "Factory interfaces for PSR-7 HTTP Message", 780 | "homepage": "http://php-http.org", 781 | "keywords": [ 782 | "factory", 783 | "http", 784 | "message", 785 | "stream", 786 | "uri" 787 | ], 788 | "time": "2015-12-19T14:08:53+00:00" 789 | }, 790 | { 791 | "name": "php-http/promise", 792 | "version": "v1.0.0", 793 | "source": { 794 | "type": "git", 795 | "url": "https://github.com/php-http/promise.git", 796 | "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" 797 | }, 798 | "dist": { 799 | "type": "zip", 800 | "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", 801 | "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", 802 | "shasum": "" 803 | }, 804 | "require-dev": { 805 | "henrikbjorn/phpspec-code-coverage": "^1.0", 806 | "phpspec/phpspec": "^2.4" 807 | }, 808 | "type": "library", 809 | "extra": { 810 | "branch-alias": { 811 | "dev-master": "1.1-dev" 812 | } 813 | }, 814 | "autoload": { 815 | "psr-4": { 816 | "Http\\Promise\\": "src/" 817 | } 818 | }, 819 | "notification-url": "https://packagist.org/downloads/", 820 | "license": [ 821 | "MIT" 822 | ], 823 | "authors": [ 824 | { 825 | "name": "Márk Sági-Kazár", 826 | "email": "mark.sagikazar@gmail.com" 827 | }, 828 | { 829 | "name": "Joel Wurtz", 830 | "email": "joel.wurtz@gmail.com" 831 | } 832 | ], 833 | "description": "Promise used for asynchronous HTTP requests", 834 | "homepage": "http://httplug.io", 835 | "keywords": [ 836 | "promise" 837 | ], 838 | "time": "2016-01-26T13:27:02+00:00" 839 | }, 840 | { 841 | "name": "psr/cache", 842 | "version": "1.0.1", 843 | "source": { 844 | "type": "git", 845 | "url": "https://github.com/php-fig/cache.git", 846 | "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" 847 | }, 848 | "dist": { 849 | "type": "zip", 850 | "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", 851 | "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", 852 | "shasum": "" 853 | }, 854 | "require": { 855 | "php": ">=5.3.0" 856 | }, 857 | "type": "library", 858 | "extra": { 859 | "branch-alias": { 860 | "dev-master": "1.0.x-dev" 861 | } 862 | }, 863 | "autoload": { 864 | "psr-4": { 865 | "Psr\\Cache\\": "src/" 866 | } 867 | }, 868 | "notification-url": "https://packagist.org/downloads/", 869 | "license": [ 870 | "MIT" 871 | ], 872 | "authors": [ 873 | { 874 | "name": "PHP-FIG", 875 | "homepage": "http://www.php-fig.org/" 876 | } 877 | ], 878 | "description": "Common interface for caching libraries", 879 | "keywords": [ 880 | "cache", 881 | "psr", 882 | "psr-6" 883 | ], 884 | "time": "2016-08-06T20:24:11+00:00" 885 | }, 886 | { 887 | "name": "psr/http-message", 888 | "version": "1.0.1", 889 | "source": { 890 | "type": "git", 891 | "url": "https://github.com/php-fig/http-message.git", 892 | "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" 893 | }, 894 | "dist": { 895 | "type": "zip", 896 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", 897 | "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", 898 | "shasum": "" 899 | }, 900 | "require": { 901 | "php": ">=5.3.0" 902 | }, 903 | "type": "library", 904 | "extra": { 905 | "branch-alias": { 906 | "dev-master": "1.0.x-dev" 907 | } 908 | }, 909 | "autoload": { 910 | "psr-4": { 911 | "Psr\\Http\\Message\\": "src/" 912 | } 913 | }, 914 | "notification-url": "https://packagist.org/downloads/", 915 | "license": [ 916 | "MIT" 917 | ], 918 | "authors": [ 919 | { 920 | "name": "PHP-FIG", 921 | "homepage": "http://www.php-fig.org/" 922 | } 923 | ], 924 | "description": "Common interface for HTTP messages", 925 | "homepage": "https://github.com/php-fig/http-message", 926 | "keywords": [ 927 | "http", 928 | "http-message", 929 | "psr", 930 | "psr-7", 931 | "request", 932 | "response" 933 | ], 934 | "time": "2016-08-06T14:39:51+00:00" 935 | }, 936 | { 937 | "name": "spomky-labs/aes-key-wrap", 938 | "version": "v4.0.1", 939 | "source": { 940 | "type": "git", 941 | "url": "https://github.com/Spomky-Labs/aes-key-wrap.git", 942 | "reference": "6d302dc2d20cd61fc8bf0e253d628c70724d302a" 943 | }, 944 | "dist": { 945 | "type": "zip", 946 | "url": "https://api.github.com/repos/Spomky-Labs/aes-key-wrap/zipball/6d302dc2d20cd61fc8bf0e253d628c70724d302a", 947 | "reference": "6d302dc2d20cd61fc8bf0e253d628c70724d302a", 948 | "shasum": "" 949 | }, 950 | "require": { 951 | "ext-mbstring": "*", 952 | "lib-openssl": "*", 953 | "php": "^7.0" 954 | }, 955 | "require-dev": { 956 | "phpunit/phpunit": "^6.0", 957 | "satooshi/php-coveralls": "^1.0" 958 | }, 959 | "type": "library", 960 | "extra": { 961 | "branch-alias": { 962 | "dev-master": "4.0.x-dev" 963 | } 964 | }, 965 | "autoload": { 966 | "psr-4": { 967 | "AESKW\\": "src/" 968 | } 969 | }, 970 | "notification-url": "https://packagist.org/downloads/", 971 | "license": [ 972 | "MIT" 973 | ], 974 | "authors": [ 975 | { 976 | "name": "Florent Morselli", 977 | "homepage": "https://github.com/Spomky-Labs/aes-key-wrap/contributors" 978 | } 979 | ], 980 | "description": "AES Key Wrap for PHP.", 981 | "homepage": "https://github.com/Spomky-Labs/aes-key-wrap", 982 | "keywords": [ 983 | "A128KW", 984 | "A192KW", 985 | "A256KW", 986 | "RFC3394", 987 | "RFC5649", 988 | "aes", 989 | "key", 990 | "padding", 991 | "wrap" 992 | ], 993 | "time": "2017-10-28T16:15:26+00:00" 994 | }, 995 | { 996 | "name": "spomky-labs/base64url", 997 | "version": "v1.0.2", 998 | "source": { 999 | "type": "git", 1000 | "url": "https://github.com/Spomky-Labs/base64url.git", 1001 | "reference": "ef6d5fb93894063d9cee996022259fd08d6646ea" 1002 | }, 1003 | "dist": { 1004 | "type": "zip", 1005 | "url": "https://api.github.com/repos/Spomky-Labs/base64url/zipball/ef6d5fb93894063d9cee996022259fd08d6646ea", 1006 | "reference": "ef6d5fb93894063d9cee996022259fd08d6646ea", 1007 | "shasum": "" 1008 | }, 1009 | "require": { 1010 | "php": "^5.3|^7.0" 1011 | }, 1012 | "require-dev": { 1013 | "phpunit/phpunit": "^4.0|^5.0", 1014 | "satooshi/php-coveralls": "^1.0" 1015 | }, 1016 | "type": "library", 1017 | "extra": { 1018 | "branch-alias": { 1019 | "dev-master": "1.0.x-dev" 1020 | } 1021 | }, 1022 | "autoload": { 1023 | "psr-4": { 1024 | "Base64Url\\": "src/" 1025 | } 1026 | }, 1027 | "notification-url": "https://packagist.org/downloads/", 1028 | "license": [ 1029 | "MIT" 1030 | ], 1031 | "authors": [ 1032 | { 1033 | "name": "Florent Morselli", 1034 | "homepage": "https://github.com/Spomky-Labs/base64url/contributors" 1035 | } 1036 | ], 1037 | "description": "Base 64 URL Safe Encoding/decoding PHP Library", 1038 | "homepage": "https://github.com/Spomky-Labs/base64url", 1039 | "keywords": [ 1040 | "base64", 1041 | "rfc4648", 1042 | "safe", 1043 | "url" 1044 | ], 1045 | "time": "2016-01-21T19:50:30+00:00" 1046 | }, 1047 | { 1048 | "name": "spomky-labs/jose", 1049 | "version": "v7.1.0", 1050 | "source": { 1051 | "type": "git", 1052 | "url": "https://github.com/Spomky-Labs/jose.git", 1053 | "reference": "c7835297fa6a2c00dcdcbfadd67f7ea099b226a1" 1054 | }, 1055 | "dist": { 1056 | "type": "zip", 1057 | "url": "https://api.github.com/repos/Spomky-Labs/jose/zipball/c7835297fa6a2c00dcdcbfadd67f7ea099b226a1", 1058 | "reference": "c7835297fa6a2c00dcdcbfadd67f7ea099b226a1", 1059 | "shasum": "" 1060 | }, 1061 | "require": { 1062 | "beberlei/assert": "^2.4", 1063 | "fgrosse/phpasn1": "^2.0", 1064 | "lib-openssl": "*", 1065 | "mdanter/ecc": "0.5.*", 1066 | "php": "^7.0", 1067 | "psr/cache": "^1.0", 1068 | "spomky-labs/aes-key-wrap": "^3.0|^4.0", 1069 | "spomky-labs/base64url": "^1.0", 1070 | "spomky-labs/php-aes-gcm": "^1.2", 1071 | "symfony/polyfill-mbstring": "^1.1" 1072 | }, 1073 | "require-dev": { 1074 | "phpunit/phpunit": "^6.0", 1075 | "satooshi/php-coveralls": "^2.0", 1076 | "symfony/cache": "^2.0|^3.0|^4.0" 1077 | }, 1078 | "suggest": { 1079 | "ext-crypto": "Highly recommended when you use AES GCM based algorithms.", 1080 | "ext-curve25519": "For EdDSA with X25519 curves support.", 1081 | "ext-ed25519": "For EdDSA with Ed25519 curves support." 1082 | }, 1083 | "type": "library", 1084 | "extra": { 1085 | "branch-alias": { 1086 | "dev-master": "7.1.x-dev" 1087 | } 1088 | }, 1089 | "autoload": { 1090 | "psr-4": { 1091 | "Jose\\": "src/" 1092 | } 1093 | }, 1094 | "notification-url": "https://packagist.org/downloads/", 1095 | "license": [ 1096 | "MIT" 1097 | ], 1098 | "authors": [ 1099 | { 1100 | "name": "Florent Morselli", 1101 | "homepage": "https://github.com/Spomky" 1102 | }, 1103 | { 1104 | "name": "All contributors", 1105 | "homepage": "https://github.com/Spomky-Labs/jose/contributors" 1106 | } 1107 | ], 1108 | "description": "JSON Object Signing and Encryption library for PHP.", 1109 | "homepage": "https://github.com/Spomky-Labs/Jose", 1110 | "keywords": [ 1111 | "JOSE", 1112 | "JWE", 1113 | "JWK", 1114 | "JWKSet", 1115 | "JWS", 1116 | "Jot", 1117 | "RFC7515", 1118 | "RFC7516", 1119 | "RFC7517", 1120 | "RFC7518", 1121 | "RFC7519", 1122 | "RFC7520", 1123 | "jwa", 1124 | "jwt" 1125 | ], 1126 | "time": "2018-05-03T07:34:56+00:00" 1127 | }, 1128 | { 1129 | "name": "spomky-labs/php-aes-gcm", 1130 | "version": "v1.2.1", 1131 | "source": { 1132 | "type": "git", 1133 | "url": "https://github.com/Spomky-Labs/php-aes-gcm.git", 1134 | "reference": "e3900f2eb29a98476ae94c25c5c4aebb32ebf338" 1135 | }, 1136 | "dist": { 1137 | "type": "zip", 1138 | "url": "https://api.github.com/repos/Spomky-Labs/php-aes-gcm/zipball/e3900f2eb29a98476ae94c25c5c4aebb32ebf338", 1139 | "reference": "e3900f2eb29a98476ae94c25c5c4aebb32ebf338", 1140 | "shasum": "" 1141 | }, 1142 | "require": { 1143 | "beberlei/assert": "^2.4", 1144 | "lib-openssl": "*", 1145 | "php": ">=5.4", 1146 | "symfony/polyfill-mbstring": "^1.1" 1147 | }, 1148 | "require-dev": { 1149 | "phpunit/phpunit": "^4.5|^5.0", 1150 | "satooshi/php-coveralls": "^1.0" 1151 | }, 1152 | "suggest": { 1153 | "ext-crypto": "Highly recommended for better performance." 1154 | }, 1155 | "type": "library", 1156 | "extra": { 1157 | "branch-alias": { 1158 | "dev-master": "1.2.x-dev" 1159 | } 1160 | }, 1161 | "autoload": { 1162 | "psr-4": { 1163 | "AESGCM\\": "src/" 1164 | } 1165 | }, 1166 | "notification-url": "https://packagist.org/downloads/", 1167 | "license": [ 1168 | "MIT" 1169 | ], 1170 | "authors": [ 1171 | { 1172 | "name": "Florent Morselli", 1173 | "homepage": "https://github.com/Spomky" 1174 | }, 1175 | { 1176 | "name": "All contributors", 1177 | "homepage": "https://github.com/Spomky-Labs/php-aes-gcm/contributors" 1178 | } 1179 | ], 1180 | "description": "AES GCM (Galois Counter Mode) PHP implementation.", 1181 | "homepage": "https://github.com/Spomky-Labs/php-aes-gcm", 1182 | "keywords": [ 1183 | "AES-GCM", 1184 | "Galois Counter Mode", 1185 | "aes", 1186 | "gcm" 1187 | ], 1188 | "time": "2018-11-07T14:39:44+00:00" 1189 | }, 1190 | { 1191 | "name": "symfony/contracts", 1192 | "version": "v1.0.1", 1193 | "source": { 1194 | "type": "git", 1195 | "url": "https://github.com/symfony/contracts.git", 1196 | "reference": "3edf0ab943d1985a356721952cba36ff31bd6e5f" 1197 | }, 1198 | "dist": { 1199 | "type": "zip", 1200 | "url": "https://api.github.com/repos/symfony/contracts/zipball/3edf0ab943d1985a356721952cba36ff31bd6e5f", 1201 | "reference": "3edf0ab943d1985a356721952cba36ff31bd6e5f", 1202 | "shasum": "" 1203 | }, 1204 | "require": { 1205 | "php": "^7.1.3" 1206 | }, 1207 | "require-dev": { 1208 | "psr/cache": "^1.0", 1209 | "psr/container": "^1.0" 1210 | }, 1211 | "suggest": { 1212 | "psr/cache": "When using the Cache contracts", 1213 | "psr/container": "When using the Service contracts", 1214 | "symfony/cache-contracts-implementation": "", 1215 | "symfony/service-contracts-implementation": "", 1216 | "symfony/translation-contracts-implementation": "" 1217 | }, 1218 | "type": "library", 1219 | "extra": { 1220 | "branch-alias": { 1221 | "dev-master": "1.0-dev" 1222 | } 1223 | }, 1224 | "autoload": { 1225 | "psr-4": { 1226 | "Symfony\\Contracts\\": "" 1227 | }, 1228 | "exclude-from-classmap": [ 1229 | "**/Tests/" 1230 | ] 1231 | }, 1232 | "notification-url": "https://packagist.org/downloads/", 1233 | "license": [ 1234 | "MIT" 1235 | ], 1236 | "authors": [ 1237 | { 1238 | "name": "Nicolas Grekas", 1239 | "email": "p@tchwork.com" 1240 | }, 1241 | { 1242 | "name": "Symfony Community", 1243 | "homepage": "https://symfony.com/contributors" 1244 | } 1245 | ], 1246 | "description": "A set of abstractions extracted out of the Symfony components", 1247 | "homepage": "https://symfony.com", 1248 | "keywords": [ 1249 | "abstractions", 1250 | "contracts", 1251 | "decoupling", 1252 | "interfaces", 1253 | "interoperability", 1254 | "standards" 1255 | ], 1256 | "time": "2018-11-24T09:35:08+00:00" 1257 | }, 1258 | { 1259 | "name": "symfony/options-resolver", 1260 | "version": "v4.2.0", 1261 | "source": { 1262 | "type": "git", 1263 | "url": "https://github.com/symfony/options-resolver.git", 1264 | "reference": "a9c38e8a3da2c03b3e71fdffa6efb0bda51390ba" 1265 | }, 1266 | "dist": { 1267 | "type": "zip", 1268 | "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a9c38e8a3da2c03b3e71fdffa6efb0bda51390ba", 1269 | "reference": "a9c38e8a3da2c03b3e71fdffa6efb0bda51390ba", 1270 | "shasum": "" 1271 | }, 1272 | "require": { 1273 | "php": "^7.1.3" 1274 | }, 1275 | "type": "library", 1276 | "extra": { 1277 | "branch-alias": { 1278 | "dev-master": "4.2-dev" 1279 | } 1280 | }, 1281 | "autoload": { 1282 | "psr-4": { 1283 | "Symfony\\Component\\OptionsResolver\\": "" 1284 | }, 1285 | "exclude-from-classmap": [ 1286 | "/Tests/" 1287 | ] 1288 | }, 1289 | "notification-url": "https://packagist.org/downloads/", 1290 | "license": [ 1291 | "MIT" 1292 | ], 1293 | "authors": [ 1294 | { 1295 | "name": "Fabien Potencier", 1296 | "email": "fabien@symfony.com" 1297 | }, 1298 | { 1299 | "name": "Symfony Community", 1300 | "homepage": "https://symfony.com/contributors" 1301 | } 1302 | ], 1303 | "description": "Symfony OptionsResolver Component", 1304 | "homepage": "https://symfony.com", 1305 | "keywords": [ 1306 | "config", 1307 | "configuration", 1308 | "options" 1309 | ], 1310 | "time": "2018-11-11T19:52:12+00:00" 1311 | }, 1312 | { 1313 | "name": "symfony/polyfill-ctype", 1314 | "version": "v1.10.0", 1315 | "source": { 1316 | "type": "git", 1317 | "url": "https://github.com/symfony/polyfill-ctype.git", 1318 | "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" 1319 | }, 1320 | "dist": { 1321 | "type": "zip", 1322 | "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", 1323 | "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", 1324 | "shasum": "" 1325 | }, 1326 | "require": { 1327 | "php": ">=5.3.3" 1328 | }, 1329 | "suggest": { 1330 | "ext-ctype": "For best performance" 1331 | }, 1332 | "type": "library", 1333 | "extra": { 1334 | "branch-alias": { 1335 | "dev-master": "1.9-dev" 1336 | } 1337 | }, 1338 | "autoload": { 1339 | "psr-4": { 1340 | "Symfony\\Polyfill\\Ctype\\": "" 1341 | }, 1342 | "files": [ 1343 | "bootstrap.php" 1344 | ] 1345 | }, 1346 | "notification-url": "https://packagist.org/downloads/", 1347 | "license": [ 1348 | "MIT" 1349 | ], 1350 | "authors": [ 1351 | { 1352 | "name": "Symfony Community", 1353 | "homepage": "https://symfony.com/contributors" 1354 | }, 1355 | { 1356 | "name": "Gert de Pagter", 1357 | "email": "BackEndTea@gmail.com" 1358 | } 1359 | ], 1360 | "description": "Symfony polyfill for ctype functions", 1361 | "homepage": "https://symfony.com", 1362 | "keywords": [ 1363 | "compatibility", 1364 | "ctype", 1365 | "polyfill", 1366 | "portable" 1367 | ], 1368 | "time": "2018-08-06T14:22:27+00:00" 1369 | }, 1370 | { 1371 | "name": "symfony/polyfill-mbstring", 1372 | "version": "v1.10.0", 1373 | "source": { 1374 | "type": "git", 1375 | "url": "https://github.com/symfony/polyfill-mbstring.git", 1376 | "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" 1377 | }, 1378 | "dist": { 1379 | "type": "zip", 1380 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", 1381 | "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", 1382 | "shasum": "" 1383 | }, 1384 | "require": { 1385 | "php": ">=5.3.3" 1386 | }, 1387 | "suggest": { 1388 | "ext-mbstring": "For best performance" 1389 | }, 1390 | "type": "library", 1391 | "extra": { 1392 | "branch-alias": { 1393 | "dev-master": "1.9-dev" 1394 | } 1395 | }, 1396 | "autoload": { 1397 | "psr-4": { 1398 | "Symfony\\Polyfill\\Mbstring\\": "" 1399 | }, 1400 | "files": [ 1401 | "bootstrap.php" 1402 | ] 1403 | }, 1404 | "notification-url": "https://packagist.org/downloads/", 1405 | "license": [ 1406 | "MIT" 1407 | ], 1408 | "authors": [ 1409 | { 1410 | "name": "Nicolas Grekas", 1411 | "email": "p@tchwork.com" 1412 | }, 1413 | { 1414 | "name": "Symfony Community", 1415 | "homepage": "https://symfony.com/contributors" 1416 | } 1417 | ], 1418 | "description": "Symfony polyfill for the Mbstring extension", 1419 | "homepage": "https://symfony.com", 1420 | "keywords": [ 1421 | "compatibility", 1422 | "mbstring", 1423 | "polyfill", 1424 | "portable", 1425 | "shim" 1426 | ], 1427 | "time": "2018-09-21T13:07:52+00:00" 1428 | }, 1429 | { 1430 | "name": "symfony/translation", 1431 | "version": "v4.2.0", 1432 | "source": { 1433 | "type": "git", 1434 | "url": "https://github.com/symfony/translation.git", 1435 | "reference": "ff9a878c9b8f8bcd4d9138e2d32f508c942773d9" 1436 | }, 1437 | "dist": { 1438 | "type": "zip", 1439 | "url": "https://api.github.com/repos/symfony/translation/zipball/ff9a878c9b8f8bcd4d9138e2d32f508c942773d9", 1440 | "reference": "ff9a878c9b8f8bcd4d9138e2d32f508c942773d9", 1441 | "shasum": "" 1442 | }, 1443 | "require": { 1444 | "php": "^7.1.3", 1445 | "symfony/contracts": "^1.0", 1446 | "symfony/polyfill-mbstring": "~1.0" 1447 | }, 1448 | "conflict": { 1449 | "symfony/config": "<3.4", 1450 | "symfony/dependency-injection": "<3.4", 1451 | "symfony/yaml": "<3.4" 1452 | }, 1453 | "provide": { 1454 | "symfony/translation-contracts-implementation": "1.0" 1455 | }, 1456 | "require-dev": { 1457 | "psr/log": "~1.0", 1458 | "symfony/config": "~3.4|~4.0", 1459 | "symfony/console": "~3.4|~4.0", 1460 | "symfony/dependency-injection": "~3.4|~4.0", 1461 | "symfony/finder": "~2.8|~3.0|~4.0", 1462 | "symfony/intl": "~3.4|~4.0", 1463 | "symfony/yaml": "~3.4|~4.0" 1464 | }, 1465 | "suggest": { 1466 | "psr/log-implementation": "To use logging capability in translator", 1467 | "symfony/config": "", 1468 | "symfony/yaml": "" 1469 | }, 1470 | "type": "library", 1471 | "extra": { 1472 | "branch-alias": { 1473 | "dev-master": "4.2-dev" 1474 | } 1475 | }, 1476 | "autoload": { 1477 | "psr-4": { 1478 | "Symfony\\Component\\Translation\\": "" 1479 | }, 1480 | "exclude-from-classmap": [ 1481 | "/Tests/" 1482 | ] 1483 | }, 1484 | "notification-url": "https://packagist.org/downloads/", 1485 | "license": [ 1486 | "MIT" 1487 | ], 1488 | "authors": [ 1489 | { 1490 | "name": "Fabien Potencier", 1491 | "email": "fabien@symfony.com" 1492 | }, 1493 | { 1494 | "name": "Symfony Community", 1495 | "homepage": "https://symfony.com/contributors" 1496 | } 1497 | ], 1498 | "description": "Symfony Translation Component", 1499 | "homepage": "https://symfony.com", 1500 | "time": "2018-11-27T07:20:32+00:00" 1501 | }, 1502 | { 1503 | "name": "symfony/yaml", 1504 | "version": "v4.2.0", 1505 | "source": { 1506 | "type": "git", 1507 | "url": "https://github.com/symfony/yaml.git", 1508 | "reference": "c41175c801e3edfda90f32e292619d10c27103d7" 1509 | }, 1510 | "dist": { 1511 | "type": "zip", 1512 | "url": "https://api.github.com/repos/symfony/yaml/zipball/c41175c801e3edfda90f32e292619d10c27103d7", 1513 | "reference": "c41175c801e3edfda90f32e292619d10c27103d7", 1514 | "shasum": "" 1515 | }, 1516 | "require": { 1517 | "php": "^7.1.3", 1518 | "symfony/polyfill-ctype": "~1.8" 1519 | }, 1520 | "conflict": { 1521 | "symfony/console": "<3.4" 1522 | }, 1523 | "require-dev": { 1524 | "symfony/console": "~3.4|~4.0" 1525 | }, 1526 | "suggest": { 1527 | "symfony/console": "For validating YAML files using the lint command" 1528 | }, 1529 | "type": "library", 1530 | "extra": { 1531 | "branch-alias": { 1532 | "dev-master": "4.2-dev" 1533 | } 1534 | }, 1535 | "autoload": { 1536 | "psr-4": { 1537 | "Symfony\\Component\\Yaml\\": "" 1538 | }, 1539 | "exclude-from-classmap": [ 1540 | "/Tests/" 1541 | ] 1542 | }, 1543 | "notification-url": "https://packagist.org/downloads/", 1544 | "license": [ 1545 | "MIT" 1546 | ], 1547 | "authors": [ 1548 | { 1549 | "name": "Fabien Potencier", 1550 | "email": "fabien@symfony.com" 1551 | }, 1552 | { 1553 | "name": "Symfony Community", 1554 | "homepage": "https://symfony.com/contributors" 1555 | } 1556 | ], 1557 | "description": "Symfony Yaml Component", 1558 | "homepage": "https://symfony.com", 1559 | "time": "2018-11-11T19:52:12+00:00" 1560 | }, 1561 | { 1562 | "name": "vlucas/phpdotenv", 1563 | "version": "v2.5.1", 1564 | "source": { 1565 | "type": "git", 1566 | "url": "https://github.com/vlucas/phpdotenv.git", 1567 | "reference": "8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e" 1568 | }, 1569 | "dist": { 1570 | "type": "zip", 1571 | "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e", 1572 | "reference": "8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e", 1573 | "shasum": "" 1574 | }, 1575 | "require": { 1576 | "php": ">=5.3.9" 1577 | }, 1578 | "require-dev": { 1579 | "phpunit/phpunit": "^4.8.35 || ^5.0" 1580 | }, 1581 | "type": "library", 1582 | "extra": { 1583 | "branch-alias": { 1584 | "dev-master": "2.5-dev" 1585 | } 1586 | }, 1587 | "autoload": { 1588 | "psr-4": { 1589 | "Dotenv\\": "src/" 1590 | } 1591 | }, 1592 | "notification-url": "https://packagist.org/downloads/", 1593 | "license": [ 1594 | "BSD-3-Clause" 1595 | ], 1596 | "authors": [ 1597 | { 1598 | "name": "Vance Lucas", 1599 | "email": "vance@vancelucas.com", 1600 | "homepage": "http://www.vancelucas.com" 1601 | } 1602 | ], 1603 | "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", 1604 | "keywords": [ 1605 | "dotenv", 1606 | "env", 1607 | "environment" 1608 | ], 1609 | "time": "2018-07-29T20:33:41+00:00" 1610 | } 1611 | ], 1612 | "packages-dev": [], 1613 | "aliases": [], 1614 | "minimum-stability": "stable", 1615 | "stability-flags": [], 1616 | "prefer-stable": false, 1617 | "prefer-lowest": false, 1618 | "platform": [], 1619 | "platform-dev": [] 1620 | } 1621 | -------------------------------------------------------------------------------- /dbseed.php: -------------------------------------------------------------------------------- 1 | exec($statement); 36 | echo "Success!\n"; 37 | } catch (\PDOException $e) { 38 | exit($e->getMessage()); 39 | } 40 | ?> -------------------------------------------------------------------------------- /public/client.php: -------------------------------------------------------------------------------- 1 | 'client_credentials', 26 | 'scope' => $scope 27 | ]); 28 | 29 | // build the curl request 30 | $ch = curl_init(); 31 | curl_setopt($ch, CURLOPT_URL, $uri); 32 | curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 33 | 'Content-Type: application/x-www-form-urlencoded', 34 | "Authorization: Basic $token" 35 | ]); 36 | curl_setopt($ch, CURLOPT_POST, 1); 37 | curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); 38 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 39 | 40 | // process and return the response 41 | $response = curl_exec($ch); 42 | $response = json_decode($response, true); 43 | if (! isset($response['access_token']) 44 | || ! isset($response['token_type'])) { 45 | exit('failed, exiting.'); 46 | } 47 | 48 | echo "success!\n"; 49 | // here's your token to use in API requests 50 | return $response['token_type'] . " " . $response['access_token']; 51 | } 52 | 53 | function getAllUsers($token) { 54 | echo "Getting all users..."; 55 | $ch = curl_init(); 56 | curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:8000/person"); 57 | curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 58 | 'Content-Type: application/json', 59 | "Authorization: $token" 60 | ]); 61 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 62 | $response = curl_exec($ch); 63 | 64 | var_dump($response); 65 | } 66 | 67 | function getUser($token, $id) { 68 | echo "Getting user with id#$id..."; 69 | $ch = curl_init(); 70 | curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:8000/person/" . $id); 71 | curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 72 | 'Content-Type: application/json', 73 | "Authorization: $token" 74 | ]); 75 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 76 | $response = curl_exec($ch); 77 | 78 | var_dump($response); 79 | } 80 | 81 | ?> -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | processRequest(); 38 | 39 | function authenticate() { 40 | try { 41 | switch(true) { 42 | case array_key_exists('HTTP_AUTHORIZATION', $_SERVER) : 43 | $authHeader = $_SERVER['HTTP_AUTHORIZATION']; 44 | break; 45 | case array_key_exists('Authorization', $_SERVER) : 46 | $authHeader = $_SERVER['Authorization']; 47 | break; 48 | default : 49 | $authHeader = null; 50 | break; 51 | } 52 | preg_match('/Bearer\s(\S+)/', $authHeader, $matches); 53 | if(!isset($matches[1])) { 54 | throw new \Exception('No Bearer Token'); 55 | } 56 | $jwtVerifier = (new \Okta\JwtVerifier\JwtVerifierBuilder()) 57 | ->setIssuer(getenv('OKTAISSUER')) 58 | ->setAudience('api://default') 59 | ->setClientId(getenv('OKTACLIENTID')) 60 | ->build(); 61 | return $jwtVerifier->verify($matches[1]); 62 | } catch (\Exception $e) { 63 | return false; 64 | } 65 | } 66 | 67 | ?> 68 | -------------------------------------------------------------------------------- /src/Controller/PersonController.php: -------------------------------------------------------------------------------- 1 | db = $db; 17 | $this->requestMethod = $requestMethod; 18 | $this->userId = $userId; 19 | 20 | $this->personGateway = new PersonGateway($db); 21 | } 22 | 23 | public function processRequest() 24 | { 25 | switch ($this->requestMethod) { 26 | case 'GET': 27 | if ($this->userId) { 28 | $response = $this->getUser($this->userId); 29 | } else { 30 | $response = $this->getAllUsers(); 31 | }; 32 | break; 33 | case 'POST': 34 | $response = $this->createUserFromRequest(); 35 | break; 36 | case 'PUT': 37 | $response = $this->updateUserFromRequest($this->userId); 38 | break; 39 | case 'DELETE': 40 | $response = $this->deleteUser($this->userId); 41 | break; 42 | default: 43 | $response = $this->notFoundResponse(); 44 | break; 45 | } 46 | header($response['status_code_header']); 47 | if ($response['body']) { 48 | echo $response['body']; 49 | } 50 | } 51 | 52 | private function getAllUsers() 53 | { 54 | $result = $this->personGateway->findAll(); 55 | $response['status_code_header'] = 'HTTP/1.1 200 OK'; 56 | $response['body'] = json_encode($result); 57 | return $response; 58 | } 59 | 60 | private function getUser($id) 61 | { 62 | $result = $this->personGateway->find($id); 63 | if (! $result) { 64 | return $this->notFoundResponse(); 65 | } 66 | $response['status_code_header'] = 'HTTP/1.1 200 OK'; 67 | $response['body'] = json_encode($result); 68 | return $response; 69 | } 70 | 71 | private function createUserFromRequest() 72 | { 73 | $input = (array) json_decode(file_get_contents('php://input'), TRUE); 74 | if (! $this->validatePerson($input)) { 75 | return $this->unprocessableEntityResponse(); 76 | } 77 | $this->personGateway->insert($input); 78 | $response['status_code_header'] = 'HTTP/1.1 201 Created'; 79 | $response['body'] = null; 80 | return $response; 81 | } 82 | 83 | private function updateUserFromRequest($id) 84 | { 85 | $result = $this->personGateway->find($id); 86 | if (! $result) { 87 | return $this->notFoundResponse(); 88 | } 89 | $input = (array) json_decode(file_get_contents('php://input'), TRUE); 90 | if (! $this->validatePerson($input)) { 91 | return $this->unprocessableEntityResponse(); 92 | } 93 | $this->personGateway->update($id, $input); 94 | $response['status_code_header'] = 'HTTP/1.1 200 OK'; 95 | $response['body'] = null; 96 | return $response; 97 | } 98 | 99 | private function deleteUser($id) 100 | { 101 | $result = $this->personGateway->find($id); 102 | if (! $result) { 103 | return $this->notFoundResponse(); 104 | } 105 | $this->personGateway->delete($id); 106 | $response['status_code_header'] = 'HTTP/1.1 200 OK'; 107 | $response['body'] = null; 108 | return $response; 109 | } 110 | 111 | private function validatePerson($input) 112 | { 113 | if (! isset($input['firstname'])) { 114 | return false; 115 | } 116 | if (! isset($input['lastname'])) { 117 | return false; 118 | } 119 | return true; 120 | } 121 | 122 | private function unprocessableEntityResponse() 123 | { 124 | $response['status_code_header'] = 'HTTP/1.1 422 Unprocessable Entity'; 125 | $response['body'] = json_encode([ 126 | 'error' => 'Invalid input' 127 | ]); 128 | return $response; 129 | } 130 | 131 | private function notFoundResponse() 132 | { 133 | $response['status_code_header'] = 'HTTP/1.1 404 Not Found'; 134 | $response['body'] = null; 135 | return $response; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/System/DatabaseConnector.php: -------------------------------------------------------------------------------- 1 | dbConnection = new \PDO( 18 | "mysql:host=$host;port=$port;charset=utf8mb4;dbname=$db", 19 | $user, 20 | $pass 21 | ); 22 | } catch (\PDOException $e) { 23 | exit($e->getMessage()); 24 | } 25 | } 26 | 27 | public function getConnection() 28 | { 29 | return $this->dbConnection; 30 | } 31 | } -------------------------------------------------------------------------------- /src/TableGateways/PersonGateway.php: -------------------------------------------------------------------------------- 1 | db = $db; 11 | } 12 | 13 | public function findAll() 14 | { 15 | $statement = " 16 | SELECT 17 | id, firstname, lastname, firstparent_id, secondparent_id 18 | FROM 19 | person; 20 | "; 21 | 22 | try { 23 | $statement = $this->db->query($statement); 24 | $result = $statement->fetchAll(\PDO::FETCH_ASSOC); 25 | return $result; 26 | } catch (\PDOException $e) { 27 | exit($e->getMessage()); 28 | } 29 | } 30 | 31 | public function find($id) 32 | { 33 | $statement = " 34 | SELECT 35 | id, firstname, lastname, firstparent_id, secondparent_id 36 | FROM 37 | person 38 | WHERE id = ?; 39 | "; 40 | 41 | try { 42 | $statement = $this->db->prepare($statement); 43 | $statement->execute(array($id)); 44 | $result = $statement->fetchAll(\PDO::FETCH_ASSOC); 45 | return $result; 46 | } catch (\PDOException $e) { 47 | exit($e->getMessage()); 48 | } 49 | } 50 | 51 | public function insert(Array $input) 52 | { 53 | $statement = " 54 | INSERT INTO person 55 | (firstname, lastname, firstparent_id, secondparent_id) 56 | VALUES 57 | (:firstname, :lastname, :firstparent_id, :secondparent_id); 58 | "; 59 | 60 | try { 61 | $statement = $this->db->prepare($statement); 62 | $statement->execute(array( 63 | 'firstname' => $input['firstname'], 64 | 'lastname' => $input['lastname'], 65 | 'firstparent_id' => $input['firstparent_id'] ?? null, 66 | 'secondparent_id' => $input['secondparent_id'] ?? null, 67 | )); 68 | return $statement->rowCount(); 69 | } catch (\PDOException $e) { 70 | exit($e->getMessage()); 71 | } 72 | } 73 | 74 | public function update($id, Array $input) 75 | { 76 | $statement = " 77 | UPDATE person 78 | SET 79 | firstname = :firstname, 80 | lastname = :lastname, 81 | firstparent_id = :firstparent_id, 82 | secondparent_id = :secondparent_id 83 | WHERE id = :id; 84 | "; 85 | 86 | try { 87 | $statement = $this->db->prepare($statement); 88 | $statement->execute(array( 89 | 'id' => (int) $id, 90 | 'firstname' => $input['firstname'], 91 | 'lastname' => $input['lastname'], 92 | 'firstparent_id' => $input['firstparent_id'] ?? null, 93 | 'secondparent_id' => $input['secondparent_id'] ?? null, 94 | )); 95 | return $statement->rowCount(); 96 | } catch (\PDOException $e) { 97 | exit($e->getMessage()); 98 | } 99 | } 100 | 101 | public function delete($id) 102 | { 103 | $statement = " 104 | DELETE FROM person 105 | WHERE id = :id; 106 | "; 107 | 108 | try { 109 | $statement = $this->db->prepare($statement); 110 | $statement->execute(array('id' => $id)); 111 | return $statement->rowCount(); 112 | } catch (\PDOException $e) { 113 | exit($e->getMessage()); 114 | } 115 | } 116 | } --------------------------------------------------------------------------------