Debian Codegraph @

doc/sources/admin/applications/mattermost.rst

raw
1 Mattermost Team Edition
2 =======================
3
4 |image0|
5
6 Presentation
7 ------------
8
9 Mattermost is a team-based instant messaging application.
10
11 See `the official Mattermost website <https://mattermost.com/>`__ for a
12 complete presentation.
13
14 Mattermost follows an Open Core development model. The freely available
15 `Team edition <https://docs.mattermost.com/developer/manifesto.html>`__
16 contains all the basic chat features, but lack the integration
17 capabilities found in the `Enterprise
18 edition <https://mattermost.com/pricing/>`__.
19
20 The Enterprise edition provides `SAML
21 integration <https://docs.mattermost.com/deployment/sso-saml.html>`__
22 out of the box, and you can configure it just like
23 :doc:`any other SAML service in LemonLDAP::NG<..//idpsaml>`
24
25 The Team edition, however, only provides SSO integration with Gitlab.
26
27 However, it is possible to configure LemonLDAP::NG to behave exactly
28 like a Gitlab Oauth2 server, allowing Mattermost Team Edition to be
29 integrated with LemonLDAP::NG without having to use a
30 :doc:`Gitlab<gitlab>` server.
31
32
33 .. danger::
34
35 The following configuration requires your user database
36 to expose a unique numeric identifier for every user.
37
38 Configuring Mattermost Team Edition
39 -----------------------------------
40
41 Configuring Mattermost through the *System Console* will not allow you
42 to set the correct URLs. You need to edit the Mattermost configuration
43 file, and avoid changing Gitlab integration settings in the *System
44 Console*
45
46 Set the following settings in ``/opt/mattermost/config/config.json``
47
48 ::
49
50 "GitLabSettings": {
51 "Enable": true,
52 "Secret": "CHOOSE_A_CLIENT_SECRET",
53 "Id": "CHOOSE_A_CLIENT_ID",
54 "Scope": "",
55 "AuthEndpoint": "https://auth.example.com/oauth2/gitlab_authorize",
56 "TokenEndpoint": "https://auth.example.com/oauth2/token",
57 "UserApiEndpoint": "https://auth.example.com/oauth2/userinfo"
58 },
59
60 Configuring your web server
61 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
62
63 Mattermost does not use OpenID Connect to communicate with Gitlab, but
64 uses plain OAuth2 instead. Because of that, LemonLDAP::NG will not
65 receive the ``scope=`` parameter and will display an error on the portal
66 when trying to authenticate.
67
68 In order to fix this, we can add a fake OAuth2 authorize URL on the
69 LemonLDAP::NG server that will automatically add this ``scope=``
70 parametrer, before sending the request to the correct OIDC URL
71
72 Here is an example configuration for Nginx, add it in your Portal
73 virtualhost before any other rewrite rule:
74
75 ::
76
77 rewrite ^/oauth2/gitlab_(authorize.*)$ https://auth.example.com/oauth2/$1?scope=openid%20gitlab ;
78
79 And if you are using Apache
80
81 ::
82
83 RewriteRule "^/oauth2/gitlab_authorize(.*)$" "https://auth.example.com/oauth2/authorize?$1scope=openid gitlab" [QSA,NE]
84
85 Configuring LemonLDAP
86 ~~~~~~~~~~~~~~~~~~~~~
87
88 We now have to configure LemonLDAP::NG to recognize Mattermost as a
89 valid OAuth2 relying party and send it the information it needs to
90 recognize a user.
91
92 Add a :doc:`new OpenID Connect relying party<..//idpopenidconnect>`
93 with the following parameters:
94
95 * **Client ID**: the same you set in Mattermost configuration
96 * **Client Secret**: the same you set in Mattermost configuration
97 * Add a new scope in "Extra claims"
98 * **Key**: ``gitlab``
99 * **Value**: ``id username name email``
100 * Add the following exported attributes
101 * ``username``: set it to the session attribute containing the user login
102 * ``name``: session attribute containing the user's full name
103 * ``email``: session attribute containing the user's email
104 * ``id``: session attribute containing the user's numeric ID. You must set
105 this claim type to *Integer*
106
107 .. danger::
108
109 Mattermost absolutely needs to receive a numerical value in the ``id``
110 claim. If you are using a LDAP server, you could use the ``uidNumber`` LDAP
111 attribute. If you use something else, you will have to find a way to
112 assign a unique numeric ID to each Mattermost user.
113
114 The ``id`` attribute has to be different for each user, since this is
115 the field Mattermost will use internally to map Gitlab identities to
116 Mattermost accouts.
117
118 Troubleshooting
119 ~~~~~~~~~~~~~~~
120
121 If you see a HTTP code 500 when going back to mattermost, with a panic()
122 in ``(*GitLabUser).IsValid(...)`` , it probably means that you are not
123 exporting the correct attributes, but it can also mean that ``id`` is
124 exported as a JSON string.
125
126 .. note::
127 An issue in version 2.0.9 prevented the ``id`` field from being sent correctly.
128 Upgrade your LemonLDAP-NG installation to at least 2.0.10 and :ref:`set the claim
129 type <oidcexportedattr>` to *Integer*
130
131 .. |image0| image:: /applications/mattermost_logo.png
132 :class: align-center
133