Search code examples
oauthconfigurationgitlabmattermost

How to add configuration data to gitlab on source install?


I need to follow certain instructions in gitlab. Those gitlab instructions are -

Manually (re)authorising GitLab Mattermost with GitLab
Authorise GitLab Mattermost

To do this, using browser navigate to the admin area of GitLab, Application section. Create a new application and for the callback URL use: http://mattermost.example.com/signup/gitlab/complete and http://mattermost.example.com/login/gitlab/complete (replace http with https if you use https).

Once the application is created you will receive an Application ID and Secret. One other information needed is the URL of GitLab instance.

Now, go to the GitLab server and edit the /etc/gitlab/gitlab.rb configuration file.

In gitlab.rb use the values you've received above:

mattermost['gitlab_enable'] = true
mattermost['gitlab_id'] = "12345656"
mattermost['gitlab_secret'] = "123456789"
mattermost['gitlab_scope'] = ""
mattermost['gitlab_auth_endpoint'] = "http://gitlab.example.com/oauth/authorize"
mattermost['gitlab_token_endpoint'] = "http://gitlab.example.com/oauth/token"
mattermost['gitlab_user_api_endpoint'] = "http://gitlab.example.com/api/v3/user"

Save the changes and then run sudo gitlab-ctl reconfigure.

If there are no errors your GitLab and GitLab Mattermost should be configured correctly.

I am currently running a source install of gitlab and I do NOT have the /etc/gitlab/gitlab.rb file available to me.

  1. How would I add the configuration for mattermost in a gitlab instance that is installed from source and not by the omnibus package?

  2. What files do I edit and what is the rake command to load those files?


Solution

  • I entered the gitlab config at mattermost/config/config.json and updated my settings with the appropriate endpoints as well as secret and ID. The correct information needed came from the gitlab gui. I created the tokens within gitlab proper and plugged the information into mattermost. I also had to edit my /etc/hosts due to the way our network is but this should not be necessary for most users.

    "GitLabSettings": {
        "Enable": true,
        "Secret": "abc123",
        "Id": "abc123",
        "Scope": "",
        "AuthEndpoint": "http://gitlab/oauth/authorize",
        "TokenEndpoint": "http://gitlab/oauth/token",
        "UserApiEndpoint": "http://gitlab/api/v3/user"
    },
    

    To get to the token, inside gitlab -

    1. Login as an admin
    2. Go to profile settings
    3. Go to applications
    4. Add the token for the mattermost application here and use this data to fill out the config file in mattermost.