Esempio n. 1
0
 public function associateScope(SessionEntity $session, ScopeEntity $scope)
 {
     $session = Session::where('id', '=', $session->getId())->first();
     $scope = Scope::where('identifier', '=', $scope->getId())->first();
     if ($session && $scope) {
         $session->scopes()->attach($scope);
     }
 }
 public function associateScope(AccessTokenEntity $token, ScopeEntity $scope)
 {
     $token = AccessToken::where('token', '=', $token->getId())->first();
     $scope = Scope::where('identifier', '=', $scope->getId())->first();
     if ($token && $scope) {
         $token->scopes()->attach($scope);
     }
 }
Esempio n. 3
0
 public function get($scope, $grantType = null, $clientId = null)
 {
     $scope = Scope::where('identifier', '=', $scope)->first();
     if (!$scope) {
         return;
     }
     return (new ScopeEntity($this->server))->hydrate(["id" => $scope->identifier, "description" => $scope->description]);
 }
Esempio n. 4
0
 public static function grantScopesToAccessToken($token, $scopes)
 {
     $accessToken = AccessToken::where('token', '=', $token)->first();
     if (!$accessToken) {
         return false;
     }
     $current_scopes = $accessToken->scopes;
     $hasScope = function ($scope) use($current_scopes) {
         foreach ($current_scopes as $_scope) {
             if ($_scope->identifier == $scope) {
                 return $_scope;
             }
         }
         return false;
     };
     if ($accessToken) {
         foreach ($scopes as $_scope) {
             if (!$hasScope($_scope)) {
                 $scope = Scope::where('identifier', '=', $_scope)->first();
                 if ($scope) {
                     $accessToken->scopes()->attach($scope);
                     $session = $accessToken->session;
                     $session->scopes()->attach($scope);
                 }
             }
         }
     }
 }