33use Closure ;
44use Dingo \Api \Http \Response ;
55use Dingo \Api \Routing \Router ;
6- use Dingo \Api \Auth \AuthManager ;
7- use Dingo \Api \Auth \BasicProvider ;
8- use Dingo \Api \Auth \OAuth2Provider ;
6+ use Dingo \Api \Auth \ProviderManager ;
97use Illuminate \Support \ServiceProvider ;
108use Symfony \Component \HttpKernel \Exception \UnauthorizedHttpException ;
119
@@ -29,7 +27,7 @@ public function boot()
2927
3028 $ this ->app ['Dingo\Api\Authentication ' ] = function ($ app )
3129 {
32- return $ app ['dingo.api.authentication ' ];
30+ return $ app ['dingo.api.auth ' ];
3331 };
3432
3533 // Set the static formatters on the response class so that requested formats
@@ -40,7 +38,7 @@ public function boot()
4038
4139 $ this ->app ['router ' ]->filter ('api ' , function ($ route , $ request )
4240 {
43- $ this ->app ['dingo.api.authentication ' ]->authenticate ();
41+ $ this ->app ['dingo.api.auth ' ]->authenticate ();
4442 });
4543 }
4644
@@ -104,7 +102,7 @@ protected function registerDispatcher()
104102 {
105103 $ this ->app ['dingo.api.dispatcher ' ] = $ this ->app ->share (function ($ app )
106104 {
107- return new Dispatcher ($ app ['request ' ], $ app ['url ' ], $ app ['router ' ], $ app ['dingo.api.authentication ' ]);
105+ return new Dispatcher ($ app ['request ' ], $ app ['url ' ], $ app ['router ' ], $ app ['dingo.api.auth ' ]);
108106 });
109107 }
110108
@@ -128,14 +126,14 @@ protected function registerExceptionHandler()
128126 */
129127 protected function registerAuthentication ()
130128 {
131- $ this ->app ['dingo.api.authentication ' ] = $ this ->app ->share (function ($ app )
129+ $ this ->app ['dingo.api.auth.manager ' ] = $ this ->app ->share (function ($ app )
132130 {
133- $ providers = [];
131+ return new ProviderManager ($ app );
132+ });
134133
135- $ resolvers = [
136- 'basic ' => function ($ app , $ options ) { return new BasicProvider ($ app ['auth ' ], $ options ); },
137- 'oauth2 ' => function ($ app , $ options ) { return new OAuth2Provider ($ app ['dingo.oauth.resource ' ], $ options ); }
138- ];
134+ $ this ->app ['dingo.api.auth ' ] = $ this ->app ->share (function ($ app )
135+ {
136+ $ providers = [];
139137
140138 foreach ($ app ['config ' ]['api::auth ' ] as $ key => $ value )
141139 {
@@ -151,7 +149,7 @@ protected function registerAuthentication()
151149 $ options = call_user_func ($ options , $ app );
152150 }
153151
154- $ providers [$ provider ] = $ resolvers [ $ provider ]( $ app , $ options );
152+ $ providers [$ provider ] = $ app [ ' dingo.api.auth.manager ' ]-> driver ( $ provider )-> setOptions ( $ options );
155153 }
156154
157155 return new Authentication ($ app ['router ' ], $ app ['auth ' ], $ providers );
0 commit comments