Configurable Github User's Email API to support Github Enterprise
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
- 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 asapi.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"
- DPhongsiri S @domehuhu
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.- 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 ofgithub.apiOrigin
orgithub.api.userEmails
, I'll addgithub.apiURL
:github.apiURL="https://your.github.server/api/v3" # defaults to https://api.github.com
- DPhongsiri S @domehuhu
The github.apiURL is looking good!. Thank you very much.
- Progresswith doing this idea
- 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.) - 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. - DPhongsiri S @domehuhu
@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?
- 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.
- KajMagnus @KajMagnus2019-06-09 12:54:48.709Z
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.