0

We use Mattermost using the 'Production Docker' setup as described in Mattermost documentation. For authentication, we federate using GitHub:Enterprise.

To setup our Mattermost team, I imported the whole Slack history. This lead to the problem that everyone who did not yet log into Mattermost via GitHub:Enterprise was not able to login. Mattermost helpfully returned the error message

"An existing user is already attached to your gitlab account"

How can I fix this issue without having to setup a new Mattermost instance and force everyone to login once before importing the Slack data?

1 Answer 1

2

Prerequisites

In order for this to work, you need

  • GitHub:Enterprise Administrator permissions
  • On the Mattermost machine, either root permissions or an account that is allowed to control docker, and, if psql is not installed, a way to install the psql command-line tool.

Steps

  1. ssh into the Mattermost vm/machine (where the mattermost docker containers are running).

  2. Change to an account with docker permissions (root; or the account you setup during Mattermost installation; or ... )

  3. Use docker ps and note the hash of the container mattermostdocker_db. We will assume it starts with 5c23.

  4. Run docker inspect 5c23 | grep IPAddress. Note the IP address of the container. We will assume it is 172.17.0.2.

  5. Ensure that the psql commandline tool is installed on the machine where mattermost/docker is running.

    • On debian: apt-get install postgresql-client
  6. Connect to the mattermost db of postgresql running inside the docker container:

    • psql -h 172.17.0.2 -p 5432 -d mattermost -U postgres -W
    • The (default?) password seems to be postgres.
  7. Verify that a user account with the correct email exists. Assume the email of the account that has the problem is '[email protected]`

  8. Connect to GitHub:Enterprise and open the admin console. We will assume the local github enterprise instance is at https://github.example.com.

  9. Click on all users and find the user that cannot login. We assume the github username is john, which would correspond to https://github.example.com/john

  10. Visit the stafftools user security page for that user.

  11. Click on the 'Search logs' link under the 'Audit logs' header. This will open a page with a query field. On this page, you will find the internal github user number for that user. Note this number. We will assume the number is 37.

  12. Back in the psql console, update the user entry with the correct number:

    • update users set authservice = 'gitlab', authdata = '37' where email = '[email protected]' ;
  13. Exit the psql console with \q:

    • mattermost-# \q
  14. Done. The user can now log into Mattermost with GitHub:Enterprise user authentication.

Notes

  • Don't forget to complete each statement in psql with a ;
  • It's gitlab, not github, even if you use GitHub:Enterprise
  • Tested with Mattermost 3.0, GitHub:Enterprise 2.6.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.