diff --git a/examples/composer.lock b/examples/composer.lock index 8bc48e8e..8f5782c0 100644 --- a/examples/composer.lock +++ b/examples/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8d3e15426ebda5d273b960d5c9f373b5", + "hash": "9ae3d11ba275cce8764cfa3002ec7c93", "packages": [ { "name": "alexbilbie/proton", @@ -187,6 +187,51 @@ ], "time": "2014-12-20 21:24:13" }, + { + "name": "firebase/php-jwt", + "version": "2.0.0", + "target-dir": "Firebase/PHP-JWT", + "source": { + "type": "git", + "url": "https://github.com/firebase/php-jwt.git", + "reference": "ffcfd888ce1e4f2d70cac2dc9b7301038332fe57" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/ffcfd888ce1e4f2d70cac2dc9b7301038332fe57", + "reference": "ffcfd888ce1e4f2d70cac2dc9b7301038332fe57", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "Authentication/", + "Exceptions/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "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", + "time": "2015-04-01 18:46:38" + }, { "name": "illuminate/container", "version": "v5.0.26", diff --git a/examples/public/jwt.php b/examples/public/jwt.php new file mode 100644 index 00000000..7dca6764 --- /dev/null +++ b/examples/public/jwt.php @@ -0,0 +1,40 @@ +addRepository(new ClientRepository()); +$server->addRepository(new ScopeRepository()); +$server->addRepository(new AccessTokenRepository()); +$server->addRepository(new UserRepository()); + +// Enable the password grant, respond with JWTs +$server->enableGrantType('PasswordGrant', new JsonWebTokenType()); + +// Setup JWT params +JsonWebTokenType::setIssuer('http://example.com/'); +JsonWebTokenType::setAudience('http://myawesomeapp.com/'); +JsonWebTokenType::setEncryptionKey('foobar123'); + +// Setup app + routing +$application = new \Proton\Application(); +$application->post('/access_token', function (Request $request) use ($server) { + try { + return $server->getAccessTokenResponse($request); + } catch (OAuthException $e) { + return $e->generateHttpResponse(); + } +}); + +// Run the app +$application->run(); diff --git a/examples/public/password.php b/examples/public/password.php new file mode 100644 index 00000000..fff4717b --- /dev/null +++ b/examples/public/password.php @@ -0,0 +1,34 @@ +addRepository(new ClientRepository()); +$server->addRepository(new ScopeRepository()); +$server->addRepository(new AccessTokenRepository()); +$server->addRepository(new UserRepository()); + +// Enable the password grant +$server->enableGrantType('PasswordGrant'); + +// Setup app + routing +$application = new \Proton\Application(); +$application->post('/access_token', function (Request $request) use ($server) { + try { + return $server->getAccessTokenResponse($request); + } catch (OAuthException $e) { + return $e->generateHttpResponse(); + } +}); + +// Run the app +$application->run(); diff --git a/examples/src/Entities/UserEntity.php b/examples/src/Entities/UserEntity.php new file mode 100644 index 00000000..8feb8c73 --- /dev/null +++ b/examples/src/Entities/UserEntity.php @@ -0,0 +1,17 @@ +