Add kolab_chat_session_domain option
This commit is contained in:
parent
1e8d83738c
commit
85cf38adc0
2 changed files with 29 additions and 7 deletions
|
@ -8,7 +8,6 @@
|
||||||
as in the Kolab server. Thanks to this we can auto-login users.
|
as in the Kolab server. Thanks to this we can auto-login users.
|
||||||
1. It has to use the same domain, if it's using different we have to use a proxy:
|
1. It has to use the same domain, if it's using different we have to use a proxy:
|
||||||
Following Apache config worked for me with kolab_chat_url=https://kolab.example.com/mattermost
|
Following Apache config worked for me with kolab_chat_url=https://kolab.example.com/mattermost
|
||||||
Note: This should be simpler with Mattermost 5.1 (to be released soon).
|
|
||||||
|
|
||||||
ProxyPreserveHost Off
|
ProxyPreserveHost Off
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
@ -17,11 +16,12 @@
|
||||||
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
|
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
|
||||||
RewriteRule (/mattermost)?(/api/v[0-9]+/(users/)?websocket) ws://mattermost.example.com:8065$2 [P,QSA,L]
|
RewriteRule (/mattermost)?(/api/v[0-9]+/(users/)?websocket) ws://mattermost.example.com:8065$2 [P,QSA,L]
|
||||||
ProxyPass /mattermost http://mattermost.example.com:8065
|
ProxyPass /mattermost http://mattermost.example.com:8065
|
||||||
ProxyPass /static http://mattermost.example.com:8065/static
|
|
||||||
ProxyPass /help http://mattermost.example.com:8065/help
|
|
||||||
ProxyPass /api http://mattermost.example.com:8065/api
|
|
||||||
|
|
||||||
2. Enabling CORS connections in Mattermost config: AllowCorsFrom:"*"
|
// replace Mattermost security headers allowing the webmail domain
|
||||||
|
Header set X-Frame-Options "allow-from https://webmail.example.com";
|
||||||
|
Header set Content-Security-Policy "frame-ancestors https://webmail.example.com";
|
||||||
|
|
||||||
|
2. Enabling CORS connections in Mattermost config: AllowCorsFrom:"webmail.example.com" (or "*")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Chat application name. For now only 'mattermost' is supported.
|
// Chat application name. For now only 'mattermost' is supported.
|
||||||
|
@ -30,6 +30,9 @@ $config['kolab_chat_driver'] = 'mattermost';
|
||||||
// Chat application URL
|
// Chat application URL
|
||||||
$config['kolab_chat_url'] = 'https://mattermost.example.com';
|
$config['kolab_chat_url'] = 'https://mattermost.example.com';
|
||||||
|
|
||||||
|
// Optional chat application domain (for session cookies)
|
||||||
|
$config['kolab_chat_session_domain'] = null;
|
||||||
|
|
||||||
// Enables opening chat in a new window (or tab)
|
// Enables opening chat in a new window (or tab)
|
||||||
$config['kolab_chat_extwin'] = false;
|
$config['kolab_chat_extwin'] = false;
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ class kolab_chat_mattermost
|
||||||
$this->plugin->add_label('openchat', 'directmessage', 'mentionmessage');
|
$this->plugin->add_label('openchat', 'directmessage', 'mentionmessage');
|
||||||
}
|
}
|
||||||
else if ($this->get_token()) {
|
else if ($this->get_token()) {
|
||||||
rcube_utils::setcookie('MMUSERID', $_SESSION['mattermost'][0], 0, false);
|
$this->setcookie('MMUSERID', $_SESSION['mattermost'][0]);
|
||||||
rcube_utils::setcookie('MMAUTHTOKEN', $_SESSION['mattermost'][1], 0, false);
|
$this->setcookie('MMAUTHTOKEN', $_SESSION['mattermost'][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,4 +336,23 @@ class kolab_chat_mattermost
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set mattermost session cookies
|
||||||
|
*/
|
||||||
|
protected function setcookie($name, $value)
|
||||||
|
{
|
||||||
|
if (headers_sent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cookie = session_get_cookie_params();
|
||||||
|
$secure = $cookie['secure'] || self::https_check();
|
||||||
|
|
||||||
|
if ($domain = $this->rc->config->get('kolab_chat_session_domain')) {
|
||||||
|
$cookie['domain'] = $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
setcookie($name, $value, 0, $cookie['path'], $cookie['domain'], $secure, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue