Saturday, 28 December 2019

Authenticating my node app against Django

I am currently running django as a cms. My goal is to add nodejs to the mix for some real time socket fuckery.So far, I have it running like this:var djangoAuth = function (req, res, next) { jwt.verify(req.params.django_user_jwt, 'DJANGO_SECRET_KEY', function(err, decoded) { if(err) { res.status(401).json("Go away") } req.user = decoded; next(); }); } router.post('/django_login', djangoAuth, (req, res) => { console.log("Hey", req.user); }); So far it works. I just have to login to Django on the front end and POST the JWT token it spits to my nodejs backend. Does it sound like a good plan?

Submitted December 29, 2019 at 02:30AM by pink_tshirt

No comments:

Post a Comment