Skip to content

Commit 27db57f

Browse files
committed
Add better Laravel 5.2 support
1 parent c8d594a commit 27db57f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/OAuth2ServerServiceProvider.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,20 @@ protected function setupMigrations(Application $app)
8989
*/
9090
public function register()
9191
{
92-
$this->registerAuthorizer();
93-
$this->registerMiddlewareBindings();
92+
$this->registerAuthorizer($this->app);
93+
$this->registerMiddlewareBindings($this->app);
9494
}
9595

9696
/**
9797
* Register the Authorization server with the IoC container.
9898
*
99+
* @param \Illuminate\Contracts\Foundation\Application $app
100+
*
99101
* @return void
100102
*/
101-
public function registerAuthorizer()
103+
public function registerAuthorizer(Application $app)
102104
{
103-
$this->app->bindShared('oauth2-server.authorizer', function ($app) {
105+
$app->singleton('oauth2-server.authorizer', function ($app) {
104106
$config = $app['config']->get('oauth2');
105107
$issuer = $app->make(AuthorizationServer::class)
106108
->setClientStorage($app->make(ClientInterface::class))
@@ -152,34 +154,34 @@ public function registerAuthorizer()
152154
return $authorizer;
153155
});
154156

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

160160
/**
161161
* Register the Middleware to the IoC container because
162162
* some middleware need additional parameters.
163163
*
164+
* @param \Illuminate\Contracts\Foundation\Application $app
165+
*
164166
* @return void
165167
*/
166-
public function registerMiddlewareBindings()
168+
public function registerMiddlewareBindings(Application $app)
167169
{
168-
$this->app->bindShared(CheckAuthCodeRequestMiddleware::class, function ($app) {
170+
$app->singleton(CheckAuthCodeRequestMiddleware::class, function ($app) {
169171
return new CheckAuthCodeRequestMiddleware($app['oauth2-server.authorizer']);
170172
});
171173

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

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

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

182-
$this->app->bindShared(OAuthUserOwnerMiddleware::class, function ($app) {
184+
$app->singleton(OAuthUserOwnerMiddleware::class, function ($app) {
183185
return new OAuthUserOwnerMiddleware($app['oauth2-server.authorizer']);
184186
});
185187
}

0 commit comments

Comments
 (0)