This repository provides necessary ressources to build the Docker image for Mattermost-LDAP module. This Docker image is usefull to try Mattermost-LDAP in a PoC or a demo, and is production ready.
The Mattermost-LDAP module can be use with Nginx or Apache/httpd. Both implementation are available in this repository. Images in this directory are used by Docker compose implementation, for more information, see section "Docker Compose setup" in the main README.md.
Mattermost-LDAP use a database to store tokens and users id. The Mattermost-LDAP Docker implementation is based on the official PostgreSQL server image automatically configured with the init script `init_postgres.sh` mounted in the `init.db` folder. The script is available in [init_db](../init_db/) folder.

The Oauth container exposes port 80 and PostgreSQL container exposes port 5432. The user interacts with the Oauth server and the tokens generated by it are stored in the database. In addition, when a user logs in, his ID is stored with a unique ID. This behavior is necessary for authentication with Mattermost. The figure above illustrates interraction between Oauth server, Postgres database and Mattermost.
You can build docker images by hand or directly use the Docker compose, which will build image automiatically. See section "Docker Compose setup" in the main README.md, for more information. To build images by hand, follow instructions below.
Mattermost-LDAP is available in an embedded version which uses an Apache server image (`mattermostldap`), and in a lightweight version for Nginx (`php-ldap-pgsql`) which is only an PHP image configured to enable necessary modules.
To build mattermostldap image use the `docker build` command :
*Note* : It is recommended to use Podman on CentOS 8 and Fedora. For more information about Podman, see official documentation : https://podman.io/getting-started/
Some image parameters can be changed, by specifying the desired parameters in container's environment variable, when you create a container to adapt it to your configuration. To apply custom parameters, they must be added to the container execution line with the --env (or -e) option followed by the parameter name and the desired value (-e <parameter> = <value> ). For more details, refer to the examples in the Usage section.
The easiest way to use these images is to use the associated Docker compose file, located in the root of this repository. Alternatively, you can run only Mattermost-LDAP image, but you need an external database.
Once built, the mattermostldap image can be used to build a container running the oauth server of the Mattermost-LDAP module. The image contains a default configuration specified in the configuration section. To run a container from the mattermostldap image:
To adapt the parameters of the image, you just need to specify custom parameters in environment variables of the container at its start. For example, to configure the LDAP server, use the following command:
In order to allow a dynamic configuration of the Mattermost-LDAP module, the choice has been made to pass the parameters by environmental variables to the container. However, this method exposes all user-defined settings to all processes in the container. As a result, passwords and security tokens are exposed throughout the container and can easily be recovered by any process running in the container, including a user shell.
Unfortunately, this is the simplest method to avoid defining static parameters in the image, forcing a recompilation of the image each time a value is changed. While waiting for a more secure solution, it is highly recommended to secure access to the container.