passport.js

Restrict login to specific domain using Node Passport with Google Auth

跟風遠走 提交于 2020-08-20 20:57:04
问题 I am implementing Google Auth on an internal service at work. It is a JS client heavy application with a Node backend. I am choosing to use the Node module Passport.js with the passport-google-oauth strategy. I have successfully got it working but one thing is still confusing me. I want to ensure my application allows only company employees to login. I understand that you can restrict the login by domain using a parameter called "hd", according to the official documentation. Firstly, where do

Facebook-passport with JWT

放肆的年华 提交于 2020-07-31 07:50:26
问题 I've been using Passport on my server for user authentication. When a user is signing in locally (using a username and password), the server sends them a JWT which is stored in localstorage, and is sent back to server for every api call that requires user authentication. Now I want to support Facebook and Google login as well. Since I began with Passport I thought it would be best to continue with Passport strategies, using passport-facebook and passport-google-oauth . I'll refer to Facebook,

How to protect static folder in express with passport

耗尽温柔 提交于 2020-07-04 05:55:40
问题 I have a project based on express with a required authentication based on passport. The backoffice is an angularjs app served as static files. My authentication code is completly based on https://github.com/jaredhanson/passport-local/blob/master/examples/express3-no-connect-flash/app.js To do not serve the angular app if you are not authenticated. I have try by adding ensureAuthenticated on the /admin route but it make the route not working (404). Once I remove ensureAuthenticated the /admin

How to protect static folder in express with passport

霸气de小男生 提交于 2020-07-04 05:55:30
问题 I have a project based on express with a required authentication based on passport. The backoffice is an angularjs app served as static files. My authentication code is completly based on https://github.com/jaredhanson/passport-local/blob/master/examples/express3-no-connect-flash/app.js To do not serve the angular app if you are not authenticated. I have try by adding ensureAuthenticated on the /admin route but it make the route not working (404). Once I remove ensureAuthenticated the /admin

Passport.js TokenError After Deployment to Production

北慕城南 提交于 2020-06-29 04:52:06
问题 I have a MERN stack app which uses Passport.js for Facebook/Twitter/Google authentication. In the development environment, everything works well and we are able to authenticate the user and log them into the application. After confirming the functionality in the development environment, we deployed to Heroku, but the same functionality is not working in production, and Passport.js is failing with a "TokenError" stating that the Domain URL is not included in the app's domains (even though we

session not create after login using passport .js

微笑、不失礼 提交于 2020-06-28 04:13:24
问题 i use console.log(user.id) in serialize it show user id when i login but in browser when i go in application, session storage is empty. it not show any key and value Passport.js const LocalStrategy = require('passport-local').Strategy const mongoose = require('mongoose') const bcrypt = require('bcrypt') const User = require('../models/User') module.exports = function(passport) { passport.use("local", new LocalStrategy({usernameField:"email"}, (email, password, done)=>{ User.findOne({email

session not create after login using passport .js

人走茶凉 提交于 2020-06-28 04:13:09
问题 i use console.log(user.id) in serialize it show user id when i login but in browser when i go in application, session storage is empty. it not show any key and value Passport.js const LocalStrategy = require('passport-local').Strategy const mongoose = require('mongoose') const bcrypt = require('bcrypt') const User = require('../models/User') module.exports = function(passport) { passport.use("local", new LocalStrategy({usernameField:"email"}, (email, password, done)=>{ User.findOne({email

passport.js multiple de/serialize methods

给你一囗甜甜゛ 提交于 2020-06-03 07:58:46
问题 I'm building a 2 parts login system. Where the a user will login to a main account Account model, this account will hold access to many teams Team model, and an account can have 1 user per team User model. The problem is that I can define an Account login strategy with passport but I will only be able to serialize and deserialize using Account model, but when I want to redirect or login the Account with their User specific data related to a Team I can't log them using passport. I need some

How do I use createProxyMiddleware with the nested logic

独自空忆成欢 提交于 2020-05-28 07:07:05
问题 /node_modules/http-proxy/lib/http-proxy/index.js:120; Error: socket hang up Previous Post: /node_modules/http-proxy/lib/http-proxy/index.js:120; Error: socket hang up I'm trying to use createProxyMiddleware({ target: serviceProvider}) instead of apiProxy.web(req, res, {target: serviceProvider}); . The browser hangs and doesn't show anything (I see the spin in the tab though) How do I properly use createProxyMiddleware with the nested codebase like below? Here is the source code. app.get('

how to delete cookie on logout in express + passport js?

这一生的挚爱 提交于 2020-05-28 05:00:14
问题 I want to "delete cookies on logout". I am not able to do that. I googled for answer and found following ways: Assign new date of expiration to cookie res.cookie('connect.sid', '', {expires: new Date(1), path: '/' }); Delete cookie using below lines res.clearCookie('connect.sid', { path: '/' }); I tried both ways individually but they do not delete the cookie. Here is my code: routes.js module.exports = function(app, passport, session){ app.get('/', function(req, res) { res.render('index.ejs'