Discourse GitHub Verification

Features

This plugin allows users to verify that they own a given GitHub account. This is separate from login with GitHub. It simply displays the a link to a user’s GitHub account on their user card and profile.

A new tab (GitHub) is added to user preferences. There is a button to connect your account with GitHub when the user has not connected their account yet. If the user has connected their account, they will see a link to their GitHub account and a button to disconnect their GitHub account from their Discourse profile.

1511f14d5db0f2c331bd201f403abbc16e71d923

image

If a user has a connected GitHub account, a link will be displayed on their user card and user profile

image

image

The plugin adds an admin API endpoint /github-verification/users.json, which returns an array of all users with a connected GitHub account. The response looks like this:

[
  {
    "id": 1,
    "username": "markvanlan",
    "github_username": "markvanlan"
  }
]

Configuration

Setup GitHub OAuth app

  • Follow GitHub’s instructions on creating an OAuth app. There are two important settings to configure in the OAuth app settings

    • Homepage URL - the homepage for your Discourse instance (e.g. https://meta.discourse.org)

    • Authorization callback URL - the home for your Discourse instance plus “/github-verification” (e.g. https://meta.discourse.org/github-verification

Configure Discourse settings

Settings can be found at /admin/site_settings/category/all_results?filter=discourse_github_verification

  • discourse github verification enabled - Enables the plugin by checking in the site settings panel (/admin/site_settings/category/all_results?filter=discourse_github_verification).

  • discourse github verification client id - Client ID of your GitHub OAuth app

  • discourse github verification client secret - Client secret of your GitHub OAuth app

Caveat

This plugin does not take into account existing login with GitHub configuration. Discourse supports this by default, but the discourse-github-verification plugin does not use a site’s existing github client id and github client secret settings. In the case these are filled in, we could probably use them instead of duplicating the settings. The plugin also does not know if a user has already logged into Discourse with Github. It would be nice to automatically detect this.


Thank you to Sailpoint for sponsoring this work and making it open-source :tada:

11 Likes

For anyone wondering how this plugin might be useful, we had it developed to work in conjunction with the gamification plugin.

We allow our users to gain points in our contributor program by contributing to our GitHub repositories. We had this plug-in made so we could ensure that the user actually owned the GitHub account they said they did. When we have a contribution event occur in GitHub, we query our list of users with connected GitHub accounts and see if the GitHub account exists in the forum. If so, we give them the designated points.

3 Likes