Пример #1
0
 public static function create(AccessToken $access_token, $lifetime = 0)
 {
     $instance = new self();
     $instance->value = Rand::getString($instance->len, OAuth2Protocol::VsChar, true);
     $instance->scope = $access_token->getScope();
     $instance->user_id = $access_token->getUserId();
     $instance->client_id = $access_token->getClientId();
     $instance->audience = $access_token->getAudience();
     $instance->from_ip = IPHelper::getUserIp();
     $instance->lifetime = intval($lifetime);
     $instance->is_hashed = false;
     return $instance;
 }
Пример #2
0
 /**
  * Checks if current_ip has access rights on the given $access_token
  * @param AccessToken $access_token
  * @param $current_ip
  * @return bool
  */
 public function checkAccessTokenAudience(AccessToken $access_token, $current_ip)
 {
     $current_audience = $access_token->getAudience();
     $current_audience = explode(' ', $current_audience);
     if (!is_array($current_audience)) {
         $current_audience = array($current_audience);
     }
     return \ResourceServer::where('active', '=', true)->where('ip', '=', $current_ip)->whereIn('host', $current_audience)->count() > 0;
 }