예제 #1
0
파일: Token.php 프로젝트: J0s3f/simpleid
 /**
  * Revokes all tokens issued from a specifed authorisation and,
  * optionally, a token source.
  *
  * @param Authorization $authorization the authorisation for which
  * tokens are to be revoked
  * @param TokenSource $source if specified, only delete tokens issued
  * from this source
  */
 public static function revokeAll($authorization, $source = null)
 {
     $cache = \Cache::instance();
     if ($source != null) {
         if ($source instanceof TokenSource) {
             $source_ref = $source->getSourceRef();
         } elseif (is_string($source)) {
             $source_ref = $source;
         }
         $suffix = self::SOURCE_REF_SEPARATOR . $source_ref;
     } else {
         $suffix = '';
     }
     $suffix .= '.' . $authorization->getFullyQualifiedID() . '.oauth_token';
     $cache->reset($suffix);
 }
예제 #2
0
 /** @see SimpleID\API\MyHooks::revokeAppHook() */
 public function revokeAppHook($cid)
 {
     $auth = AuthManager::instance();
     $store = StoreManager::instance();
     $user = $auth->getUser();
     $client = $store->loadClient($cid, 'SimpleID\\Protocols\\OAuth\\OAuthClient');
     $aid = Authorization::buildID($user, $client);
     $authorization = $store->loadAuth($aid);
     if ($authorization != null) {
         $authorization->revokeAllTokens();
         $store->deleteAuth($authorization);
     }
 }
예제 #3
0
파일: Code.php 프로젝트: J0s3f/simpleid
 /**
  * Creates an authorization code.
  *
  * Once the authorization code object has been created, the code can be retrieved using
  * the {@link getCode()} method.
  *
  * @param Authorization $authorization the authorization that wishes to generate
  * this code
  * @param string|null $redirect_uri the redirect_uri parameter in the authorisation request, if
  * present
  * @param array $scope the allowed scope - this should be a subset of the scope provided by the
  * authorization
  * @param array $additional additional data to be stored in the authorization code
  * @return Code the authorization code object
  */
 public static function create($authorization, $redirect_uri, $scope, $additional = array())
 {
     $code = new Code();
     $rand = new Random();
     $cache = \Cache::instance();
     $code->cid = $rand->id();
     $code->aid = $authorization->getStoreID();
     $code->auth_state = $authorization->getAuthState();
     $code->redirect_uri = $redirect_uri;
     $code->scope = !is_array($scope) ? explode(' ', $scope) : $scope;
     $code->additional = $additional;
     $code->expires = time() + SIMPLEID_INSTANT_TOKEN_EXPIRES_IN;
     $cache->set($code->getCode() . '.code', $code, SIMPLEID_INSTANT_TOKEN_EXPIRES_IN);
     $code->is_valid = true;
     return $code;
 }