Skip to content

Commit 6ce7b20

Browse files
committed
Add an auth provider guide for Mattermost
Signed-off-by: Ondřej Slabý <[email protected]>
1 parent 72894d1 commit 6ce7b20

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ There are some config settings you need to change in the files below.
202202
| `CMD_GITLAB_CLIENTID` | no example | GitLab API client id |
203203
| `CMD_GITLAB_CLIENTSECRET` | no example | GitLab API client secret |
204204
| `CMD_GITLAB_VERSION` | no example | GitLab API version (v3 or v4) |
205-
| `CMD_MATTERMOST_BASEURL` | no example | Mattermost authentication endpoint |
205+
| `CMD_MATTERMOST_BASEURL` | no example | Mattermost authentication endpoint for versions below 5.0. For Mattermost version 5.0 and above, see [guide](docs/guides/auth/mattermost-self-hosted.md). |
206206
| `CMD_MATTERMOST_CLIENTID` | no example | Mattermost API client id |
207207
| `CMD_MATTERMOST_CLIENTSECRET` | no example | Mattermost API client secret |
208208
| `CMD_DROPBOX_CLIENTID` | no example | Dropbox API client id |
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Authentication guide - Mattermost (self-hosted)
2+
===
3+
4+
*Note: The Mattermost setup portion of this document is just a quick guide. See the [official documentation](https://docs.mattermost.com/developer/oauth-2-0-applications.html) for more details.*
5+
6+
This guide uses the generic OAuth2 module for compatibility with Mattermost version 5.0 and above.
7+
8+
1. Sign-in with an administrator account to your Mattermost instance
9+
2. Make sure **OAuth 2.0 Service Provider** is enabled in the Main Menu (menu button next to your username in the top left corner) --> System Console --> Custom Integrations menu, which you can find at `https://your.mattermost.domain/admin_console/integrations/custom`
10+
11+
![mattermost-enable-oauth2](../images/auth/mattermost-enable-oauth2.png)
12+
13+
3. Navigate to the OAuth integration settings through Main Menu --> Integrations --> OAuth 2.0 Applications, at `https://your.mattermost.domain/yourteam/integrations/oauth2-apps`
14+
4. Click on the **Add OAuth 2.0 Application** button to add a new OAuth application
15+
16+
![mattermost-oauth-app-add](../images/auth/mattermost-oauth-app-add.png)
17+
18+
5. Fill out the form and click **Save**
19+
20+
![mattermost-oauth-app-form](../images/auth/mattermost-oauth-app-form.png)
21+
22+
*Note: The callback URL is \<your-codimd-url\>/auth/oauth2/callback*
23+
24+
6. After saving the application, you'll receive the Client ID and Client Secret
25+
26+
![mattermost-oauth-app-done](../images/auth/mattermost-oauth-app-done.png)
27+
28+
7. Add the Client ID and Client Secret to your config.json file or pass them as environment variables
29+
* config.json:
30+
````javascript
31+
{
32+
"production": {
33+
"oauth2": {
34+
"baseURL": "https://your.mattermost.domain",
35+
"userProfileURL": "https://your.mattermost.domain/api/v4/users/me",
36+
"userProfileUsernameAttr": "id",
37+
"userProfileDisplayNameAttr": "username",
38+
"userProfileEmailAttr": "email",
39+
"tokenURL": "https://your.mattermost.domain/oauth/access_token",
40+
"authorizationURL": "https://your.mattermost.domain/oauth/authorize",
41+
"clientID": "ii4p1u3jz7dXXXXXXXXXXXXXXX",
42+
"clientSecret": "mqzzx6fydbXXXXXXXXXXXXXXXX"
43+
}
44+
}
45+
}
46+
````
47+
* environment variables:
48+
````
49+
CMD_OAUTH2_BASEURL=https://your.mattermost.domain
50+
CMD_OAUTH2_USER_PROFILE_URL=https://your.mattermost.domain/api/v4/users/me
51+
CMD_OAUTH2_USER_PROFILE_USERNAME_ATTR=id
52+
CMD_OAUTH2_USER_PROFILE_DISPLAY_NAME_ATTR=username
53+
CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR=email
54+
CMD_OAUTH2_TOKEN_URL=https://your.mattermost.domain/oauth/access_token
55+
CMD_OAUTH2_AUTHORIZATION_URL=https://your.mattermost.domain/oauth/authorize
56+
CMD_OAUTH2_CLIENT_ID=ii4p1u3jz7dXXXXXXXXXXXXXXX
57+
CMD_OAUTH2_CLIENT_SECRET=mqzzx6fydbXXXXXXXXXXXXXXXX
58+
````
25.4 KB
Loading
20.9 KB
Loading
31 KB
Loading
60.7 KB
Loading

0 commit comments

Comments
 (0)