passport.js

Dynamic failureRedirect with passport.js

社会主义新天地 提交于 2019-12-14 01:06:08
问题 This is my login function atm: app.post("/login", passport.authenticate("local", { failureRedirect: "/login?error=1" }), function (req, res) { res.redirect(req.body.url || "/"); }); I need to put the req.body.url inside the failureRedirect url, so it should looks like: app.post("/login", passport.authenticate("local", { failureRedirect: "/login?error=1&url=" + (req.body.url || "/") }), function (req, res) { res.redirect(req.body.url || "/"); }); It can't work because the req variable is

passport-saml - express - redirected url not submitting form gives SAML assertion not yet valid

五迷三道 提交于 2019-12-13 18:02:00
问题 Below is the error that I am getting on my console today as opposed to yesterday when the same code was working fine. Error: SAML assertion not yet valid at SAML.checkTimestampsValidityError I have verified that I receive a success from the IDP and hence the application gets redirected to the '/home' endpoint in the URL which has been mentioned in the config file. Additionally, when I submit the form, after an auto redirection [which shows me Internal Server Error ] I press refresh button of

isAuthenticated() function not working node.js passport

≡放荡痞女 提交于 2019-12-13 17:14:45
问题 I am creating online course application and I want only authenticated users to see the course details and course lecture. I am using local strategy of passport authentication for user authentication. I added isAuthenticated in my routes, however, still the unauthenticated users can view the video lectures. Here is my routes file. file name:- courses.server.routes.js 'use strict'; /** * Module dependencies */ var coursesPolicy = require('../policies/courses.server.policy'), courses = require('

How to Authenticate & Authorize a Client-Side Web App using Remote NodeJS API that uses Passport.js

倾然丶 夕夏残阳落幕 提交于 2019-12-13 16:31:57
问题 As shown in the illustration below, I have a standalone API Project running on a server with a port say 3001 , and I have a Web App running on a server with port say 3002 . API on port 3001 , has all the API routes required for the Web App (& mobile apps) to fetch and put data, including Authentication API (Using passport-local and passport-jwt ). In the API side of the project, I have also handled user role authorization, and every routes has list of roles who can access the APIs. Example

Node.JS verify Google Authentication token

陌路散爱 提交于 2019-12-13 16:14:45
问题 I am trying to build a Node.JS REST server using the Express.JS framework that integrates Google authentication for mobile applications. The Node.JS version used is 0.12.7. I am having a problem when verifying the Google token received from the application, as it seems that the module I am trying to load returns an error. The module used to verify this token is passport-google-token. The code used to initialize this module and check the token is as follows: index.js file 'use strict'; import

PassportJS redirect loop

爷,独闯天下 提交于 2019-12-13 14:06:32
问题 Below is the code I have restify = require("restify") passport = require("passport") GoogleStrategy = require("passport-google").Strategy jsonContentType = (req, res, next) -> res.setHeader("content-type", "application/json") next(req, res, next) server = restify.createServer( name: "Sparked API" ) passport.use(new GoogleStrategy({ returnURL: "http://localhost:8080/auth/google/return" realm: "http://localhost:8080/" }, (id, profile, done) -> done() )) server.use(jsonContentType) server.get("/

PassportJS and Stripe

时间秒杀一切 提交于 2019-12-13 07:34:28
问题 I am attempting to charge a user when they create an account. Everything is set up and working perfect with the code before. When a user sign's up for a "premium" section of the website they have an account created and are charged with the code below. The problem: If a user's credit card ends up getting declined for various reasons... their user account is STILL created. How would I change my code below to not reach that part of the code if the credit card fails? Note: this DOES work for when

Passport js, can't sign in after cookie has expired

假如想象 提交于 2019-12-13 05:18:18
问题 I'm using passport js as authentication middleware, local strategy. It works. But when the cookie has expired, I can no longer login. passport.use(new LocalStrategy({ usernameField: 'email' }, function(username, password, done) { mongoose.model('users').findOne({ email: username, password: password }, function(err, result){ if(result){ var user = { name: result.name, email:result.email }; return done(null, user); }else{ return done(null, false, { message: 'Incorrect username.' }); } }); } ));

Accessing a s3 bucket from Node

北城余情 提交于 2019-12-13 04:55:37
问题 I have a basic node application where a user logs in and is able to view links to files stored in a directory within the app. The file structure looks something like this. ├── app ├── public ├── node_modules ├── secure (files stored here) ├── .ebextensions ├── .elasticbeanstalk ├── package.json └── app.js the secure/ directory is where all my files are stored (approx 350mb). here is an example of a link to a file in that directory href="/secure/folder/document.pdf" I've moved the whole secure

Node.js/passport-Facebook authentication

随声附和 提交于 2019-12-13 04:42:47
问题 I am trying to implement a simple Facebook login integration using passport (passport-facebook) authentication middleware. Regarding to this documentation over here I have some code here from my server.js : var express = require('express'), passport = require('passport'), FacebookStrategy = require('passport-facebook').Strategy, app = express(); // Facebook authentication: passport.use( new FacebookStrategy({ clientID: "fb client id here", clientSecret: "fb client secret key here",