Merge pull request #682 from wilsonge/patch-1

Fix middleware example fatal error
This commit is contained in:
Alex Bilbie 2016-11-08 13:18:13 +00:00 committed by GitHub
commit b32204bd91

View File

@ -8,6 +8,7 @@
*/ */
use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\ResourceServer;
use League\OAuth2\Server\Grant\AuthCodeGrant; use League\OAuth2\Server\Grant\AuthCodeGrant;
use League\OAuth2\Server\Grant\RefreshTokenGrant; use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\Middleware\AuthorizationServerMiddleware; use League\OAuth2\Server\Middleware\AuthorizationServerMiddleware;
@ -66,6 +67,15 @@ $app = new App([
return $server; return $server;
}, },
ResourceServer::class => function () {
$publicKeyPath = 'file://' . __DIR__ . '/../public.key';
$server = new ResourceServer(
new AccessTokenRepository(),
$publicKeyPath
);
return $server;
},
]); ]);
// Access token issuer // Access token issuer
@ -94,6 +104,6 @@ $app->group('/api', function () {
return $response->withBody($body); return $response->withBody($body);
}); });
})->add(new ResourceServerMiddleware($app->getContainer()->get(AuthorizationServer::class))); })->add(new ResourceServerMiddleware($app->getContainer()->get(ResourceServer::class)));
$app->run(); $app->run();