Tag: passport.js

SPA(angular度)身份validation与OAuth2提供商的独立域上的API和身份validation服务器; Google,Facebook

我有一个angular度的应用程序运行在独立的域比我的api / auth服务器。 对于本地的例子:我的angular度应用程序是在localhost:9000,我的api / auth服务器是在localhost:3000。 或者,如果这是公开的,例如在CDN上的angular色。 我想使用服务器/代码stream与Google和Facebook进行身份validation。 我见过的例子使用窗口popup窗口或cookies。 由于CORS问题,Cookies不可能出现问题,我希望这个Web API也可以在移动应用程序中使用。 我发现Sattelizer,这工作良好,但我正在寻找与护照一起工作的解决scheme。 本质上是一种用于交换访问令牌的授权代码(通过angular度应用程序传递)的通行证策略,而不是直接从后端请求访问令牌。 如果这不存在,我可能会尝试做一个。

passportjs,摩卡,超级ECONNREFUSED

我正在尝试使用摩卡,超级terminal和护照进行身份validation,但是我收到拒绝连接的错误消息。 我认为这与我开始我的应用程序的方式… var testUser = { "email": "test@test.com", "password": "test" }; var app = require('../../server'); var request = require('superagent'); var user = request.agent(app); describe('authentication api ', function() { it('should login a user', function(done) { user.post('/login') .send(testUser) .end(function(err, res) { if(err) throw err; done(); }); }); }); 这个用户确实存在于我的mongo数据库中。 在我的服务器文件,这是更高的两个层次: module.exports = app.listen(port, function() { console.log('app listening […]

不工作:PingFederate + Passport.js Ping

我试图用PingFederate作为我的Auth服务器和passport-ping npm进行login。 我做了所有通常的configuration,即 app.get("/auth/ping", passport.authenticate("ping")); app.get("/auth/ping/callback", passport.authenticate("ping",{ failureRedirect: '/login'}), function(req,res){ console.log(profile); res.render("profile", {user : req.user}); } ); 和 // Ping Strategy passport.use(new PingStrategy({ host: 'blahblah.com', port: 9031, clientID: config.ping.clientID, clientSecret: config.facebook.clientSecret, callbackURL: config.ping.callbackURL }, function(accessToken, refreshToken, profile, done) { User.findOrCreatePingUser(profile, done); })); 我甚至可以授予PingFederate的许可,并从那里重新定向。 但是,当Passport试图parsing这个授权码时,会抛出以下错误: Express 500 TokenError: Invalid client or client credentials at Strategy.OAuth2Strategy.parseErrorResponse (c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:298:12) […]

捕捉/处理MySQL重复input错误 – 使用NodeJS,PassportJS,Express,连接闪存,Heroku

我正在做一个节点应用程序的用户注册,从这个例子开始,但是使用MySQL数据库而不是MongoDB。 用户表中的多列具有唯一性约束。 这是创build表的SQL代码: CREATE TABLE `' + dbconfig.database + '`.`' + dbconfig.users_table + '` ( \ `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, \ `username` VARCHAR(60) NULL, \ `password` CHAR(60) NULL, \ `facebook_id` VARCHAR(60) NULL, \ `facebook_token` CHAR(223) NULL, \ `facebook_name` VARCHAR(100) NULL, \ `facebook_email` VARCHAR(100) NULL, \ `google_id` VARCHAR(60) NULL, \ `google_token` CHAR(67) NULL, \ […]

护照login回拨丢失会话

我有下面的代码存储用户引用HTTP头到会话,所以,在facebook护照login发生后,我可以知道他试图访问哪个页面,并正确地redirect我的用户: function facebookAction(req, res, next){ var referer = req.headers['referer']; req.session.redirectLogin = url.format(parsed, true); passport.authenticate('facebook', {scope: ['user_birthday', 'user_location', 'email']})(req, res, next); } 问题是,在Facebook回叫我的URL后,会话不再被设置: function facebookCallbackAction(req, res, next){ var redirectLogin = req.session.redirectLogin; console.log(req.session.redirectLogin); // this is undefined passport.authenticate('facebook', { successRedirect: redirectLogin + 'login=1', failureRedirect: redirectLogin + 'loginError=1'})(req, res, next); } login发生,但由于某种原因我失去了会话。 有没有人之前通过这个问题? 我使用sails作为框架

在process._tickCallback(node.js:419:13)处,NodeJs,500未能获得访问令牌(错误:连接ECONNREFUSED)

我正在使用护照GoogleStrategy来validation用户,但我得到以下错误。 你能帮我么 ? 码 passport.use(new GoogleOAuth2Strategy({ clientID : configAuth.googleAuth.clientID, clientSecret: configAuth.googleAuth.clientSecret, callbackURL: configAuth.googleAuth.callbackURL, scope: ['profile', 'email', 'openid'], passReqToCallback : true }, function(token, refreshToken, profile, done) { // User.findOne won't fire until we have all our data back from Google process.nextTick(function() { console.log(profile.id); User.findOne({ 'google.id' : profile.id }, function(err, user) { if (err) return done(err); if […]

PassportJS获取Facebook用户位置

我试图设定我的策略,以两种方式获得用户的家,而这两者都不起作用。 有没有人有PassportJS代码来获取用户的地址(只是城市和州)? 策略尝试“位置”和“地址”: profileFields: ['id', 'name','picture.type(large)', 'emails', 'displayName', 'location', 'address', 'about', 'gender'], 试图获得使用地址,如在这里看到的portablecontacts.net : user.facebook.location = profile.address.locality + ', ' profile.address.region;

使用Node.js,Passport进行服务器到服务器的身份validation

我有两个服务在不同的子域上运行:1)Node.js,Express,PassportJS,2)基于PHP。 这两个服务都暴露在同一个门户网站中,为了避免要求用户input凭证两次,我们从PHP服务器调用Node.jsloginAPI。 节点返回会话cookie( connect.sid ),我们转发这个客户端的域设置为<<rootdomain>>.com 。 现在,当客户端调用Node.js时,我们可以看到cookie被发送到Node,但仍然无法validation。 我已经validation了以下几点: 从PHP服务器到Node的loginAPI调用返回connect.sid cookie的成功,并将会话条目添加到Redis服务器(我们使用Redis来存储会话) Cookie在浏览器中正确设置 浏览器调用Node.js时connect.sid cookie发送到服务器 如果我们直接从客户端调用loginAPI,一切都按预期工作。 基本上独立的Node应用程序没有任何问题。 我很好奇节点是否使用用户代理,IP或什么来validationconnect.sid cookie? 或者它与Passport / Express会话参数值有关吗? 什么可能是错的? 仅供参考,目前网站没有在SSL上运行。 这是我的会议参数: store = new RedisStore({ port: 6379, host: 'localhost', client : redis }); var sess = { store: store, secret: 'some secret', rolling: true, cookie: { maxAge : 36000000, secure: false }, saveUninitialized: […]

BigCommerce oauth2 passport.js策略

BigCommerce是一个巨大的电子商务平台,他们的API和应用程序开发变得非常大。 他们的新API使用oauth2authentication(授权types=授权码)。 有没有人开发Bigcommerce passport.js策略呢? 据我所见,它就像传统的授权代码策略,但初始授权请求不会被应用程序本身启动,login到其Bigcommerce商店的使用者将启动来自该应用程序内的“bigcommerce App store”的授权请求bigcommerce商店仪表板。 然后,应用程序(使用node.js和passport.js)将处理接收authentication代码的callbackurl,并请求令牌(来自Bigcommerce api)。 我有这个进程使用simple-oauth2 npm模块,但需要弄清楚在MongoDB中存储客户端访问令牌 有没有人做过这个?

从redirect表示护照authentication空白页面

我使用Facebook的身份validation策略使用护照。 我使用angular度为客户端和服务器端表示。 当用户点击loginFacebook,并成功通过身份validation后,我将redirect回主页面。 但是,当我回来时,我总是得到空白页。 刷新后,页面再次罚款。 这是我的实现: facebook.js: 'use strict'; var passport = require('passport'), url = require('url'), FacebookStrategy = require('passport-facebook').Strategy, config = require('../config'), user = require('../../app/user/user.server.controller'); module.exports = function() { // Use the Passport's Facebook strategy passport.use(new FacebookStrategy({ clientID: config.facebook.clientID, clientSecret: config.facebook.clientSecret, callbackURL: config.facebook.callbackURL, profileFields: ['id', 'displayName', 'email'], passReqToCallback: true }, function(req, accessToken, refreshToken, profile, done) […]