passport.js

Passport-js How to create a custom strategy

蓝咒 提交于 2019-12-10 12:31:19
问题 I am looking to create my own strategy. I have client_id , client_secret and related meta data. I also know the flow of execution. So I want to create my own strategy and add my custom logic for authentication. I looked at passport-strategy, but I am not understanding how to implement my own strategy. Can anyone explain it? 回答1: You have two options here: If you have a custom logic for authentication you don't really need to create your own strategy... you can use the passport-custom strategy

Need to redirect to google app email login page instead of normal gmail login in passportjs and nodejs

倖福魔咒の 提交于 2019-12-10 12:29:49
问题 I have a nodejs application. In which I setup a google auth2 login system using passport js. I need to authenticate against a google app email id not a normal gmail id. Authentication is working fine. But it is not redirecting to the google app email login page (google.com/a/domain.com). It redirect to the gmail login page and from there I can login and authenticate by typing the full email id (username@domain.com). Is there any way to redirect to app engine login page so that I have only

how to 'redirect' with react after login with passport.js?

回眸只為那壹抹淺笑 提交于 2019-12-10 11:21:56
问题 Newbie react question: I’m using it with passport.js and express. I’m successfully logging in to the application. But I don't know how to do a redirect. router.post('/login', passport.authenticate('local'), function(req, res) { // If this function gets called, authentication was successful. res.redirect('/upload'); //<—— what I’d like to do is some kind of redirect here }); Any help appreciated. 回答1: Do that on your callback route. router.get('/facebook', passport.authenticate('facebook', {

Passport.js throwing “undefined is not a function” with LocalStrategy

て烟熏妆下的殇ゞ 提交于 2019-12-10 11:06:37
问题 I am implementing local authentication using Passport.js. I have already implemented Github Oauth, which is fine but for some reason the local strategy is failing with the above error. I cannot find any source of the issue so far. I have read other posts but the usual answer is that you should change the require statement to: var LocalStrategy = require('passport-local').Strategy; However, I have already done this. Any help would be much appreciated. Here are my files as it stands. I have

Re-handle request after changes

…衆ロ難τιáo~ 提交于 2019-12-10 10:42:55
问题 I'm trying to use passport.js in a generic way, changing configuration before calling authenticate , but I can't find a way to redirect request to it after. I handle request like this: Entry point : app.get('/authorize/:clientId/:network', authUtils.authorize); Handler : async function authorize(request, response, next) { try { let clientId = request.params.clientId; let network = request.params.network; config = await databaseUtils.getConfig(clientId, network); if(typeof(config) !==

Using cookieSession with Passport

筅森魡賤 提交于 2019-12-10 10:41:28
问题 I want to use cookie session store with Passport because memory store is not designed for production: Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process. Here's my Express initialization: app.use(express.bodyParser({keepExtensions:true})); app.use(express.cookieParser(cookieSecret)); app.use(express.cookieSession({ key: cookieKey, secret: cookieSecret, maxAge: sessionTimeout })); app.use

Use Passport.js Behind Corporate Firewall for Facebook Strategy

孤者浪人 提交于 2019-12-10 10:19:33
问题 I have been able to use node.js and passport.js to connect to Facebook using the GitHub project available at: https://github.com/jaredhanson/passport-facebook/tree/master/examples/login. Here is the what the app.js code is doing: var express = require('express') , passport = require('passport') , util = require('util') , FacebookStrategy = require('passport-facebook').Strategy , logger = require('morgan') , session = require('express-session') , bodyParser = require("body-parser") ,

Express: is it possible to bypass sessions for static files?

孤者浪人 提交于 2019-12-10 03:52:15
问题 I'm using a quite straightforward setup of Express + Mongoose + Passport + Connect-mongo, and everything works fine. The only thing that is puzzling me, is that I can see the passport.unserializeUser called even for static files, which is - from my application point of view - absolutely pointless. I can understand that there are cases where you want the static files to be served under some sort of authorization as well, but I wonder how I could "skip" the whole session middleware in case I'm

passport authentication failure leads to redirect loop

断了今生、忘了曾经 提交于 2019-12-10 02:22:15
问题 I am using node, express and passport with facebook authentication. I have the following routes (when /facebook/auth/callback is the callback url): function render(page, req, res) { var user = null; if (req.user) { user = req.user.toObject(); user.isLoggedIn = true; } res.render(page, { user: user }); } app.get('/auth-failure', function (req, res) { res.render('auth-failure'); }); app.get('/auth-success', function (req, res) { render('auth-success', req, res); }); app.get('/facebook/auth',

More Passport.js woes - hangs on form submission

点点圈 提交于 2019-12-10 00:54:40
问题 I am setting up what I thought would be the simplest auth possibly - a site loads on a log in screen, user enters credentials in a form, on submission I am using Passport.JS and Sequelize to check the credentials. Most all of this is copied from various tutorials, or the Passport website itself. No matter what I do, change or attempt though, the site just hangs as soon as I click the form submit button. In the dev tools network tab I just shows the post request to /login as pending. To