Skip to content

Commit c3c16d0

Browse files
author
epriestley
committed
Github OAuth
Summary: Test Plan: Reviewers: CC:
1 parent fcb4cf5 commit c3c16d0

22 files changed

+845
-333
lines changed

conf/default.conf.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
'recaptcha.private-key',
9999
'phabricator.csrf-key',
100100
'facebook.application-secret',
101+
'github.secret',
101102
),
102103

103104
// -- MySQL --------------------------------------------------------------- //
@@ -187,6 +188,27 @@
187188
'facebook.application-secret' => null,
188189

189190

191+
// -- Github ---------------------------------------------------------------- //
192+
193+
// Can users use Github credentials to login to Phabricator?
194+
'github.auth-enabled' => false,
195+
196+
// The Github "Client ID" to use for Github API access.
197+
'github.application-id' => null,
198+
199+
// The Github "Secret" to use for Github API access.
200+
'github.application-secret' => null,
201+
202+
203+
// Github Authorize URI. You don't need to change this unless Github changes
204+
// its API in the future (this is unlikely).
205+
'github.authorize-uri' => 'https://github.com/login/oauth/authorize',
206+
207+
// Github Access Token URI. You don't need to change this unless Github
208+
// changes its API in the future (this is unlikely).
209+
'github.access-token-uri' => 'https://github.com/login/oauth/access_token',
210+
211+
190212
// -- Recaptcha ------------------------------------------------------------- //
191213

192214
// Is Recaptcha enabled? If disabled, captchas will not appear.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
create table phabricator_user.user_oauthinfo (
2+
id int unsigned not null auto_increment primary key,
3+
userID int unsigned not null,
4+
oauthProvider varchar(255) not null,
5+
oauthUID varchar(255) not null,
6+
unique key (userID, oauthProvider),
7+
unique key (oauthProvider, oauthUID),
8+
dateCreated int unsigned not null,
9+
dateModified int unsigned not null
10+
);
11+
12+
insert into phabricator_user.user_oauthinfo
13+
(userID, oauthProvider, oauthUID, dateCreated, dateModified)
14+
SELECT id, 'facebook', facebookUID, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
15+
FROM phabricator_user.user
16+
WHERE facebookUID is not null;
17+
18+
alter table phabricator_user.user drop facebookUID;

src/__phutil_library_map__.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@
187187
'PhabricatorEmailLoginController' => 'applications/auth/controller/email',
188188
'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken',
189189
'PhabricatorEnv' => 'infrastructure/env',
190-
'PhabricatorFacebookAuthController' => 'applications/auth/controller/facebookauth',
191-
'PhabricatorFacebookAuthDiagnosticsController' => 'applications/auth/controller/facebookauth/diagnostics',
192190
'PhabricatorFile' => 'applications/files/storage/file',
193191
'PhabricatorFileController' => 'applications/files/controller/base',
194192
'PhabricatorFileDAO' => 'applications/files/storage/base',
@@ -214,6 +212,12 @@
214212
'PhabricatorMetaMTAMailingListsController' => 'applications/metamta/controller/mailinglists',
215213
'PhabricatorMetaMTASendController' => 'applications/metamta/controller/send',
216214
'PhabricatorMetaMTAViewController' => 'applications/metamta/controller/view',
215+
'PhabricatorOAuthDiagnosticsController' => 'applications/auth/controller/oauthdiagnostics',
216+
'PhabricatorOAuthFailureView' => 'applications/auth/view/oauthfailure',
217+
'PhabricatorOAuthLoginController' => 'applications/auth/controller/oauth',
218+
'PhabricatorOAuthProvider' => 'applications/auth/oauth/provider/base',
219+
'PhabricatorOAuthProviderFacebook' => 'applications/auth/oauth/provider/facebook',
220+
'PhabricatorOAuthProviderGithub' => 'applications/auth/oauth/provider/github',
217221
'PhabricatorObjectHandle' => 'applications/phid/handle',
218222
'PhabricatorObjectHandleData' => 'applications/phid/handle/data',
219223
'PhabricatorObjectSelectorDialog' => 'view/control/objectselector',
@@ -270,6 +274,7 @@
270274
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/base',
271275
'PhabricatorUser' => 'applications/people/storage/user',
272276
'PhabricatorUserDAO' => 'applications/people/storage/base',
277+
'PhabricatorUserOAuthInfo' => 'applications/people/storage/useroauthinfo',
273278
'PhabricatorUserProfile' => 'applications/people/storage/profile',
274279
'PhabricatorUserSettingsController' => 'applications/people/controller/settings',
275280
'PhabricatorXHProfController' => 'applications/xhprof/controller/base',
@@ -436,8 +441,6 @@
436441
'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
437442
'PhabricatorEmailLoginController' => 'PhabricatorAuthController',
438443
'PhabricatorEmailTokenController' => 'PhabricatorAuthController',
439-
'PhabricatorFacebookAuthController' => 'PhabricatorAuthController',
440-
'PhabricatorFacebookAuthDiagnosticsController' => 'PhabricatorAuthController',
441444
'PhabricatorFile' => 'PhabricatorFileDAO',
442445
'PhabricatorFileController' => 'PhabricatorController',
443446
'PhabricatorFileDAO' => 'PhabricatorLiskDAO',
@@ -459,6 +462,11 @@
459462
'PhabricatorMetaMTAMailingListsController' => 'PhabricatorMetaMTAController',
460463
'PhabricatorMetaMTASendController' => 'PhabricatorMetaMTAController',
461464
'PhabricatorMetaMTAViewController' => 'PhabricatorMetaMTAController',
465+
'PhabricatorOAuthDiagnosticsController' => 'PhabricatorAuthController',
466+
'PhabricatorOAuthFailureView' => 'AphrontView',
467+
'PhabricatorOAuthLoginController' => 'PhabricatorAuthController',
468+
'PhabricatorOAuthProviderFacebook' => 'PhabricatorOAuthProvider',
469+
'PhabricatorOAuthProviderGithub' => 'PhabricatorOAuthProvider',
462470
'PhabricatorPHID' => 'PhabricatorPHIDDAO',
463471
'PhabricatorPHIDAllocateController' => 'PhabricatorPHIDController',
464472
'PhabricatorPHIDController' => 'PhabricatorController',
@@ -507,6 +515,7 @@
507515
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
508516
'PhabricatorUser' => 'PhabricatorUserDAO',
509517
'PhabricatorUserDAO' => 'PhabricatorLiskDAO',
518+
'PhabricatorUserOAuthInfo' => 'PhabricatorUserDAO',
510519
'PhabricatorUserProfile' => 'PhabricatorUserDAO',
511520
'PhabricatorUserSettingsController' => 'PhabricatorPeopleController',
512521
'PhabricatorXHProfController' => 'PhabricatorController',

src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ public function getURIMap() {
130130
'diagnose/$' => 'PhabricatorFacebookAuthDiagnosticsController',
131131
),
132132

133+
'/oauth/' => array(
134+
'(?P<provider>github|facebook)/' => array(
135+
'login/$' => 'PhabricatorOAuthLoginController',
136+
'diagnose/$' => 'PhabricatorOAuthDiagnosticsController',
137+
),
138+
),
139+
133140
'/xhprof/' => array(
134141
'profile/(?P<phid>[^/]+)/$' => 'PhabricatorXHProfProfileController',
135142
),

0 commit comments

Comments
 (0)