modules/orionode/lib/user.js
function configureGithubOAuth(app, options) {
	if (options.configParams.get("orion.oauth.github.client")) {
		const GithubStrategy = require('passport-github2').Strategy;
		passport.use(new GithubStrategy({
			clientID: options.configParams.get("orion.oauth.github.client"),
			clientSecret: options.configParams.get("orion.oauth.github.secret"),
			passReqToCallback: true,
			callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback",
			scope: "user:email"
		}, /* @callback */ function(req, accessToken, refreshToken, profile, done) {
			const email = profile.emails[0].value;
			oauth(profile.provider + "/" + profile.id, profile.username, email, req, done);
		}));
		app.get('/login/oauth/github', options.basicMiddleware, passport.authenticate('github'));
		app.get('/mixlogin/manageoauth/oauth/github', options.basicMiddleware, passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback/link"}));
		app.get('/auth/github/callback*', options.basicMiddleware, function(req, res) {
			return passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback" + (req.params["0"] || "")}, /* @callback */ function(err, user, info){
				createNewUser(req,res,err,user, options);
			})(req,res);
		});
	}
}
function configureGithubOAuth(app, options) {
	if (options.configParams.get("orion.oauth.github.client")) {
		const GithubStrategy = require('passport-github2').Strategy;
		passport.use(new GithubStrategy({
			clientID: options.configParams.get("orion.oauth.github.client"),
			clientSecret: options.configParams.get("orion.oauth.github.secret"),
			passReqToCallback: true,
			callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback",
			scope: "user:email"
		}, /* @callback */ function(req, accessToken, refreshToken, profile, done) {
			const email = profile.emails[0].value;
			oauth(profile.provider + "/" + profile.id, profile.username, email, req, done);
		}));
		app.get('/login/oauth/github', options.basicMiddleware, passport.authenticate('github'));
		app.get('/mixlogin/manageoauth/oauth/github', options.basicMiddleware, passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback/link"}));
		app.get('/auth/github/callback*', options.basicMiddleware, function(req, res) {
			return passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback" + (req.params["0"] || "")}, /* @callback */ function(err, user, info){
				createNewUser(req,res,err,user, options);
			})(req,res);
		});
	}
}
function configureGithubOAuth ( app , options ) { if ( options . configParams . get ( "orion.oauth.github.client" ) ) { const GithubStrategy = require ( 'passport-github2' ) . Strategy ; passport . use ( new GithubStrategy ( { clientID : options . configParams . get ( "orion.oauth.github.client" ) , clientSecret : options . configParams . get ( "orion.oauth.github.secret" ) , passReqToCallback : true , callbackURL : ( options . configParams . get ( "orion.auth.host" ) || "" ) + "/auth/github/callback" , scope : "user:email" } , /* @callback */ function ( req , accessToken , refreshToken , profile , done ) { const email = profile . emails [ 0 ] . value ; oauth ( profile . provider + "/" + profile . id , profile . username , email , req , done ) ; } ) ) ; app . get ( '/login/oauth/github' , options . basicMiddleware , passport . authenticate ( 'github' ) ) ; app . get ( '/mixlogin/manageoauth/oauth/github' , options . basicMiddleware , passport . authenticate ( 'github' , { callbackURL : ( options . configParams . get ( "orion.auth.host" ) || "" ) + "/auth/github/callback/link" } ) ) ; app . get ( '/auth/github/callback*' , options . basicMiddleware , function ( req , res ) { return passport . authenticate ( 'github' , { callbackURL : ( options . configParams . get ( "orion.auth.host" ) || "" ) + "/auth/github/callback" + ( req . params [ "0" ] || "" ) } , /* @callback */ function ( err , user , info ) { createNewUser ( req , res , err , user , options ) ; } ) ( req , res ) ; } ) ; } }
Optionally configures GitHub OAuth. Checks for the server property 'orion.oauth.github.client', and if found optionally
sets up the support.
@param {express.Router} app The backing app
@param {{?}} options The map of server options
@see https://wiki.eclipse.org/Orion/Server_admin_guide#Setting_up_GitHub_OAuth_authentication
Optionally configures GitHub OAuth . Checks for the server property orion . oauth . github . client and if found optionally sets up the support .