From 8694b7e9761e4fc7a86871d1c7f0eff614f7db14 Mon Sep 17 00:00:00 2001 From: Andrew Throener Date: Thu, 2 Jul 2015 07:44:58 -0500 Subject: [PATCH] PayPal Authentication --- config/env/development.js | 6 +++ config/env/production.js | 6 +++ config/env/test.js | 6 +++ modules/users/client/img/buttons/paypal.png | Bin 0 -> 5229 bytes .../authentication.client.view.html | 3 ++ .../manage-social-accounts.client.view.html | 6 +++ .../users/server/config/strategies/paypal.js | 42 ++++++++++++++++++ .../users/server/routes/auth.server.routes.js | 4 ++ package.json | 1 + 9 files changed, 74 insertions(+) create mode 100644 modules/users/client/img/buttons/paypal.png create mode 100644 modules/users/server/config/strategies/paypal.js diff --git a/config/env/development.js b/config/env/development.js index 310189454b..c61be6e592 100644 --- a/config/env/development.js +++ b/config/env/development.js @@ -29,6 +29,12 @@ module.exports = { clientID: process.env.GITHUB_ID || 'APP_ID', clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET', callbackURL: '/api/auth/github/callback' + }, + paypal: { + clientID: process.env.PAYPAL_ID || 'CLIENT_ID', + clientSecret: process.env.PAYPAL_SECRET || 'CLIENT_SECRET', + callbackURL: '/api/auth/paypal/callback', + sandbox: true }, mailer: { from: process.env.MAILER_FROM || 'MAILER_FROM', diff --git a/config/env/production.js b/config/env/production.js index 01cc6beb87..003be5fe35 100644 --- a/config/env/production.js +++ b/config/env/production.js @@ -27,6 +27,12 @@ module.exports = { clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET', callbackURL: '/api/auth/github/callback' }, + paypal: { + clientID: process.env.PAYPAL_ID || 'CLIENT_ID', + clientSecret: process.env.PAYPAL_SECRET || 'CLIENT_SECRET', + callbackURL: '/api/auth/paypal/callback', + sandbox: false + }, mailer: { from: process.env.MAILER_FROM || 'MAILER_FROM', options: { diff --git a/config/env/test.js b/config/env/test.js index dd0c6184cb..9a6d9514e2 100644 --- a/config/env/test.js +++ b/config/env/test.js @@ -31,6 +31,12 @@ module.exports = { clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET', callbackURL: '/api/auth/github/callback' }, + paypal: { + clientID: process.env.PAYPAL_ID || 'CLIENT_ID', + clientSecret: process.env.PAYPAL_SECRET || 'CLIENT_SECRET', + callbackURL: '/api/auth/paypal/callback', + sandbox: true + }, mailer: { from: process.env.MAILER_FROM || 'MAILER_FROM', options: { diff --git a/modules/users/client/img/buttons/paypal.png b/modules/users/client/img/buttons/paypal.png new file mode 100644 index 0000000000000000000000000000000000000000..54689395635bf9e1e59e912524fe2c42985ae044 GIT binary patch literal 5229 zcmY*d1yIyqwEpd~q{I>e(g;YGEG0;H*CLCwlypc*xO7R0bSx6my#mq=f-C~kAl)TM ziooMP^Jd<>d*|FUbMBlw-<@;kyXTx}9W7-d0vZAU0Ekpo6!h*j@;|`?->(`b=h^oP z-%SPK2>^U7{|U&qNZR|}i2FuWQxSIw8=HiUJ(V3%3IG&@stU3OzHFMV0W1xs5TyiWo1>8i!*$MYT11qvmO~koM%=b-j;I@(0z(P*y7w6NTIuly6u5D(Gy;dbzORrSZR_ zw5n5V>xjg#1t2;PA=UwCr6x?9@DH~HnL!j>LCJ{oRJ>jt0 z!Dwl{-1&DZ9PP5;y}ug1c4Xe(3G2=|{q>GGI)IT6PY$_8Eo*^gSyWMXmeP36)9L_M zSMP-6O`Jm%2>u=Vf$*cRQ zC4Nk?Pr4kDNLad?c}oub#{N)1AQo?WgE51TMF<19#8c%TpA3+*LsP#Lo6U$+fG+=) z?<#z~D-Hu8zW((r8(VqM*-V71dUAihtxwG)JxvwBv@focW^fxiSWh(4Zb^Wwu(yP( z9|{Q&;zLp_Gh^_=C!2)y!o(F3j(6nRx9@sL0C<7>7Nn<3e}$SEfZ%~rvAbmq_L#xI zqXuAKT8DOE@}t}!$q*+t5otU*m=G%r#3TcVF+h?Y*CH-02|CXgQ{3Hjh-EqOie2hz z%h%oLI0zoE_<5((tZ4htB@9?cE~Dw5fLYI#CzvQK0uPrMPO8N>AH|dXzG~+(gZ*R8 z%=Gor#M7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lXsJskzQcwb8pVt{w;Y!F zwk6=$H`Irn(C=)=ks)w*?ZChMp`yG3Q`lO%iQSM;g6Xd*8k3HjbPlw%yrtP&W8-Nm zH-EX|cQ<@Xq@dR{^eI{Ar!4G?4t!o}fBTwY{P7i?bA7WUM=qu>XmvQ1>ZBy)37q~p zZrOn4r{LK6K^C6}V+cV&S}$g(Rw2Lyayc8;R2)uty1MXC+vV?CS*4XS8!#$3`uxN^ zb}J$DlN?s_QSign in using your social accounts + + +
diff --git a/modules/users/client/views/settings/manage-social-accounts.client.view.html b/modules/users/client/views/settings/manage-social-accounts.client.view.html index b40b203e6c..6a0b47300e 100644 --- a/modules/users/client/views/settings/manage-social-accounts.client.view.html +++ b/modules/users/client/views/settings/manage-social-accounts.client.view.html @@ -40,5 +40,11 @@

+ diff --git a/modules/users/server/config/strategies/paypal.js b/modules/users/server/config/strategies/paypal.js new file mode 100644 index 0000000000..21271bf975 --- /dev/null +++ b/modules/users/server/config/strategies/paypal.js @@ -0,0 +1,42 @@ +'use strict'; + +/** + * Module dependencies. + */ +var passport = require('passport'), + PayPalStrategy = require('passport-paypal-openidconnect').Strategy, + users = require('../../controllers/users.server.controller'); + +module.exports = function (config) { + passport.use(new PayPalStrategy({ + clientID: config.paypal.clientID, + clientSecret: config.paypal.clientSecret, + callbackURL: config.paypal.callbackURL, + scope: 'openid profile email', + sandbox: config.paypal.sandbox, + 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._json.email, + username: profile.username, + provider: 'paypal', + providerIdentifierField: 'user_id', + providerData: providerData + }; + + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + } + )); +}; diff --git a/modules/users/server/routes/auth.server.routes.js b/modules/users/server/routes/auth.server.routes.js index 6390beed5f..02b6471847 100644 --- a/modules/users/server/routes/auth.server.routes.js +++ b/modules/users/server/routes/auth.server.routes.js @@ -50,4 +50,8 @@ module.exports = function(app) { // Setting the github oauth routes app.route('/api/auth/github').get(passport.authenticate('github')); app.route('/api/auth/github/callback').get(users.oauthCallback('github')); + + // Setting the paypal oauth routes + app.route('/api/auth/paypal').get(passport.authenticate('paypal')); + app.route('/api/auth/paypal/callback').get(users.oauthCallback('paypal')); }; diff --git a/package.json b/package.json index aabab5ab59..9af09003c3 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "passport-linkedin": "~0.1.3", "passport-google-oauth": "~0.1.5", "passport-github": "~0.1.5", + "passport-paypal-openidconnect": "^0.1.1", "acl": "~0.4.4", "socket.io": "~1.1.0", "lodash": "~2.4.1",