-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix: updates to accounts-ghe (fixes #201 , #200 ) - Make accounts-ghe a local package - don't send auth token to github as part of params - don't require GITHUB_API and GITHUB_URL for ghe logins - sanitize GHE url input on the initial razeedash configuration screen * add packages/accounts-ghe * Update packages * modernize accounts-ghe and make it a local package
- Loading branch information
Showing
18 changed files
with
306 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
Accounts.oauth.registerService('ghe'); | ||
|
||
if (Meteor.isClient) { | ||
Meteor.loginWithGhe = function(options, callback) { | ||
// support a callback without options | ||
if (!callback && typeof options === 'function') { | ||
callback = options; | ||
options = null; | ||
} | ||
|
||
const credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback); | ||
Ghe.requestCredential(options, credentialRequestCompleteCallback); | ||
}; | ||
} else { | ||
Accounts.addAutopublishFields({ | ||
forLoggedInUser: ['services.ghe'], | ||
forOtherUsers: ['services.ghe.username'] | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
Ghe = {}; | ||
|
||
// Request Github credentials for the user | ||
// @param options {optional} | ||
// @param credentialRequestCompleteCallback {Function} Callback function to call on | ||
// completion. Takes one argument, credentialToken on success, or Error on | ||
// error. | ||
Ghe.requestCredential = function(options, credentialRequestCompleteCallback) { | ||
// support both (options, callback) and (callback). | ||
if (!credentialRequestCompleteCallback && typeof options === 'function') { | ||
credentialRequestCompleteCallback = options; | ||
options = {}; | ||
} | ||
|
||
const config = ServiceConfiguration.configurations.findOne({ service: 'ghe' }); | ||
if (!config) { | ||
credentialRequestCompleteCallback && credentialRequestCompleteCallback(new ServiceConfiguration.ConfigError()); | ||
return; | ||
} | ||
const credentialToken = Random.secret(); | ||
|
||
const scope = (options && options.requestPermissions) || ['user:email']; | ||
const flatScope = _.map(scope, encodeURIComponent).join('+'); | ||
|
||
const loginStyle = OAuth._loginStyle('ghe', config, options); | ||
|
||
let url = config.gheURL; | ||
const httpCheck = /^((http|https):\/\/)/; | ||
if(!httpCheck.test(config.gheURL)) { | ||
url = `https://${config.gheURL}`; | ||
} | ||
|
||
const trailingSlash = /\/*$/gi; | ||
const gheUrl = url.replace(trailingSlash, ''); | ||
|
||
const loginUrl = | ||
gheUrl + '/login/oauth/authorize' + | ||
'?client_id=' + config.clientId + | ||
'&scope=' + flatScope + | ||
'&redirect_uri=' + OAuth._redirectUri('ghe', config) + | ||
'&state=' + OAuth._stateParam(loginStyle, credentialToken, options && options.redirectUrl); | ||
|
||
OAuth.launchLogin({ | ||
loginService: 'ghe', | ||
loginStyle, | ||
loginUrl, | ||
credentialRequestCompleteCallback, | ||
credentialToken, | ||
popupOptions: { | ||
width: 900, | ||
height: 450 | ||
} | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template name="configureLoginServiceDialogForGhe"> | ||
<p> | ||
First, you'll need to get a GitHub Client ID. Follow these steps: | ||
</p> | ||
<ol> | ||
<li> | ||
Visit your enterprise GitHub site and go to<br/> Settings -> Developer settings -> OAuth Apps -> New OAuth App | ||
</li> | ||
<li> | ||
Set Homepage URL to: <span class="url">{{siteUrl}}</span> | ||
</li> | ||
<li> | ||
Set Authorization callback URL to: <span class="url">{{siteUrl}}_oauth/ghe</span> | ||
</li> | ||
</ol> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
Template.configureLoginServiceDialogForGhe.helpers({ | ||
siteUrl: function() { | ||
return Meteor.absoluteUrl(); | ||
} | ||
}); | ||
|
||
Template.configureLoginServiceDialogForGhe.fields = () => [ | ||
{ property: 'gheURL', label: 'GitHub Enterprise URL' }, | ||
{ property: 'clientId', label: 'Client ID' }, | ||
{ property: 'secret', label: 'Client Secret' } | ||
]; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.