tl;dr: I’m trying to get Mattermost to trust the reverse proxy’s REMOTE_USER setting for authentication
The idea here would be to use the reverse proxy’s modules for authentication. I’ve seen the LDAP/SSO feedback request, but this approach is different in that Mattermost would not have to duplicate the security logic.
I’ve gotten so far as to get Active Directory SSO to work with Apache2’s libapache2-mod-auth-kerb. At this point Mattermost could just trust the REMOTE_USER header, since it’s guaranteed to be set and purified by Apache2. Chrome and IE are operational, out of the box, Firefox users have to hop through a few loops.
I’ve gotten a very similar setup to work with other web applications, e.g., phpBB, graphite, etc, but I’m unsure on how to proceed with Mattermost’s Erlang + Go. Any ideas?
The prerequisites are a working Kerberos authentication so that kinit and klist work. I’m using Ubuntu 14.04(.3 LTS). Here are the relevant snippets to duplicate my setup:
sudo apt-get install apache2 gnutls-bin msktutil libapache2-mod-auth-kerb
kinit
klist
cd && msktutil --create --base OU=Testlab --service HTTP --keytab http_mmost01.krb5keytab --computer-name mmost01 --upn HTTP/mmost01.foo.bar
sudo chown www-data:www-data http_mmost01.krb5keytab
sudo chmod 0600 http_mmost01.krb5keytab
sudo cp http_mmost01.krb5tab /etc/apache2/
sudo a2enmod proxy_wstunnel proxy proxy_http ssl
/etc/apache2/sites-enabled$ cat 001-mattermost-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin admin@foo.bar
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/key.pem
ProxyRequests Off
ProxyPreserveHost On
# https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
Header always append X-Frame-Options SAMEORIGIN
<Location "/">
AuthType Kerberos
KrbAuthRealms FOO.BAR
Krb5Keytab /etc/apache2/http_mmost01.krb5keytab
KrbMethodNegotiate On
KrbMethodK5Passwd Off # set to On for Firefox
KrbLocalUserMapping On
require valid-user
# http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
ProxyPass ws://localhost:8065/ retry=0
</Location>
</VirtualHost>