Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Re-setting admin auth for Websocket authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ghecquet committed Jun 6, 2016
1 parent 0a09ff3 commit a1b4abb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
20 changes: 12 additions & 8 deletions core/src/plugins/core.mq/class.MqManager.php
Expand Up @@ -318,13 +318,15 @@ public function clientChannelMethod(ServerRequestInterface $request, ResponseInt
} }
} }


public function wsAuthenticate(ServerRequestInterface $requestInterface, ResponseInterface &$responseInterface) public function wsAuthenticate(ServerRequestInterface $request, ResponseInterface &$response)
{ {
$this->logDebug("Entering wsAuthenticate"); $this->logDebug("Entering wsAuthenticate");

$configs = $this->getConfigs(); $configs = $this->getConfigs();
/*if (!isSet($httpVars["key"]) || $httpVars["key"] != $configs["WS_SERVER_ADMIN"]) { $httpVars = $request->getQueryParams();
if (!isSet($httpVars["key"]) || $httpVars["key"] != $configs["WS_SERVER_ADMIN"]) {
throw new Exception("Cannot authentify admin key"); throw new Exception("Cannot authentify admin key");
}*/ }
$user = AuthService::getLoggedUser(); $user = AuthService::getLoggedUser();
if ($user == null) { if ($user == null) {
$this->logDebug("Error Authenticating through WebSocket (not logged)"); $this->logDebug("Error Authenticating through WebSocket (not logged)");
Expand All @@ -339,7 +341,7 @@ public function wsAuthenticate(ServerRequestInterface $requestInterface, Respons
$this->logDebug("Authenticating user ".$user->id." through WebSocket"); $this->logDebug("Authenticating user ".$user->id." through WebSocket");
$x = new \Pydio\Core\Http\Response\SerializableResponseStream(); $x = new \Pydio\Core\Http\Response\SerializableResponseStream();
$x->addChunk(new \Pydio\Core\Http\Message\XMLMessage($xml)); $x->addChunk(new \Pydio\Core\Http\Message\XMLMessage($xml));
$responseInterface = $responseInterface->withBody($x); $response = $response->withBody($x);


} }


Expand Down Expand Up @@ -399,12 +401,14 @@ public function generateCaddyFile($params) {


$hosts = []; $hosts = [];


// Getting URLs of the Pydio system $configs = $this->getConfigs();

// Getting URLs of the Pydio system
$serverURL = Utils::detectServerURL(); $serverURL = Utils::detectServerURL();
$tokenURL = $serverURL . "?get_action=keystore_generate_auth_token"; $tokenURL = $serverURL . "?get_action=keystore_generate_auth_token";
$authURL = $serverURL . "/api/pydio/ws_authenticate"; $authURL = $serverURL . "/api/pydio/ws_authenticate?key=" . $configs["WS_SERVER_ADMIN"];


// Websocket // Websocket Server Config
$host = $params["WS_HOST"]; $host = $params["WS_HOST"];
$port = $params["WS_PORT"]; $port = $params["WS_PORT"];
$secure = $params["WS_SECURE"]; $secure = $params["WS_SECURE"];
Expand All @@ -419,7 +423,7 @@ public function generateCaddyFile($params) {
] ]
); );


// Upload // Upload Server Config
$host = $params["UPLOAD_HOST"]; $host = $params["UPLOAD_HOST"];
$port = $params["UPLOAD_PORT"]; $port = $params["UPLOAD_PORT"];
$secure = $params["UPLOAD_SECURE"]; $secure = $params["UPLOAD_SECURE"];
Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/core.mq/class.PydioInstantMessenger.js
Expand Up @@ -62,6 +62,7 @@ Class.create("PydioInstantMessenger", {
}, },


initForRepoId:function(repoId){ initForRepoId:function(repoId){

if(window.WebSocket && this.configs.get("WS_ACTIVE")){ if(window.WebSocket && this.configs.get("WS_ACTIVE")){


if(this.ws) { if(this.ws) {
Expand All @@ -81,6 +82,7 @@ Class.create("PydioInstantMessenger", {
}else{ }else{
if(repoId){ if(repoId){
var url = "ws"+(this.configs.get("WS_SECURE")?"s":"")+"://"+this.configs.get("WS_HOST")+":"+this.configs.get("WS_PORT")+"/"+this.configs.get("WS_PATH"); var url = "ws"+(this.configs.get("WS_SECURE")?"s":"")+"://"+this.configs.get("WS_HOST")+":"+this.configs.get("WS_PORT")+"/"+this.configs.get("WS_PATH");

this.ws = new WebSocket(url); this.ws = new WebSocket(url);
this.ws.onmessage = function(event){ this.ws.onmessage = function(event){
var obj = parseXml(event.data); var obj = parseXml(event.data);
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.mq/manifest.xml
Expand Up @@ -23,7 +23,7 @@
<global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket port]" label="CONF_MESSAGE[WS Port]" name="WS_PORT" type="string" expose="true" default="8090"/> <global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket port]" label="CONF_MESSAGE[WS Port]" name="WS_PORT" type="string" expose="true" default="8090"/>
<global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket secure]" label="CONF_MESSAGE[WS Client SSL]" name="WS_SECURE" type="boolean" expose="true" default="false"/> <global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket secure]" label="CONF_MESSAGE[WS Client SSL]" name="WS_SECURE" type="boolean" expose="true" default="false"/>
<global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket path]" label="CONF_MESSAGE[WS Path]" name="WS_PATH" type="string" expose="true" default="ws"/> <global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket path]" label="CONF_MESSAGE[WS Path]" name="WS_PATH" type="string" expose="true" default="ws"/>

<global_param group="CONF_MESSAGE[WebSocket Server]" description="CONF_MESSAGE[WebSocket Authentication Key]" label="CONF_MESSAGE[WS Admin Key]" name="WS_SERVER_ADMIN" type="string" default="adminsecretkey"/>


<global_param group="CONF_MESSAGE[Upload]" description="CONF_MESSAGE[Upload server is running]" label="CONF_MESSAGE[Upload]" name="UPLOAD_ACTIVE" type="boolean" expose="true"/> <global_param group="CONF_MESSAGE[Upload]" description="CONF_MESSAGE[Upload server is running]" label="CONF_MESSAGE[Upload]" name="UPLOAD_ACTIVE" type="boolean" expose="true"/>


Expand Down

0 comments on commit a1b4abb

Please sign in to comment.