mirror of
				https://github.com/elyby/oauth2-server.git
				synced 2025-05-31 14:12:07 +05:30 
			
		
		
		
	Updated examples
This commit is contained in:
		@@ -5,8 +5,9 @@
 | 
			
		||||
    "require-dev": {
 | 
			
		||||
        "league/event": "^2.1",
 | 
			
		||||
        "lcobucci/jwt": "^3.1",
 | 
			
		||||
        "paragonie/random_compat": "^1.1",
 | 
			
		||||
        "psr/http-message": "^1.0"
 | 
			
		||||
        "paragonie/random_compat": "^2.0",
 | 
			
		||||
        "psr/http-message": "^1.0",
 | 
			
		||||
        "defuse/php-encryption": "^2.1"
 | 
			
		||||
    },
 | 
			
		||||
    "autoload": {
 | 
			
		||||
        "psr-4": {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										178
									
								
								examples/composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										178
									
								
								examples/composer.lock
									
									
									
										generated
									
									
									
								
							@@ -4,23 +4,25 @@
 | 
			
		||||
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
 | 
			
		||||
        "This file is @generated automatically"
 | 
			
		||||
    ],
 | 
			
		||||
    "hash": "48bcb7a3514d7c7f271c554ba1440124",
 | 
			
		||||
    "content-hash": "e41be75973527cb9d63f27ad14ac8624",
 | 
			
		||||
    "content-hash": "9813ed7c3b6dcf107f44df9392935b8f",
 | 
			
		||||
    "packages": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "container-interop/container-interop",
 | 
			
		||||
            "version": "1.1.0",
 | 
			
		||||
            "version": "1.2.0",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/container-interop/container-interop.git",
 | 
			
		||||
                "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e"
 | 
			
		||||
                "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e",
 | 
			
		||||
                "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e",
 | 
			
		||||
                "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8",
 | 
			
		||||
                "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
                "psr/container": "^1.0"
 | 
			
		||||
            },
 | 
			
		||||
            "type": "library",
 | 
			
		||||
            "autoload": {
 | 
			
		||||
                "psr-4": {
 | 
			
		||||
@@ -32,7 +34,8 @@
 | 
			
		||||
                "MIT"
 | 
			
		||||
            ],
 | 
			
		||||
            "description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
 | 
			
		||||
            "time": "2014-12-30 15:22:37"
 | 
			
		||||
            "homepage": "https://github.com/container-interop/container-interop",
 | 
			
		||||
            "time": "2017-02-14T19:40:03+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "nikic/fast-route",
 | 
			
		||||
@@ -75,7 +78,7 @@
 | 
			
		||||
                "router",
 | 
			
		||||
                "routing"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2015-06-18 19:15:47"
 | 
			
		||||
            "time": "2015-06-18T19:15:47+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "pimple/pimple",
 | 
			
		||||
@@ -121,20 +124,69 @@
 | 
			
		||||
                "container",
 | 
			
		||||
                "dependency injection"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2015-09-11 15:10:35"
 | 
			
		||||
            "time": "2015-09-11T15:10:35+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "psr/http-message",
 | 
			
		||||
            "version": "1.0",
 | 
			
		||||
            "name": "psr/container",
 | 
			
		||||
            "version": "1.0.0",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/php-fig/http-message.git",
 | 
			
		||||
                "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
 | 
			
		||||
                "url": "https://github.com/php-fig/container.git",
 | 
			
		||||
                "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
 | 
			
		||||
                "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
 | 
			
		||||
                "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
 | 
			
		||||
                "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
                "php": ">=5.3.0"
 | 
			
		||||
            },
 | 
			
		||||
            "type": "library",
 | 
			
		||||
            "extra": {
 | 
			
		||||
                "branch-alias": {
 | 
			
		||||
                    "dev-master": "1.0.x-dev"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            "autoload": {
 | 
			
		||||
                "psr-4": {
 | 
			
		||||
                    "Psr\\Container\\": "src/"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            "notification-url": "https://packagist.org/downloads/",
 | 
			
		||||
            "license": [
 | 
			
		||||
                "MIT"
 | 
			
		||||
            ],
 | 
			
		||||
            "authors": [
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "PHP-FIG",
 | 
			
		||||
                    "homepage": "http://www.php-fig.org/"
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "description": "Common Container Interface (PHP FIG PSR-11)",
 | 
			
		||||
            "homepage": "https://github.com/php-fig/container",
 | 
			
		||||
            "keywords": [
 | 
			
		||||
                "PSR-11",
 | 
			
		||||
                "container",
 | 
			
		||||
                "container-interface",
 | 
			
		||||
                "container-interop",
 | 
			
		||||
                "psr"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2017-02-14T16:28:37+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "psr/http-message",
 | 
			
		||||
            "version": "1.0.1",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/php-fig/http-message.git",
 | 
			
		||||
                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
 | 
			
		||||
                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
@@ -162,6 +214,7 @@
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "description": "Common interface for HTTP messages",
 | 
			
		||||
            "homepage": "https://github.com/php-fig/http-message",
 | 
			
		||||
            "keywords": [
 | 
			
		||||
                "http",
 | 
			
		||||
                "http-message",
 | 
			
		||||
@@ -170,7 +223,7 @@
 | 
			
		||||
                "request",
 | 
			
		||||
                "response"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2015-05-04 20:22:00"
 | 
			
		||||
            "time": "2016-08-06T14:39:51+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "slim/slim",
 | 
			
		||||
@@ -236,22 +289,85 @@
 | 
			
		||||
                "micro",
 | 
			
		||||
                "router"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2015-12-07 14:11:09"
 | 
			
		||||
            "time": "2015-12-07T14:11:09+00:00"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "packages-dev": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "lcobucci/jwt",
 | 
			
		||||
            "version": "3.1.1",
 | 
			
		||||
            "name": "defuse/php-encryption",
 | 
			
		||||
            "version": "v2.1.0",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/lcobucci/jwt.git",
 | 
			
		||||
                "reference": "afea8e682e911a21574fd8519321b32522fa25b5"
 | 
			
		||||
                "url": "https://github.com/defuse/php-encryption.git",
 | 
			
		||||
                "reference": "5176f5abb38d3ea8a6e3ac6cd3bbb54d8185a689"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/lcobucci/jwt/zipball/afea8e682e911a21574fd8519321b32522fa25b5",
 | 
			
		||||
                "reference": "afea8e682e911a21574fd8519321b32522fa25b5",
 | 
			
		||||
                "url": "https://api.github.com/repos/defuse/php-encryption/zipball/5176f5abb38d3ea8a6e3ac6cd3bbb54d8185a689",
 | 
			
		||||
                "reference": "5176f5abb38d3ea8a6e3ac6cd3bbb54d8185a689",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
                "ext-openssl": "*",
 | 
			
		||||
                "paragonie/random_compat": "~2.0",
 | 
			
		||||
                "php": ">=5.4.0"
 | 
			
		||||
            },
 | 
			
		||||
            "require-dev": {
 | 
			
		||||
                "nikic/php-parser": "^2.0|^3.0",
 | 
			
		||||
                "phpunit/phpunit": "^4|^5"
 | 
			
		||||
            },
 | 
			
		||||
            "bin": [
 | 
			
		||||
                "bin/generate-defuse-key"
 | 
			
		||||
            ],
 | 
			
		||||
            "type": "library",
 | 
			
		||||
            "autoload": {
 | 
			
		||||
                "psr-4": {
 | 
			
		||||
                    "Defuse\\Crypto\\": "src"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            "notification-url": "https://packagist.org/downloads/",
 | 
			
		||||
            "license": [
 | 
			
		||||
                "MIT"
 | 
			
		||||
            ],
 | 
			
		||||
            "authors": [
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "Taylor Hornby",
 | 
			
		||||
                    "email": "taylor@defuse.ca",
 | 
			
		||||
                    "homepage": "https://defuse.ca/"
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "Scott Arciszewski",
 | 
			
		||||
                    "email": "info@paragonie.com",
 | 
			
		||||
                    "homepage": "https://paragonie.com"
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "description": "Secure PHP Encryption Library",
 | 
			
		||||
            "keywords": [
 | 
			
		||||
                "aes",
 | 
			
		||||
                "authenticated encryption",
 | 
			
		||||
                "cipher",
 | 
			
		||||
                "crypto",
 | 
			
		||||
                "cryptography",
 | 
			
		||||
                "encrypt",
 | 
			
		||||
                "encryption",
 | 
			
		||||
                "openssl",
 | 
			
		||||
                "security",
 | 
			
		||||
                "symmetric key cryptography"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2017-05-18T21:28:48+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "lcobucci/jwt",
 | 
			
		||||
            "version": "3.2.1",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/lcobucci/jwt.git",
 | 
			
		||||
                "reference": "ddce703826f9c5229781933b1a39069e38e6a0f3"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/lcobucci/jwt/zipball/ddce703826f9c5229781933b1a39069e38e6a0f3",
 | 
			
		||||
                "reference": "ddce703826f9c5229781933b1a39069e38e6a0f3",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
@@ -259,7 +375,7 @@
 | 
			
		||||
                "php": ">=5.5"
 | 
			
		||||
            },
 | 
			
		||||
            "require-dev": {
 | 
			
		||||
                "mdanter/ecc": "~0.3",
 | 
			
		||||
                "mdanter/ecc": "~0.3.1",
 | 
			
		||||
                "mikey179/vfsstream": "~1.5",
 | 
			
		||||
                "phpmd/phpmd": "~2.2",
 | 
			
		||||
                "phpunit/php-invoker": "~1.1",
 | 
			
		||||
@@ -296,7 +412,7 @@
 | 
			
		||||
                "JWS",
 | 
			
		||||
                "jwt"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2016-03-24 22:46:13"
 | 
			
		||||
            "time": "2016-10-31T20:09:32+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "league/event",
 | 
			
		||||
@@ -346,20 +462,20 @@
 | 
			
		||||
                "event",
 | 
			
		||||
                "listener"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2015-05-21 12:24:47"
 | 
			
		||||
            "time": "2015-05-21T12:24:47+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "paragonie/random_compat",
 | 
			
		||||
            "version": "v1.4.1",
 | 
			
		||||
            "version": "v2.0.10",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/paragonie/random_compat.git",
 | 
			
		||||
                "reference": "c7e26a21ba357863de030f0b9e701c7d04593774"
 | 
			
		||||
                "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/paragonie/random_compat/zipball/c7e26a21ba357863de030f0b9e701c7d04593774",
 | 
			
		||||
                "reference": "c7e26a21ba357863de030f0b9e701c7d04593774",
 | 
			
		||||
                "url": "https://api.github.com/repos/paragonie/random_compat/zipball/634bae8e911eefa89c1abfbf1b66da679ac8f54d",
 | 
			
		||||
                "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
@@ -394,7 +510,7 @@
 | 
			
		||||
                "pseudorandom",
 | 
			
		||||
                "random"
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2016-03-18 20:34:03"
 | 
			
		||||
            "time": "2017-03-13T16:27:32+00:00"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "aliases": [],
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,7 @@ $app = new App([
 | 
			
		||||
            $privateKeyPath,
 | 
			
		||||
            $publicKeyPath
 | 
			
		||||
        );
 | 
			
		||||
        $server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
 | 
			
		||||
 | 
			
		||||
        // Enable the authentication code grant on the server with a token TTL of 1 hour
 | 
			
		||||
        $server->enableGrantType(
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ $app = new App([
 | 
			
		||||
            $privateKey,
 | 
			
		||||
            $publicKey
 | 
			
		||||
        );
 | 
			
		||||
        $server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
 | 
			
		||||
 | 
			
		||||
        // Enable the client credentials grant on the server
 | 
			
		||||
        $server->enableGrantType(
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ $app = new App([
 | 
			
		||||
            $privateKeyPath,
 | 
			
		||||
            $publicKeyPath
 | 
			
		||||
        );
 | 
			
		||||
        $server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
 | 
			
		||||
 | 
			
		||||
        // Enable the implicit grant on the server with a token TTL of 1 hour
 | 
			
		||||
        $server->enableGrantType(new ImplicitGrant(new \DateInterval('PT1H')));
 | 
			
		||||
 
 | 
			
		||||
@@ -48,6 +48,7 @@ $app = new App([
 | 
			
		||||
            $privateKeyPath,
 | 
			
		||||
            $publicKeyPath
 | 
			
		||||
        );
 | 
			
		||||
        $server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
 | 
			
		||||
 | 
			
		||||
        // Enable the authentication code grant on the server with a token TTL of 1 hour
 | 
			
		||||
        $server->enableGrantType(
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ $app = new App([
 | 
			
		||||
            'file://' . __DIR__ . '/../private.key',    // path to private key
 | 
			
		||||
            'file://' . __DIR__ . '/../public.key'      // path to public key
 | 
			
		||||
        );
 | 
			
		||||
        $server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
 | 
			
		||||
 | 
			
		||||
        $grant = new PasswordGrant(
 | 
			
		||||
            new UserRepository(),           // instance of UserRepositoryInterface
 | 
			
		||||
 
 | 
			
		||||
@@ -43,6 +43,7 @@ $app = new App([
 | 
			
		||||
            $privateKeyPath,
 | 
			
		||||
            $publicKeyPath
 | 
			
		||||
        );
 | 
			
		||||
        $server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
 | 
			
		||||
 | 
			
		||||
        // Enable the refresh token grant on the server
 | 
			
		||||
        $grant = new RefreshTokenGrant($refreshTokenRepository);
 | 
			
		||||
@@ -66,10 +67,8 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI
 | 
			
		||||
    } catch (OAuthServerException $exception) {
 | 
			
		||||
        return $exception->generateHttpResponse($response);
 | 
			
		||||
    } catch (\Exception $exception) {
 | 
			
		||||
        $body = new Stream('php://temp', 'r+');
 | 
			
		||||
        $body->write($exception->getMessage());
 | 
			
		||||
 | 
			
		||||
        return $response->withStatus(500)->withBody($body);
 | 
			
		||||
        $response->getBody()->write($exception->getMessage());
 | 
			
		||||
        return $response->withStatus(500);
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user