No internet connection
  1. Home
  2. Ideas

Configurable Github User's Email API to support Github Enterprise

By Phongsiri S @domehuhu
    2019-03-04 08:43:06.763Z

    I've tried to configure the authentication for Github Enterprise using Github OpenAuth. However, it failed where it calls to the /user/emails api from the Github server. Can you please make it be configurable like other endpoints? (e.g. github.authorizationURL and github.accessTokenURL)

      private def loadPublicAndVerifiedEmailAddrs(oauth2AuthInfo: OAuth2Info)
            : Future[(Option[ExternalEmailAddr], Option[ExternalEmailAddr])] = {
        val githubRequest: ws.WSRequest =
          wsClient.url(s"https://api.github.com/user/emails").withHeaders(
    

    Expected:
    The url to emails API can be configurable in the play-framework.conf

    Actual:
    The url is currently hard-coded to https://api.github.com/user/emails

    • 16 replies

    There are 16 replies. Estimated reading time: 20 minutes

    1. Ok I'll fix. As per the docs, https://help.github.com/en/enterprise/2.15/admin/installation/about-the-github-enterprise-server-api,
      GitHub Enterprise has the same API as api.github.com?

      Then it should be enough to make the API origin (i.e. https://api.github.com) configurable? (but not the URL path, /user/emails)

      I have in mind to add this config value:

      github.apiOrigin="https://api.github.com"  # default
      

      What do you think?

      Thanks for including the source code snippet and details.

      Edit: Now I found this: https://stackoverflow.com/a/50612869/694469 and seems GitHub Enterprise also has other endpoints, e.g. https://hostname/api/v3/... — so now I'm thinking I can instead add this config value:

      github.api.userEmails='https://api.github.com/user/emails"
      
      1. DPhongsiri S @domehuhu
          2019-03-04 13:41:22.966Z

          Thank you very much!
          Yes my Github also contains /api/ as well. The response of the API also follow the Github V3 spec, So I think should be working.

          1. Now I had a look here: https://developer.github.com/enterprise/2.16/v3/#current-version

            The API is accessed from http(s)://[hostname]/api/v3

            And here: https://developer.github.com/enterprise/2.16/v3/users/emails/#list-email-addresses-for-a-user

            GET /user/emails

            So that's the same, as github.com's API, just a different origin and the URL path is prefixed with /api/v3/. So instead of github.apiOrigin or github.api.userEmails, I'll add github.apiURL:

            github.apiURL="https://your.github.server/api/v3"   # defaults to https://api.github.com
            
            1. DPhongsiri S @domehuhu
                2019-03-05 04:14:01.492Z

                The github.apiURL is looking good!. Thank you very much.

          2. Progress
            with doing this idea
          3. @KajMagnus marked this topic as Planned 2019-03-04 10:13:46.776Z.
          4. @KajMagnus marked this topic as Started 2019-03-04 14:57:54.236Z.
          5. I just released a new version v0.6.22-85e88ba, with this config value included. @domehuhu your server should auto upgrade this night, before Friday. Please let me know if / how this works. (Not impossible that you'll run into some additional issue, I suppose.)

            1. KajMagnus @KajMagnus2019-03-15 08:22:57.678Zreplies todomehuhu:

              Hi again Phongsiri, now I've released a new version, and you can do this: (and restart the app contaner afterwards)

              talkyard.spamChecks.enabled=false
              

              In /opt/talkyard/conf/play-framework.conf. This'll prevent any requests to Stopforumspam and Akismet.

              1. D
                Phongsiri S @domehuhu
                  2019-03-15 11:07:11.570Zreplies toKajMagnus:

                  @KajMagnus
                  Thank you very much! It's working perfectly now.

                  FYI, I have to connect all registered users to the Github login manually by inserting records in the identities table myself. Is there any way to connect Github login from the user profile page?

                  1. KajMagnus @KajMagnus2019-03-17 05:06:06.420Zreplies todomehuhu:

                    Ok I'm glad it works.

                    Currently you cannot connect Github login from the user profile page. However, seems to me I need to add that. (Plus connecting Gmail and Facebook accounts too — to make it more smooth to sign up for Talkyard's hosting.) So I think this'll happen in one or two months.

                    1. Phongsiri @domehuhu I'm marking this as done, since works fine for you now, if I understood correctly.

                      About this:

                      Is there any way to connect Github login from the user profile page?

                      That's about a forum admin updating forum members' profiles to connect them to their GitHub Enterprise accounts? Hmm I first interpreted this, as each member logging in him/herself, and adding his/her GitHub Enterprise account.

                      The latter is (I think) simpler, because then it's simpler show that the member does control the GitHub account (namely, the member logs in to his/her GitHub account, as part of the connect-GitHub-login steps).

                      ***

                      If you have any other thoughts or questions or ideas, it'd be interesting to hear.

                      1. @KajMagnus marked this topic as Done 2019-06-09 12:55:20.649Z.