|
| 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 | + |
| 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 | + |
| 17 | + |
| 18 | +5. Fill out the form and click **Save** |
| 19 | + |
| 20 | + |
| 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 | + |
| 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 | + ```` |
0 commit comments