diff --git a/config/env/development.js b/config/env/development.js index 17470972f2..8596e6e0bb 100644 --- a/config/env/development.js +++ b/config/env/development.js @@ -24,5 +24,10 @@ module.exports = { clientID: process.env.LINKEDIN_ID || 'APP_ID', clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET', callbackURL: 'http://localhost:3000/auth/linkedin/callback' - } -}; \ No newline at end of file + }, + github: { + clientID: process.env.GITHUB_ID || 'APP_ID', + clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET', + callbackURL: 'http://localhost:3000/auth/github/callback' + } +}; diff --git a/config/env/production.js b/config/env/production.js index 26c97d775d..110bf7d4b1 100644 --- a/config/env/production.js +++ b/config/env/production.js @@ -39,5 +39,10 @@ module.exports = { clientID: process.env.LINKEDIN_ID || 'APP_ID', clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET', callbackURL: 'http://localhost:3000/auth/linkedin/callback' - } -}; \ No newline at end of file + }, + github: { + clientID: process.env.GITHUB_ID || 'APP_ID', + clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET', + callbackURL: 'http://localhost:3000/auth/github/callback' + } +}; diff --git a/config/env/test.js b/config/env/test.js index cc3f0aa4c4..baef3f7d64 100644 --- a/config/env/test.js +++ b/config/env/test.js @@ -25,5 +25,10 @@ module.exports = { clientID: process.env.LINKEDIN_ID || 'APP_ID', clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET', callbackURL: 'http://localhost:3000/auth/linkedin/callback' - } -}; \ No newline at end of file + }, + github: { + clientID: process.env.GITHUB_ID || 'APP_ID', + clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET', + callbackURL: 'http://localhost:3000/auth/github/callback' + } +}; diff --git a/config/strategies/github.js b/config/strategies/github.js new file mode 100644 index 0000000000..77193bd6f7 --- /dev/null +++ b/config/strategies/github.js @@ -0,0 +1,42 @@ +'use strict'; + +/** + * Module dependencies. + */ +var passport = require('passport'), + url = require('url'), + GithubStrategy = require('passport-github').Strategy, + config = require('../config'), + users = require('../../app/controllers/users'); + +module.exports = function() { + // Use github strategy + passport.use(new GithubStrategy({ + clientID: config.github.clientID, + clientSecret: config.github.clientSecret, + callbackURL: config.github.callbackURL, + passReqToCallback: true + }, + function(req, accessToken, refreshToken, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.accessToken = accessToken; + providerData.refreshToken = refreshToken; + + // Create the user OAuth profile + var providerUserProfile = { + firstName: profile.name.givenName, + lastName: profile.name.familyName, + displayName: profile.displayName, + email: profile.emails[0].value, + username: profile.username, + provider: 'github', + providerIdentifierField: 'id', + providerData: providerData + }; + + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + } + )); +}; \ No newline at end of file diff --git a/package.json b/package.json index cd9eacc6af..f96511f730 100755 --- a/package.json +++ b/package.json @@ -1,69 +1,70 @@ { - "name": "meanjs", - "description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.", - "version": "0.3.1", - "private": false, - "author": "https://github.com/meanjs/mean/graphs/contributors", - "repository": { - "type": "git", - "url": "https://github.com/meanjs/mean.git" - }, - "engines": { - "node": "0.10.x", - "npm": "1.4.x" - }, - "scripts": { - "start": "grunt", - "test": "grunt test", - "postinstall": "bower install --config.interactive=false" - }, - "dependencies": { - "express": "~4.2.0", - "express-session": "~1.1.0", - "body-parser": "~1.2.0", - "cookie-parser": "~1.1.0", - "compression": "~1.0.1", - "method-override": "~1.0.0", - "morgan": "~1.1.0", - "connect-mongo": "~0.4.0", - "connect-flash": "~0.1.1", - "helmet": "~0.2.1", - "consolidate": "~0.10.0", - "swig": "~1.3.2", - "mongoose": "~3.8.8", - "passport": "~0.2.0", - "passport-local": "~1.0.0", - "passport-facebook": "~1.0.2", - "passport-twitter": "~1.0.2", - "passport-linkedin": "~0.1.3", - "passport-google-oauth": "~0.1.5", - "lodash": "~2.4.1", - "forever": "~0.11.0", - "bower": "~1.3.1", - "grunt-cli": "~0.1.13", - "glob": "~3.2.9" - }, - "devDependencies": { - "supertest": "~0.12.1", - "should": "~3.3.1", - "grunt-env": "~0.4.1", - "grunt-node-inspector": "~0.1.3", - "grunt-contrib-watch": "~0.6.1", - "grunt-contrib-jshint": "~0.10.0", - "grunt-contrib-csslint": "^0.2.0", - "grunt-ngmin": "0.0.3", - "grunt-contrib-uglify": "~0.4.0", - "grunt-contrib-cssmin": "~0.9.0", - "grunt-nodemon": "~0.2.1", - "grunt-concurrent": "~0.5.0", - "grunt-mocha-test": "~0.10.0", - "grunt-karma": "~0.8.2", - "load-grunt-tasks": "~0.4.0", - "karma": "~0.12.0", - "karma-jasmine": "~0.2.1", - "karma-coverage": "~0.2.0", - "karma-chrome-launcher": "~0.1.2", - "karma-firefox-launcher": "~0.1.3", - "karma-phantomjs-launcher": "~0.1.2" - } -} \ No newline at end of file + "name": "meanjs", + "description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.", + "version": "0.3.1", + "private": false, + "author": "https://github.com/meanjs/mean/graphs/contributors", + "repository": { + "type": "git", + "url": "https://github.com/meanjs/mean.git" + }, + "engines": { + "node": "0.10.x", + "npm": "1.4.x" + }, + "scripts": { + "start": "grunt", + "test": "grunt test", + "postinstall": "bower install --config.interactive=false" + }, + "dependencies": { + "body-parser": "~1.2.0", + "bower": "~1.3.1", + "compression": "~1.0.1", + "connect-flash": "~0.1.1", + "connect-mongo": "~0.4.0", + "consolidate": "~0.10.0", + "cookie-parser": "~1.1.0", + "express": "~4.2.0", + "express-session": "~1.1.0", + "forever": "~0.11.0", + "glob": "~3.2.9", + "grunt-cli": "~0.1.13", + "helmet": "~0.2.1", + "lodash": "~2.4.1", + "method-override": "~1.0.0", + "mongoose": "~3.8.8", + "morgan": "~1.1.0", + "passport": "~0.2.0", + "passport-facebook": "~1.0.2", + "passport-github": "^0.1.5", + "passport-google-oauth": "~0.1.5", + "passport-linkedin": "~0.1.3", + "passport-local": "~1.0.0", + "passport-twitter": "~1.0.2", + "swig": "~1.3.2" + }, + "devDependencies": { + "supertest": "~0.12.1", + "should": "~3.3.1", + "grunt-env": "~0.4.1", + "grunt-node-inspector": "~0.1.3", + "grunt-contrib-watch": "~0.6.1", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-csslint": "^0.2.0", + "grunt-ngmin": "0.0.3", + "grunt-contrib-uglify": "~0.4.0", + "grunt-contrib-cssmin": "~0.9.0", + "grunt-nodemon": "~0.2.1", + "grunt-concurrent": "~0.5.0", + "grunt-mocha-test": "~0.10.0", + "grunt-karma": "~0.8.2", + "load-grunt-tasks": "~0.4.0", + "karma": "~0.12.0", + "karma-jasmine": "~0.2.1", + "karma-coverage": "~0.2.0", + "karma-chrome-launcher": "~0.1.2", + "karma-firefox-launcher": "~0.1.3", + "karma-phantomjs-launcher": "~0.1.2" + } +} diff --git a/public/modules/users/img/buttons/github.png b/public/modules/users/img/buttons/github.png new file mode 100644 index 0000000000..37b77cbefe Binary files /dev/null and b/public/modules/users/img/buttons/github.png differ diff --git a/public/modules/users/views/signin.client.view.html b/public/modules/users/views/signin.client.view.html index 0ddb6e5cf0..bf27c637f4 100644 --- a/public/modules/users/views/signin.client.view.html +++ b/public/modules/users/views/signin.client.view.html @@ -13,6 +13,10 @@