passport.js

PassportJS Profile Undefined Name

混江龙づ霸主 提交于 2019-12-12 02:57:48
问题 I'm using PassportJS and passport-google-oauth in an ExpressJS web app. var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; passport.use(new GoogleStrategy({ clientID: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_CLIENT_SECRET, callbackURL: CALLBACK }, function(accessToken, refreshToken, profile, done) { console.log(profile.displayName); console.log(profile.name.familyName); console.log(profile.name.givenName); ... })); The problem is that profile.displayName , profile.name

RESTful Node.js Application with passport-http

北城以北 提交于 2019-12-12 02:54:11
问题 I'm working to get passport-http working with my application to make it comply with RESTful principles. Right now the default is that the browser prompts the user for a username and password with it's own prompt. With Node.js and PassportJS is it possible to use my own login form? In the case that a user tries to access a page that they are not authenticated for then I would redirect them to that form. Or is this in itself violating the principles of RESTful design? 回答1: REST defines web

Page callback not load with NodeJS Express Passport-facebook

偶尔善良 提交于 2019-12-12 02:47:26
问题 I have an application node js using express for authentication via facebook but the url /auth/facebook/callback does not load. Dependencies version: Express: 4.13.3 Passport 0.3.0 Passport-facebook 2.0.0 app.js var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))

How can I manage sessions with Passport JS for some routes using express?

戏子无情 提交于 2019-12-12 02:28:58
问题 I got below express node.js server code using Passport . At it my whole routes definition depends upon a MongoDB connection using mongo-db but model used by Passport is done through another connection by mongoose . I mention these two details cause I think it should also be coded in a better way. However, the main problem is that even though Passport it's doing it's work, I still can go to localhost/registro directly no matter I didn't logged in first. When someone tried to access to

Check if username is taken - PassportJS

一笑奈何 提交于 2019-12-12 02:15:59
问题 I am needing to check that the username is not taken before a user creates an account. I am attempting to build a one page application with AJAX and passport. How would I go about checking to see if the username is taken BEFORE posting when a user is registering using passport? Not sure where to start. Thanks! app.post("/quiz", function(req, res){ var newUser = new User({username: req.body.username, datapoint: req.body.datapoint}); User.register(newUser, req.body.password, function(err, user)

Passportjs (after successful login)

泄露秘密 提交于 2019-12-11 22:34:18
问题 I have the following code borrowed from this excellent resource: http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local#handling-signup/registration app.post('/signup', passport.authenticate('local-signup', { successRedirect : '/profile', // redirect to the secure profile section failureRedirect : '/signup', // redirect back to the signup page if there is an error })); but I don't want to use the successRedirect or failureRedirect as my front end is an Angularjs app.

Passport-facebook unable to connect

我们两清 提交于 2019-12-11 20:15:09
问题 In my application, I'm trying to add loggin with facebook account. As I'm using passport for the moment with local strategy, I tried to add the facebook strategy. I registered on facebook developper site to have my token and secret. I simply copy/paste source code portions from the official passport github, adapting to my personal use. The problem occurs when calling passport.authenticate('facebook'); I am stuck in here and not redirected to the facebook loggin page. My application is waiting

Beginner Passport/React: login system not working

≯℡__Kan透↙ 提交于 2019-12-11 17:16:02
问题 I can't get this login system to work, here's my code: React code: login(username, password) { fetch('http://localhost:8080/login', { method: 'post', headers : { 'Content-Type': 'application/json', 'Accept': 'application/json, text/plain, */*', }, body: JSON.stringify({username: username, password: password}) }).then(res=>res.json()) .then(res => console.log(res)); } Node backend, called by the React code: app.post("/login", function(request, response) { passport.authenticate("local-login",

Access authenticated user on Angular SPA client side

百般思念 提交于 2019-12-11 17:08:16
问题 I'm building web app using Node.js Express.js for the server-side and Angular 6 SPA for the client. Using the simple Express.js code, below, I've successfully authenticated a user via SAML2.js ADFS and now I want to access the user on the client side Angular SPA. How do I do that? I found a similar setup here, but there is not an answer there and its a bit dated. var saml2 = require('saml2-js'); var fs = require('fs'); var express = require('express'); var https = require('https'); var app =

Passport-Azure-Ad seems to run asynchronously (still)

こ雲淡風輕ζ 提交于 2019-12-11 16:57:21
问题 The traditional way of running Passport strategies in nodejs express middleware is: server.get('/api/tasks', passport.authenticate('oauth-bearer', { session: false })); I am using https://tsed.io, ("typescript express decorators") and referencing this passport strategy it is done like: class MyCtrl { @Get('/api/tasks') @UseBefore(passport.authenticate('oauth-bearer', { session: false })) get() { ... } } This works perfectly. you can also run it as a detached middleware. Something like: @Post(