GitLab OmniAuth plugin

Source code: / discourse-omniauth-gitlab · GitLab

:warning: Attention

This is supported on GitLab 7.7+.


First, register a new system application in GitLab by visiting /admin/applications/new.
The redirect URI is of the form:

Add the plugin’s repository url to your container’s app.yml file:

    - exec:
        cd: $home/plugins
          - mkdir -p plugins
          - git clone
          - git clone

Rebuild the container by providing the APP_ID, SECRET and GitLab url values:

cd /var/discourse
git pull origin master
GITLAB_APP_ID=gitlabtestid GITLAB_SECRET=gitlabtestsecret GITLAB_URL= ./launcher rebuild app

Otherwise you can add these variables in app.yml under the env section.


I have a silly question: you mention /admin/applications/new, but my Gitlab instance returns 404 for this URL. Any idea what could cause this? (Omnibus 7.5.3) I couldn’t find anything relative to that problem here or in Gitlab’s forum (and I don’t have console access to troubleshoot it).

Not silly at all, my fault I didn’t mention it. This is supported on 7.7+.


Hey I realize this is a very old topic now, but this plugin is really interesting. This is exactly what I’m looking for but I’m just curious about how the existing discourse users will be connected to Gitlab account.
For example, Gitlab’s OAuth allows a logged in user to connect their Google, Facebook, or Github accounts in their settings, is there something similar in this plugin for discourse to gitlab as well?

It will be by the email provided by Gitlab. If the email matches when you first sign in with Gitlab, the account will be connected.

1 Like

orly? Thanks very much! :smiley: can’t wait to try it out tonight

it’s not connecting the account, when I try to log in with gitlab it just redirects me to signup with my info filled out and tells me my username and email has already been taken :frowning:

Got it fixed, made a merge request to the repo on gitlab, not sure if anyone still maintains that o_o


Yes, I maintain it and merged your MR thanks!



I have manually created accounts that I want to associate with a Gitlab account. Is there a way to do it?

The normal workflow is that an existing gitlab account visits the Discourse: then its discourse account is created. What I want to do is, as an admin or as the logged-in user, explicitly set the link between the gitlab and discourse accounts.

I guess setting the same e-mail between GitLab and Discourse will work.

Yes - if you log in via GitLab and there already is a Discourse account with that e-mail address, then that’s the account you are logged in to.

@RalfJung my experiment doesn’t match your description: I tried logging in with my gitlab account which uses the same username and email as the existing Discourse account.

But when I “login with gitlab”, I receive a proposal to create a new account named username1 instead of the existing username.

What you describe is what I would like to achieve. Moreover, I’d like to have a user UI to associate an account. This, it seems to me, is missing from the current Discourse.

Are you pulling the latest master? There was a change back in October which fixed the issue you describe added ability to connect existing accounts (2b2016eb) · Commits · / discourse-omniauth-gitlab · GitLab

1 Like

Hmmm, my plugin page was showing a fixed version (v0.0.2) without any mean to change it nor update the plugin. I ran again the rebuild command:

No change:

[Edit:] Seems like / omniauth-gitlab · GitLab is DEPRECATED. The page tells to look at instead. Should I use that, or your fork?

The Discourse plugin uses linchus/omniauth-gitlab, not my fork, see plugin.rb · master · / discourse-omniauth-gitlab · GitLab

I bumped the version to 0.0.3 to include a fix in omniauth-gitlab ( Try to rebuild the container.

Although it’s strange, because we use the same version as you in and works fine, I just tested it.


I rebuilt the instance and now it shows v0.0.3. But I still can’t login from Gitlab: it proposes me to use a different username. This is weird.

I tried running the code from the console:

::PluginStore.get("gl", "gl_uid_hellekin")
=> nil
existing_user = User.where(email: email).first
=> User ...
::PluginStore.set("gl", "gl_uid_hellekin", {user_id:})

Then tried to login from gitlab again. No luck.

BTW, I submitted an MR to fix a minor issue.

Could it be that you have multiple e-mails in GitLab? I think it only captures the one you set as primary.

I have emails using +, e.g., Would that interfere?

No, but i tried with a new GitLab account and I can reproduce your issue. Investigating.

1 Like

Any progress on this @axil?