passport.js

persistent sessions with passport, mongodb and express

无人久伴 提交于 2019-12-17 22:39:33
问题 I'm using passport to handle authentication and sessions in my application. I'm persisting sessions to mongodb using mongostore. The setup works fine in general. However, when I restart the server all users are logged out, so apparently sessions are hold in memory instead of being only persisted to mongodb. I'm trying to achieve a setup where users are still logged in when restarting the server. Basic configuration is as follows middleware app.use(express.cookieParser('your secret here'));

Authentication with Passport + Facebook + Express + create-react-app + React-Router + proxy

爷,独闯天下 提交于 2019-12-17 21:52:53
问题 TLDR: How do I initiate the Facebook Auth process from a page in my React application? I've found quite a few posts that touch on most, but not all, of the items I've listed in the title of this post. And I'm pretty close to getting this working, but there must be something I'm missing. My app consists of a create-react-app front-end using react-router for routing. I have this running on port 51000 in my development environment. In package.json, I'm using "proxy" to redirect other routes to

Everyauth vs Passport.js?

笑着哭i 提交于 2019-12-17 21:24:36
问题 Everyauth and Passport.js seem to have very similar feature sets. What are some of the positive and negative comparisons between the two that would make me want to use one over the other? 回答1: Chiming in with my two cents, as the developer of Passport. Before developing Passport, I evaluated everyauth and determined that it didn't meet my requirements. So, I set about implementing a different solution which would. The major points I wanted to address are: Idiomatic Node.js everyauth makes

Get request object in Passport strategy callback

我的梦境 提交于 2019-12-17 18:26:19
问题 So here is my configuration for passport-facebook strategy: passport.use(new FacebookStrategy({ clientID: ".....", clientSecret: ".....", callbackURL: "http://localhost:1337/register/facebook/callback", }, facebookVerificationHandler )); And here is facebookVerificationHandler: var facebookVerificationHandler = function (accessToken, refreshToken, profile, done) { process.nextTick(function () { ....... }); }; Is there a way to access to the request object in facebookVerificationHandler? Users

Nodejs Passport display username

假装没事ソ 提交于 2019-12-17 17:44:33
问题 In nodeJS I am using the passport module for authentication. I would like to show the username of the currently logged in user. I tried the following code: passport.displayName and Localstrategy.username And for more info please also see: http://passportjs.org/docs/profile But that is not working. Any suggestions? Thanks 回答1: The user (as supplied by the verify callback), is set as a property on the request at req.user . Any properties of the user can be accessed through that object, in your

Passport-Facebook authentication is not providing email for all Facebook accounts

筅森魡賤 提交于 2019-12-17 17:35:19
问题 I am using Passport-Facebook authentication. passport.use(new FacebookStrategy({ clientID: 'CLIENT_ID', clientSecret: 'CLIENT_SECRET', callbackURL: "http://www.example.com/auth/facebook/callback" }, function (accessToken, refreshToken, profile, done) { process.nextTick(function () { console.log(profile) }); } )); For some of the Facebook accounts I don't get the email_id and I even tried by using a scope variable such as below, but still I am unable to get the email_id. profileUrl : " " and

passport-local with node-jwt-simple

天涯浪子 提交于 2019-12-17 17:33:08
问题 How can I combine passport-local to return a JWT token on successful authentication? I want to use node-jwt-simple and looking at passport.js I am not sure how to go about. var passport = require('passport') , LocalStrategy = require('passport-local').Strategy; passport.use(new LocalStrategy( function(username, password, done) { User.findOne({ username: username }, function(err, user) { if (err) { return done(err); } if (!user) { return done(null, false, { message: 'Incorrect username.' }); }

nodejs passport authentication token

天涯浪子 提交于 2019-12-17 14:58:52
问题 I am writing a nodejs application that I would like to use as both a web application, as well as an API provider. Once a user is authenticated, I want to assign that user a token to be used for subsequent requests. This works great with passport for the web application, as I just serialize and deserialize the user with the token in the session. However, when responding to API requests, there is no cookie to set to store the session information. Ideally, passport would look for the token both

passport.js passport.initialize() middleware not in use

☆樱花仙子☆ 提交于 2019-12-17 07:02:06
问题 I am using node with express + mongoose and trying to use passport.js with restful api. I keep getting this exception after authentication success (I see the callback url on the browser): /Users/naorye/dev/naorye/myproj/node_modules/mongoose/lib/utils.js:419 throw err; ^ Error: passport.initialize() middleware not in use at IncomingMessage.req.login.req.logIn (/Users/naorye/dev/naorye/myproj/node_modules/passport/lib/passport/http/request.js:30:30) at Context.module.exports.delegate.success (

PassportJS Session Mixed Up

笑着哭i 提交于 2019-12-14 03:39:55
问题 On our ExpressJS application, when pushed to production server, the passport session gets mixed up at random times. At random, the page can load the view of another user even when I did not log out of my session. Without doing anything else, another refresh will bring me back to my own account (at random too). This phenomenon is happening to two of our web applications coded by two separate users following the Passport guides on their website. Both web apps use Facebook connect/API. This