No internet connection
  1. Home
  2. Ideas

Configurable Github User's Email API to support Github Enterprise

By Phongsiri S @domehuhu2019-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

  • 17 replies

There are 17 replies. Estimated reading time: 19 minutes

  1. KajMagnus @KajMagnus2019-03-04 10:13:44.037Z

    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 @domehuhu2019-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. KajMagnus @KajMagnus2019-03-04 14:34:55.800Z

        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 @domehuhu2019-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. KajMagnus @KajMagnus2019-03-07 09:46:58.398Z

      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 @domehuhu2019-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.