passport.js

Express router create a new session not wanted

删除回忆录丶 提交于 2019-12-24 00:45:25
问题 I am doing a react project using express and passport-local for the authentication part based on this tutorial : https://scotch.io/tutorials/easy-node-authentication-setup-and-local The authentification work very well, I added the express router to define my routes for my api, but when I call for example "/api/myroute" the router of express creates an other session and I lose the user, so my function isLoggedIn blocks the call of my controllers because there is no user in this new session. So

Using passport-steam with sails-generate-auth

好久不见. 提交于 2019-12-23 18:53:33
问题 I'm creating a SailsJS application, and I want users to log in only with Steam authentication. I used sails-generate-auth to create some boilerplate code with sails routes, but I'm having trouble plugging passport-steam into it. https://github.com/kasperisager/sails-generate-auth https://github.com/liamcurry/passport-steam The reported error is: C:\Users\Joe\testProject\node_modules\passport-steam\lib\passport-steam\strategy.js:67 id: result.response.players[0].steamid, ^ TypeError: Cannot

Implement cookie based authentication in Node JS with Passport

社会主义新天地 提交于 2019-12-23 17:52:19
问题 Below is my server.js (app.js). I am using express with passport, for user authentication. But whenever I restart my node server user logsout. I am very new to nodejs, I was wondering how I could implement a cookie based authentication. So that user does not log out even if the server starts. I'm sure theres some config change which I have not able to find. // server.js // set up ====================================================================== // get all the tools we need var express =

How to authenticate a route with passport-jwt?

末鹿安然 提交于 2019-12-23 16:21:21
问题 I'm using passport-jwt and my strategy is setup like: let jwtOptions = {} jwtOptions.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken() jwtOptions.secretOrKey = process.env.SECRET var strategy = new JwtStrategy(jwtOptions, function (jwt_payload, next) { console.log('payload received', jwt_payload); // usually this would be a database call: var user = users[_.findIndex(users, { id: jwt_payload.id })]; if (user) { next(null, user); } else { next(null, false); } }) passport.use(strategy)

Getting 401 unauthorized status while authorizing jwt token using passport-jwt

落花浮王杯 提交于 2019-12-23 12:58:07
问题 After successfully logging in I am getting the jwt token, now to access restricted api's I am sending the authorization header, but I am always getting 401 Unauthorized I have referred to this Authenticating node API with passport-jwt question asked here but didn't helped me, this is the function I am calling for accessing data from resticted api check() { console.log(this.token); var headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append("Authorization",

passport-saml and SAML encryption

主宰稳场 提交于 2019-12-23 09:13:46
问题 I'm new to passport and passport-saml , and I'm trying to build a Node.js server that uses our University's Shibboleth identity provider for single sign-on. I'm pretty close to getting it all working, but I'm hitting a snag during the /login/callback that I think is related to the encryption configuration. I am able to redirect the client to the sign-in page, and after a successful sign-in, the IdP does a POST back to my /login/callback route. Then I get this error: Error: Invalid signature

Passport.js and Mongoose.js populate User on login - loses populated field on req.user

喜你入骨 提交于 2019-12-23 08:39:12
问题 Using Mongoose.js, my authenticate method populates the field "companyRoles._company," but the populated data reverts to the company reference ID when I try to access the same populated field in my req.user object. //Authentication UserSchema.static('authenticate', function(email, password, callback) { this.findOne({ email: email }) .populate('companyRoles._company', ['name', '_id']) .run(function(err, user) { if (err) { return callback(err); } if (!user) { return callback(null, false); }

Authentication with passport. Can I trust that req.user is indeed the logged in user?

我与影子孤独终老i 提交于 2019-12-23 05:23:05
问题 I'm using passport to authenticate users at my site. Users can register orders, which have and foreignKey (ObjectId) to the User object. Example-objects (written as mongoose schemas): var orderSchema = new mongoose.Schema({ ... address: String, _userID: {type: mongoose.Schema.Types.ObjectId, required: true, ref: 'User'} }); var userSchema = new mongoose.Schema({ email: String, }); Mongoose will create the primary key for each object. My question is; is it enough to check if req.user._id ===

Nodejs Passport Oauth2 Proxy

穿精又带淫゛_ 提交于 2019-12-23 04:31:25
问题 I built my own strategy for passport. Now an instance of my application runs behind a corporate firewall. Thus I need to get all outgoing requests passed to a proxy server first (http), which then connects to the outside world (https). I got this running with other modules like request which offer an option to pass a proxy config. `app -(http)-> proxy -(https via vpn tunnel)-> www`` Question 1) How can I force the outgoing requests from my passport strategy to go via the proxy? 2) If it is

Nodejs Passport Oauth2 Proxy

痞子三分冷 提交于 2019-12-23 04:31:08
问题 I built my own strategy for passport. Now an instance of my application runs behind a corporate firewall. Thus I need to get all outgoing requests passed to a proxy server first (http), which then connects to the outside world (https). I got this running with other modules like request which offer an option to pass a proxy config. `app -(http)-> proxy -(https via vpn tunnel)-> www`` Question 1) How can I force the outgoing requests from my passport strategy to go via the proxy? 2) If it is