예제 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('appId');
     $userId = $input->getArgument('userId');
     $scopes = $input->getArgument('scopes');
     $expire = $input->getArgument('expire');
     if (!is_numeric($appId)) {
         $app = $this->appTable->getOneByName($appId);
     } else {
         $app = $this->appTable->get($appId);
     }
     if (empty($app)) {
         throw new RuntimeException('Invalid app');
     }
     if (!is_numeric($userId)) {
         $user = $this->userTable->getOneByName($userId);
     } else {
         $user = $this->userTable->get($userId);
     }
     if (empty($user)) {
         throw new RuntimeException('Invalid user');
     }
     $scopes = $this->scopeService->getValidScopes($app['id'], $user['id'], $scopes);
     $ip = '127.0.0.1';
     $expire = new DateInterval($expire);
     $accessToken = $this->appService->generateAccessToken($app['id'], $user['id'], $scopes, $ip, $expire);
     $response = ['App' => $app['name'], 'User' => $user['name'], 'Token' => $accessToken->getAccessToken(), 'Expires' => date('Y-m-d', $accessToken->getExpiresIn()), 'Scope' => $accessToken->getScope()];
     $output->writeln("");
     $output->writeln(Yaml::dump($response, 2));
     $output->writeln("");
 }
예제 #2
0
파일: User.php 프로젝트: apioo/fusio-impl
 public function getDetail($userId)
 {
     $user = $this->get($userId);
     $user['scopes'] = $this->userTable->getScopeNames($user['id']);
     $user['apps'] = $this->appTable->getByUserId($user['id'], Fields::blacklist(['userId', 'parameters', 'appSecret']));
     return $user;
 }
예제 #3
0
파일: App.php 프로젝트: apioo/fusio-impl
 public function removeToken($appId, $tokenId)
 {
     $app = $this->appTable->get($appId);
     if (!empty($app)) {
         $this->appTokenTable->removeTokenFromApp($appId, $tokenId);
     } else {
         throw new StatusCode\NotFoundException('Invalid app');
     }
 }
예제 #4
0
 public function delete($userId, $appId)
 {
     $app = $this->appTable->get($appId);
     if (!empty($app)) {
         if ($app['userId'] != $userId) {
             throw new StatusCode\BadRequestException('App does not belong to the user');
         }
         $this->appService->delete($appId);
     } else {
         throw new StatusCode\NotFoundException('Could not find app');
     }
 }
예제 #5
0
파일: Grant.php 프로젝트: apioo/fusio-impl
 public function getAll($userId)
 {
     return $this->appTable->getAuthorizedApps($userId);
 }