public function getHandler($conn) { Context::clear(); $app = \Slim\Slim::getInstance(); $credentials = $conn->WebSocket->request->getQuery()->toArray(); // // Aparently, this doesn't work as expected. // // set x-auth-token if (isset($credentials['X-Auth-Token'])) { $app->request->headers->set('X-Auth-Token', $credentials['X-Auth-Token']); unset($credentials['X-Auth-Token']); } // remove "/" and possible "ws/" from resource path $resource = str_replace("ws/", "", substr($conn->WebSocket->request->getPath(), 1)); $hash = md5($resource . join(",", array_values($credentials))); if (!isset($this->handlers[$hash])) { if ($key = Model\AppKey::where('app_id', $credentials['X-App-Id'])->where('key', $credentials['X-App-Key'])->first()) { Context::setKey($key); $channel = Model\Module::channel($resource); if ($channel) { $this->handlers[$hash] = $channel->compile(); } } } return isset($this->handlers[$hash]) ? $this->handlers[$hash] : null; }
public function tearDown() { // restore commandline key AppKey::current()->type = AppKey::TYPE_CLI; Context::setTrusted(false); // reset active auth token AuthToken::setCurrent(null); }
public function keys() { Context::setTablePrefix(''); return Model\AppKey::where('app_id', Context::getAppId())->get(); }
public static function getAppKeys($type = null) { $app_id = self::getAppId(); if (!$app_id) { throw new \Exception("app_id is required."); } // keep previous $connection = \DLModel::getConnectionResolver()->connection(); $previous_prefix = $connection->getTablePrefix(); static::setTablePrefix(''); // filter by app_id $query = AppKey::where('app_id', $app_id); // filter by type if specified if ($type) { $query->where('type', $type); } $app_keys = $query->get(); static::setTablePrefix($previous_prefix); return $app_keys; }
public function tearDown() { // restore commandline key AppKey::current()->type = AppKey::TYPE_CLI; }