Any route with passport.authenticate & JWT Authorization header not being called
fromage9747 opened this issue · comments
I was able to troubleshoot this issue with the help of the below issue:
#89
Using an old user account I am not able to access any route with passport.authenticate. If I log in with a newly created account, everything works fine.
I just encountered this issue with the project I am working on. It was with a user account that I created when I first built the app however the JWT expiry has been the same since the start. Not sure what caused it. I too would be interested in how it happened. Spent two days with troubleshooting ruling out other possibilities. I was able to successfully login with a newer user account.
I can confirm that a new token is created each time I login with the old account:
1st Login
JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvbmxpbmVfc3RhdHVzIjp7ImlzX29ubGluZSI6ZmFsc2UsInNvY2tldF9pZCI6IiIsIm9ubGluZV9zdGF0dXNfc3RyaW5nIjoib2ZmbGluZSIsImxhc3Rfc2Vlbl9kYXRlIjoiMjAxOS0xMC0xOFQwNzoyMDozMi4zNTVaIn0sInRpbWVzdGFtcHMiOnsidmVyaWZpZWRfZGF0ZSI6IjIwMTgtMDctMjlUMDg6MzE6NTEuOTIyWiIsIm1vZGlmaWVkX2RhdGUiOiIyMDE5LTEwLTE5VDA3OjM0OjM2Ljk5MVoiLCJjcmVhdGVkX2RhdGUiOiIyMDE4LTA3LTI5VDA4OjMwOjQwLjA2NFoiLCJsYXN0X2xvZ2luX2RhdGUiOiIyMDE5LTEwLTE5VDA3OjM0OjM2Ljk5MVoifSwic2lkZWJhcl9zdGF0dXMiOnRydWUsInJvbGVzIjpbXSwiaXNWZXJpZmllZCI6dHJ1ZSwicHVibGljX3NlYXJjaCI6ZmFsc2UsInBheW1lbnRfaW5zdHJ1Y3Rpb25zIjoiQ29uZ3JhdHVsYXRpb25zIG9uIHdpbm5pbmcgbXkgYXVjdGlvbiFcblxuUGxlYXNlIG1ha2UgcGF5bWVudCB2aWEgdGhlIHBheW1lbnQgb3B0aW9uIHlvdSBzZWxlY3RlZCBpbiBteSBsaXN0aW5nLlxuXG5PbmNlIHBheW1lbnQgaGFzIGJlZW4gbWFkZSB5b3VyIGl0ZW0gd2lsb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Iubm92b3RlbGVjb20ucnUiLCJpbnRlcm5ldF9wcm92aWRlcl90eXBlIjoiUmVzaWRlbnRpYWwiLCJpbnRlcm5ldF9zZXJ2aWNlX3Byb3ZpZGVyIjoiTm92b3RlbGVjb20gTHRkIiwibGF0aXR1ZGUiOiI1NC42MzY2IiwibG9uZ2l0dWRlIjoiODMuMzA0NSIsIm9yZ2FuaXphdGlvbiI6Ik5vdm90ZWxlY29tIEx0ZCIsImlwX2FkZHJlc3MiOiIzNy4xOTIuMTY2LjQyIiwicmVnaW9uIjoiTm92b3NpYmlyc2sgT2JsYXN0Iiwic3RhdHVzIjoic3VjY2VzcyJ9LCJ0aW1lc3RhbXBzIjp7ImNyZWF0ZWRfZGF0ZSI6IjIwMTktMTAtMThUMDc6MTU6MjUuNjY1WiJ9LCJfaWQiOiI1ZGE5NjY4ZGYwMWZjOThjOGRmM2VkYzgifV0sImxpc3Rpbmdfd2F0Y2hsaXN0IjpbXSwiaWF0IjoxNTcxNDc4NTcxLCJleHAiOjE1NzIwODMzNzF9.LEK4Sj5HlkGjHgvMj7gNHtqGuZD0ZelE_Y5VAalpoiA
I am not storing these in the DB. They only get stored in the user's local storage of the browser and are sent up to the API by Angular when a route requires authentication.
As previously stated, this issue is only occurring with the old user that I originally created with the app. Not sure why this is happening. Perhaps @mikenicholson can shed some light? I haven't deleted the old user account so I can run some tests if need be.
Update. I had an idea that maybe resetting the password for the user account that is encountering the issue might resolve the issue but it has not.
My passport code is pretty much standard. nothing special here:
`const JwtStrategy = require('passport-jwt').Strategy;
const ExtractJwt = require('passport-jwt').ExtractJwt;
const User = require('../models/user');
const config = require('../config/database');
module.exports = function(passport) {
console.log('Passport is being called');
let opts = {};
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('JWT');
opts.secretOrKey = config.secret;
passport.use(new JwtStrategy(opts, (jwt_payload, done) => {
User.getUserById(jwt_payload._id, (err, user) => {
if (err) {
// console.log(err);
return done(err, false);
}
if (user) {
// console.log(user);
return done(null, user);
} else {
// console.log('no user found');
return done(null, false);
}
});
}));
};`
Not sure why its not being correctly formatted. I am using the <> code formatter
I don't understand this issue but I have a feeling it is exactly like what I'm going through right now.
I discovered while testing my auth API with postman that, no matter which user I use for authentication, I keep getting the first user in my DB returned to me.
@mikenicholson Could you shed some light on this? I would hate for my app to go into production only to find all the user accounts be botched after a year of use.
Ran into this issue again onto a newer account which has directed me to too much data being the issue or rather passport is not waiting long enough to get the data from the database or something,