Class rename fixes

This commit is contained in:
Alex Bilbie 2016-04-17 12:54:49 +01:00
parent 7c35778316
commit 6ed9cbf701
6 changed files with 31 additions and 36 deletions

View File

@ -1,7 +1,6 @@
<?php <?php
use League\OAuth2\Server\ResourceServer; use League\OAuth2\Server\ResourceServer;
use League\OAuth2\Server\Server;
use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
@ -13,7 +12,7 @@ $app = new App([
'settings' => [ 'settings' => [
'displayErrorDetails' => true, 'displayErrorDetails' => true,
], ],
Server::class => function () { ResourceServer::class => function () {
// Setup the authorization server // Setup the authorization server
$server = new ResourceServer( $server = new ResourceServer(
new AccessTokenRepository(), new AccessTokenRepository(),
@ -26,7 +25,7 @@ $app = new App([
$app->add( $app->add(
new \League\OAuth2\Server\Middleware\ResourceServerMiddleware( new \League\OAuth2\Server\Middleware\ResourceServerMiddleware(
$app->getContainer()->get(Server::class) $app->getContainer()->get(ResourceServer::class)
) )
); );

View File

@ -2,8 +2,7 @@
use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\AuthCodeGrant; use League\OAuth2\Server\Grant\AuthCodeGrant;
use League\OAuth2\Server\RequestTypes\AuthorizationRequest; use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Server;
use OAuth2ServerExamples\Entities\UserEntity; use OAuth2ServerExamples\Entities\UserEntity;
use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use OAuth2ServerExamples\Repositories\AuthCodeRepository; use OAuth2ServerExamples\Repositories\AuthCodeRepository;
@ -21,7 +20,7 @@ $app = new App([
'settings' => [ 'settings' => [
'displayErrorDetails' => true, 'displayErrorDetails' => true,
], ],
Server::class => function () { AuthorizationServer::class => function () {
// Init our repositories // Init our repositories
$clientRepository = new ClientRepository(); $clientRepository = new ClientRepository();
$scopeRepository = new ScopeRepository(); $scopeRepository = new ScopeRepository();
@ -33,7 +32,7 @@ $app = new App([
$publicKeyPath = 'file://' . __DIR__ . '/../public.key'; $publicKeyPath = 'file://' . __DIR__ . '/../public.key';
// Setup the authorization server // Setup the authorization server
$server = new Server( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$accessTokenRepository, $accessTokenRepository,
$scopeRepository, $scopeRepository,
@ -56,8 +55,8 @@ $app = new App([
]); ]);
$app->get('/authorize', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) { $app->get('/authorize', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */ /* @var \League\OAuth2\Server\AuthorizationServer $server */
$server = $app->getContainer()->get(Server::class); $server = $app->getContainer()->get(AuthorizationServer::class);
try { try {
// Validate the HTTP request and return an AuthorizationRequest object. // Validate the HTTP request and return an AuthorizationRequest object.
@ -84,8 +83,8 @@ $app->get('/authorize', function (ServerRequestInterface $request, ResponseInter
}); });
$app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) { $app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */ /* @var \League\OAuth2\Server\AuthorizationServer $server */
$server = $app->getContainer()->get(Server::class); $server = $app->getContainer()->get(AuthorizationServer::class);
try { try {
return $server->respondToAccessTokenRequest($request, $response); return $server->respondToAccessTokenRequest($request, $response);

View File

@ -2,7 +2,7 @@
use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\ImplicitGrant; use League\OAuth2\Server\Grant\ImplicitGrant;
use League\OAuth2\Server\Server; use League\OAuth2\Server\AuthorizationServer;
use OAuth2ServerExamples\Entities\UserEntity; use OAuth2ServerExamples\Entities\UserEntity;
use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use OAuth2ServerExamples\Repositories\ClientRepository; use OAuth2ServerExamples\Repositories\ClientRepository;
@ -18,7 +18,7 @@ $app = new App([
'settings' => [ 'settings' => [
'displayErrorDetails' => true, 'displayErrorDetails' => true,
], ],
Server::class => function () { AuthorizationServer::class => function () {
// Init our repositories // Init our repositories
$clientRepository = new ClientRepository(); $clientRepository = new ClientRepository();
$scopeRepository = new ScopeRepository(); $scopeRepository = new ScopeRepository();
@ -28,7 +28,7 @@ $app = new App([
$publicKeyPath = 'file://' . __DIR__ . '/../public.key'; $publicKeyPath = 'file://' . __DIR__ . '/../public.key';
// Setup the authorization server // Setup the authorization server
$server = new Server( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$accessTokenRepository, $accessTokenRepository,
$scopeRepository, $scopeRepository,
@ -44,8 +44,8 @@ $app = new App([
]); ]);
$app->get('/authorize', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) { $app->get('/authorize', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */ /* @var \League\OAuth2\Server\AuthorizationServer $server */
$server = $app->getContainer()->get(Server::class); $server = $app->getContainer()->get(AuthorizationServer::class);
try { try {
// Validate the HTTP request and return an AuthorizationRequest object. // Validate the HTTP request and return an AuthorizationRequest object.

View File

@ -2,15 +2,14 @@
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\AuthenticationServerMiddleware; use League\OAuth2\Server\Middleware\AuthorizationServerMiddleware;
use League\OAuth2\Server\Middleware\ResourceServerMiddleware; use League\OAuth2\Server\Middleware\ResourceServerMiddleware;
use League\OAuth2\Server\Server; use League\OAuth2\Server\AuthorizationServer;
use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use OAuth2ServerExamples\Repositories\AuthCodeRepository; use OAuth2ServerExamples\Repositories\AuthCodeRepository;
use OAuth2ServerExamples\Repositories\ClientRepository; use OAuth2ServerExamples\Repositories\ClientRepository;
use OAuth2ServerExamples\Repositories\RefreshTokenRepository; use OAuth2ServerExamples\Repositories\RefreshTokenRepository;
use OAuth2ServerExamples\Repositories\ScopeRepository; use OAuth2ServerExamples\Repositories\ScopeRepository;
use OAuth2ServerExamples\Repositories\UserRepository;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Slim\App; use Slim\App;
@ -22,20 +21,19 @@ $app = new App([
'settings' => [ 'settings' => [
'displayErrorDetails' => true, 'displayErrorDetails' => true,
], ],
Server::class => function () { AuthorizationServer::class => function () {
// Init our repositories // Init our repositories
$clientRepository = new ClientRepository(); $clientRepository = new ClientRepository();
$accessTokenRepository = new AccessTokenRepository(); $accessTokenRepository = new AccessTokenRepository();
$scopeRepository = new ScopeRepository(); $scopeRepository = new ScopeRepository();
$authCodeRepository = new AuthCodeRepository(); $authCodeRepository = new AuthCodeRepository();
$refreshTokenRepository = new RefreshTokenRepository(); $refreshTokenRepository = new RefreshTokenRepository();
$userRepository = new UserRepository();
$privateKeyPath = 'file://' . __DIR__ . '/../private.key'; $privateKeyPath = 'file://' . __DIR__ . '/../private.key';
$publicKeyPath = 'file://' . __DIR__ . '/../public.key'; $publicKeyPath = 'file://' . __DIR__ . '/../public.key';
// Setup the authorization server // Setup the authorization server
$server = new Server( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$accessTokenRepository, $accessTokenRepository,
$scopeRepository, $scopeRepository,
@ -48,7 +46,6 @@ $app = new App([
new AuthCodeGrant( new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$refreshTokenRepository, $refreshTokenRepository,
$userRepository,
new \DateInterval('PT10M') new \DateInterval('PT10M')
), ),
new \DateInterval('PT1H') new \DateInterval('PT1H')
@ -66,7 +63,7 @@ $app = new App([
// Access token issuer // Access token issuer
$app->post('/access_token', function () { $app->post('/access_token', function () {
})->add(new AuthenticationServerMiddleware($app->getContainer()->get(Server::class))); })->add(new AuthorizationServerMiddleware($app->getContainer()->get(AuthorizationServer::class)));
// Secured API // Secured API
$app->group('/api', function () { $app->group('/api', function () {
@ -90,6 +87,6 @@ $app->group('/api', function () {
return $response->withBody($body); return $response->withBody($body);
}); });
})->add(new ResourceServerMiddleware($app->getContainer()->get(Server::class))); })->add(new ResourceServerMiddleware($app->getContainer()->get(AuthorizationServer::class)));
$app->run(); $app->run();

View File

@ -2,7 +2,7 @@
use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\PasswordGrant; use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Server; use League\OAuth2\Server\AuthorizationServer;
use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use OAuth2ServerExamples\Repositories\ClientRepository; use OAuth2ServerExamples\Repositories\ClientRepository;
use OAuth2ServerExamples\Repositories\RefreshTokenRepository; use OAuth2ServerExamples\Repositories\RefreshTokenRepository;
@ -19,7 +19,7 @@ $app = new App([
'settings' => [ 'settings' => [
'displayErrorDetails' => true, 'displayErrorDetails' => true,
], ],
Server::class => function () { AuthorizationServer::class => function () {
// Init our repositories // Init our repositories
$clientRepository = new ClientRepository(); $clientRepository = new ClientRepository();
$accessTokenRepository = new AccessTokenRepository(); $accessTokenRepository = new AccessTokenRepository();
@ -31,7 +31,7 @@ $app = new App([
$publicKeyPath = 'file://' . __DIR__ . '/../public.key'; $publicKeyPath = 'file://' . __DIR__ . '/../public.key';
// Setup the authorization server // Setup the authorization server
$server = new Server( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$accessTokenRepository, $accessTokenRepository,
$scopeRepository, $scopeRepository,
@ -50,8 +50,8 @@ $app = new App([
]); ]);
$app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) { $app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */ /* @var \League\OAuth2\Server\AuthorizationServer $server */
$server = $app->getContainer()->get(Server::class); $server = $app->getContainer()->get(AuthorizationServer::class);
try { try {
return $server->respondToAccessTokenRequest($request, $response); return $server->respondToAccessTokenRequest($request, $response);

View File

@ -2,7 +2,7 @@
use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\RefreshTokenGrant; use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\Server; use League\OAuth2\Server\AuthorizationServer;
use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use OAuth2ServerExamples\Repositories\ClientRepository; use OAuth2ServerExamples\Repositories\ClientRepository;
use OAuth2ServerExamples\Repositories\RefreshTokenRepository; use OAuth2ServerExamples\Repositories\RefreshTokenRepository;
@ -18,7 +18,7 @@ $app = new App([
'settings' => [ 'settings' => [
'displayErrorDetails' => true, 'displayErrorDetails' => true,
], ],
Server::class => function () { AuthorizationServer::class => function () {
// Init our repositories // Init our repositories
$clientRepository = new ClientRepository(); $clientRepository = new ClientRepository();
$accessTokenRepository = new AccessTokenRepository(); $accessTokenRepository = new AccessTokenRepository();
@ -29,7 +29,7 @@ $app = new App([
$publicKeyPath = 'file://' . __DIR__ . '/../public.key'; $publicKeyPath = 'file://' . __DIR__ . '/../public.key';
// Setup the authorization server // Setup the authorization server
$server = new Server( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$accessTokenRepository, $accessTokenRepository,
$scopeRepository, $scopeRepository,
@ -51,8 +51,8 @@ $app = new App([
]); ]);
$app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) { $app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */ /* @var \League\OAuth2\Server\AuthorizationServer $server */
$server = $app->getContainer()->get(Server::class); $server = $app->getContainer()->get(AuthorizationServer::class);
try { try {
return $server->respondToAccessTokenRequest($request, $response); return $server->respondToAccessTokenRequest($request, $response);