public function getClientRepository()
 {
     $server = m::mock('League\\OAuth2\\Server\\AbstractServer');
     $repo = new FluentClient($this->app['db']);
     $repo->setServer($server);
     return $repo;
 }
Example #2
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $secret = substr(sha1(time() . mt_rand()), 0, 40);
     $this->clients->create($this->argument('name'), $this->argument('client_id'), ($public = $this->option('public')) ? '' : $secret);
     if (!$public) {
         $this->info("Here is the key for your new client:");
         $this->comment($secret);
     } else {
         $this->info("Your new client is ready");
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $clientName = $this->argument('clientName');
     $clientId = $this->argument('clientId');
     $clientSecret = $this->argument('clientSecret');
     $this->clientRepo->create($clientName, $clientId, $clientSecret);
     $this->info('Client created successfully');
     $this->info('Client Name: ' . $clientName);
     $this->info('Client ID: ' . $clientId);
     $this->info('Client Secret: ' . $clientSecret);
 }
 /**
  * Bind the storage implementations to the IoC container.
  *
  * @return void
  */
 public function registerStorageBindings()
 {
     $provider = $this;
     $this->app->singleton(FluentAccessToken::class, function () use($provider) {
         $storage = new FluentAccessToken($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->singleton(FluentAuthCode::class, function () use($provider) {
         $storage = new FluentAuthCode($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->singleton(FluentClient::class, function ($app) use($provider) {
         $limitClientsToGrants = $app['config']->get('oauth2.limit_clients_to_grants');
         $storage = new FluentClient($provider->app['db'], $limitClientsToGrants);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->singleton(FluentRefreshToken::class, function () use($provider) {
         $storage = new FluentRefreshToken($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->singleton(FluentScope::class, function ($app) use($provider) {
         $limitClientsToScopes = $app['config']->get('oauth2.limit_clients_to_scopes');
         $limitScopesToGrants = $app['config']->get('oauth2.limit_scopes_to_grants');
         $storage = new FluentScope($provider->app['db'], $limitClientsToScopes, $limitScopesToGrants);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->singleton(FluentSession::class, function () use($provider) {
         $storage = new FluentSession($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
 }
 /**
  * Bind the storage implementations to the IoC container
  * @return void
  */
 public function registerStorageBindings()
 {
     $provider = $this;
     $this->app->bindShared('LucaDegasperi\\OAuth2Server\\Storage\\FluentAccessToken', function () use($provider) {
         $storage = new FluentAccessToken($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->bindShared('LucaDegasperi\\OAuth2Server\\Storage\\FluentAuthCode', function () use($provider) {
         $storage = new FluentAuthCode($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->bindShared('LucaDegasperi\\OAuth2Server\\Storage\\FluentClient', function ($app) use($provider) {
         $limitClientsToGrants = $app['config']->get('oauth2.limit_clients_to_grants');
         $storage = new FluentClient($provider->app['db'], $limitClientsToGrants);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->bindShared('LucaDegasperi\\OAuth2Server\\Storage\\FluentRefreshToken', function () use($provider) {
         $storage = new FluentRefreshToken($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->bindShared('LucaDegasperi\\OAuth2Server\\Storage\\FluentScope', function ($app) use($provider) {
         $limitClientsToScopes = $app['config']->get('oauth2.limit_clients_to_scopes');
         $limitScopesToGrants = $app['config']->get('oauth2.limit_scopes_to_grants');
         $storage = new FluentScope($provider->app['db'], $limitClientsToScopes, $limitScopesToGrants);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
     $this->app->bindShared('LucaDegasperi\\OAuth2Server\\Storage\\FluentSession', function () use($provider) {
         $storage = new FluentSession($provider->app['db']);
         $storage->setConnectionName($provider->getConnectionName());
         return $storage;
     });
 }
 /**
  * Get the client associated with a session
  *
  * @param \League\OAuth2\Server\Entity\SessionEntity $session The session
  *
  * @return \League\OAuth2\Server\Entity\ClientEntity | null
  */
 public function getBySession(SessionEntity $session)
 {
     $result = $this->storage->getBySession($session);
     return $result;
 }