public function boot() { $this->app['api.auth']->extend('oauth', function ($app) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker(), false); $provider->setUserResolver(function ($id) { // Logic to return a user by their ID. return \App\User::findOrFail($id); }); $provider->setClientResolver(function ($id) { // Logic to return a client by their ID. return \App\User::findOrFail($id); }); return $provider; }); /* $this->app[Auth::class]->extend('oauth', function ($app) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { // Logic to return a user by their ID. return App\User::findOrFail($id); }); $provider->setClientResolver(function ($id) { // Logic to return a client by their ID. return App\User::findOrFail($id); }); return $provider; }); * */ }
public function boot() { $this->app[Auth::class]->extend('oauth', function ($app) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { // Logic to return a user by their ID. }); $provider->setClientResolver(function ($id) { // Logic to return a client by their ID. }); return $provider; }); }
public function boot() { $this->app[DingoAuth::class]->extend('oauth', function ($app) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { Auth::loginUsingId($id); return User::findOrFail($id); }); $provider->setClientResolver(function ($id) { //TODO: Logic to return a client by their ID. }); return $provider; }); }
/** * Bootstrap the application services. * * @return void */ public function boot() { app('Dingo\\Api\\Auth\\Auth')->extend('oauth', function ($app) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setClientResolver(function ($id) { // Logic to return a client by their ID. }); $provider->setUserResolver(function ($id) { $resolver = app(UserResolver::class); return $resolver->resolveById($id); }); return $provider; }); }
/** * Booting application */ public function boot() { $userRepository = $this->app['App\\Repositories\\UserRepository']; $oauthClientRepository = $this->app['App\\Repositories\\OauthClientRepository']; $this->app[Auth::class]->extend('oauth', function ($app) use($userRepository, $oauthClientRepository) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) use($userRepository) { return $userRepository->findById($id); }); $provider->setClientResolver(function ($id) use($oauthClientRepository) { return $oauthClientRepository->findById($id); }); return $provider; }); }
/** * Register the oAuth 2 server provider */ public function registerOAuthProvider() { app('Dingo\\Api\\Auth\\Auth')->extend('oauth', function ($app) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { $resolver = app(UserResolverInterface::class); return $resolver->resolveById($id); }); $provider->setClientResolver(function ($id) { $resolver = app(ClientResolverInterface::class); return $resolver->resolveById($id); }); return $provider; }); }
public function boot(UserRepository $repository) { $this->app[Auth::class]->extend('oauth', function ($app) use($repository) { $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) use($repository) { // Logic to return a user by their ID. return $repository->get($id); }); /*$provider->setClientResolver(function ($id) { // Logic to return a client by their ID. return new \stdClass; });*/ return $provider; }); }