Skip to content

Commit

Permalink
Add better Laravel 5.2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Dec 22, 2015
1 parent c8d594a commit 27db57f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/OAuth2ServerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,20 @@ protected function setupMigrations(Application $app)
*/
public function register()
{
$this->registerAuthorizer();
$this->registerMiddlewareBindings();
$this->registerAuthorizer($this->app);
$this->registerMiddlewareBindings($this->app);
}

/**
* Register the Authorization server with the IoC container.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
public function registerAuthorizer()
public function registerAuthorizer(Application $app)
{
$this->app->bindShared('oauth2-server.authorizer', function ($app) {
$app->singleton('oauth2-server.authorizer', function ($app) {
$config = $app['config']->get('oauth2');
$issuer = $app->make(AuthorizationServer::class)
->setClientStorage($app->make(ClientInterface::class))
Expand Down Expand Up @@ -152,34 +154,34 @@ public function registerAuthorizer()
return $authorizer;
});

$this->app->bind(Authorizer::class, function ($app) {
return $app['oauth2-server.authorizer'];
});
$app->alias('oauth2-server.authorizer', Authorizer::class);
}

/**
* Register the Middleware to the IoC container because
* some middleware need additional parameters.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
public function registerMiddlewareBindings()
public function registerMiddlewareBindings(Application $app)
{
$this->app->bindShared(CheckAuthCodeRequestMiddleware::class, function ($app) {
$app->singleton(CheckAuthCodeRequestMiddleware::class, function ($app) {
return new CheckAuthCodeRequestMiddleware($app['oauth2-server.authorizer']);
});

$this->app->bindShared(OAuthMiddleware::class, function ($app) {
$app->singleton(OAuthMiddleware::class, function ($app) {
$httpHeadersOnly = $app['config']->get('oauth2.http_headers_only');

return new OAuthMiddleware($app['oauth2-server.authorizer'], $httpHeadersOnly);
});

$this->app->bindShared(OAuthClientOwnerMiddleware::class, function ($app) {
$app->singleton(OAuthClientOwnerMiddleware::class, function ($app) {
return new OAuthClientOwnerMiddleware($app['oauth2-server.authorizer']);
});

$this->app->bindShared(OAuthUserOwnerMiddleware::class, function ($app) {
$app->singleton(OAuthUserOwnerMiddleware::class, function ($app) {
return new OAuthUserOwnerMiddleware($app['oauth2-server.authorizer']);
});
}
Expand Down

0 comments on commit 27db57f

Please sign in to comment.