Questions tagged [passport.js]

Passport.js is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped into any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter and more.

Passport.js is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped into any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter and more.

URL : Official website

6968 questions
481
votes
7 answers

Understanding passport serialize deserialize

How would you explain the workflow of Passport's serialize and deserialize methods to a layman. Where does user.id go after passport.serializeUser has been called? We are calling passport.deserializeUser right after it where does it fit in the…
Anubhav
  • 7,138
  • 5
  • 21
  • 33
217
votes
11 answers

Passport.js - Error: failed to serialize user into session

I got a problem with the Passport.js module and Express.js. This is my code and I just want to use a hardcoded login for the first try. I always get the message: I searched a lot and found some posts in stackoverflow but I didnt get the…
user2244925
  • 2,314
  • 3
  • 14
  • 11
216
votes
6 answers

How to implement a secure REST API with node.js

I start planning a REST API with node.js ,express and mongodb. The API provides data for a website (public and private area) and maybe later a mobile app. The frontend will be developed with AngularJS. For some days I read a lot about securing REST…
tschiela
  • 5,231
  • 4
  • 28
  • 35
161
votes
4 answers

What does passport.session() middleware do?

I am building an authentication system using Passport.js using Easy Node Authentication: Setup and Local tutorial. I am confused about what passport.session() does. After playing around with the different middleware I came to understand that…
Georges Krinker
  • 2,259
  • 4
  • 25
  • 24
157
votes
3 answers

passport.js RESTful auth

How does one handle authentication (local and Facebook, for example) using passport.js, through a RESTful API instead of through a web interface? Specific concerns are handling the passing of data from callbacks to a RESTful response (JSON) vs using…
ryanrhee
  • 2,550
  • 4
  • 23
  • 25
125
votes
7 answers

Everyauth vs Passport.js?

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?
EhevuTov
  • 20,205
  • 16
  • 66
  • 71
120
votes
16 answers

ERR_HTTP_HEADERS_SENT: Cannot set headers after they are sent to the client

I'm facing this weird issue in NodeJS when using with Passport.js, Express and Mongoose. Basically, I get an error saying "Cannot set headers after they are sent to the client" even though I don't send more than one header. I've read other posts and…
lourdesr
  • 1,311
  • 2
  • 9
  • 5
117
votes
8 answers

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

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…
Naor
  • 23,465
  • 48
  • 152
  • 268
116
votes
7 answers

Redirecting to previous page after authentication in node.js using passport.js

I'm trying to establish a login mechanism using node.js, express and passport.js. The Login itself works quite nice, also sessions are stored nicely with redis but I do have some troubles with redirecting the user to where he started from before…
Alx
  • 6,275
  • 7
  • 32
  • 54
114
votes
6 answers

How to know if user is logged in with passport.js?

I've been reading passport.js info and samples for two days, but I'm not sure after that I did all the process of authenticating. How do I know if I'm logged in, for example, I'll have a navigation bar with a login or logout button, is there some…
RMontes13
  • 2,138
  • 3
  • 16
  • 23
107
votes
2 answers

Using PassportJS, how does one pass additional form fields to the local authentication strategy?

I'm using passportJS and I'm wanting to supply more than just req.body.username and req.body.password to my authentication strategy (passport-local). I have 3 form fields: username, password, & foo How do I go about accessing req.body.foo from my…
k00k
  • 17,314
  • 13
  • 59
  • 86
92
votes
3 answers

passport-local with node-jwt-simple

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 =…
cgiacomi
  • 4,629
  • 6
  • 27
  • 33
90
votes
30 answers

Node + Express + Passport: req.user Undefined

My question is similar to this one, but there was no insight into his solution. I'm using Passport to auth using Instagram. After successful auth, users are directed to "/". At this point, the request has the user object (aka it's working). …
gojohnnygo
  • 1,148
  • 1
  • 10
  • 13
83
votes
1 answer

How is req.isAuthenticated() in Passport JS implemented?

In passportJS Documentation, I think passport isAuthenticated function not documented well. How is req.isAuthenticated() in PassportJS implemented?
Kim
  • 1,081
  • 2
  • 12
  • 17
77
votes
29 answers

Why is PassportJS in Node not removing session on logout

I am having trouble getting my system to log out with PassportJS. It seems the logout route is being called, but its not removing the session. I want it to return 401, if the user is not logged in in specific route. I call authenticateUser to check…
Jeffrey Chen
  • 1,039
  • 2
  • 11
  • 14
1
2 3
99 100