Questions tagged [express-jwt]

Middleware for handling JSON Web Tokens with Connect or Express, including validation and setting user attributes in the request object.

React struggling to retrieve the initial value from localStorage

Hello everyone! I am currently working on a MERN app and have been exploring how to implement JWT token authentication. Everything seems to be working fine, but I encountered a small issue on the frontend. After a user logs in, the token is successfully se ...

utilizing refresh tokens in Angular and Express-JWT

I'm interested in incorporating the Sliding expiration principle with JSON web tokens using Angular, Node.js, and express-jwt. I find myself a bit confused on how to go about this, as well as struggling to come across any examples or resources related ...

Node.js app experiencing intermittent issues with AngularJS interceptor failing to include JWT Bearer token in all requests

I have implemented a JWT authentication system in a node app. To ensure the Bearer token is included in every request, I used an interceptor. It functions correctly when accessing a restricted route within Angular or by using curl with the token specified ...

Is express-jwt assigning the user object to req.user._doc, as opposed to just req.user?

Previously, I have utilized the npm package express-jwt for effortless JWT signing and decoding. Typically (and as per the documentation), it decodes the token in a request, extracts the user object payload, and assigns it to req.user. However, this time a ...

Only use Node's expressJwt middleware if the specific ID route is not

We've encountered a challenge with the expressJwt library where we need to exclude the GET method for the route api/items/:id but not for routes like api/items/:id/special-action. Currently, our setup only excludes all routes that contain the :id paramete ...

Why does my catch block fail to execute in the event of an error?

I'm currently encountering an issue while working with the express-jwt library. Instead of receiving a JSON response for errors, I am getting an HTML error display in my postman tool. I need help on how to handle and pass express-jwt errors within the catc ...

We encountered an issue: `TypeError: expressJwt function is undefined`

As I work on developing middleware for user authorization within my application, I encounter an issue while attempting to determine if a route necessitates signing in. The relevant snippet of code is presented below: const { expressJwt } = require ...

Having trouble with importing a variable in an Express application? You may encounter this error message: "Route.get() must

When trying to import requireSignin from the controllers/auth.js file into the routes/user.js file and adding it to the router.get('/user/:id', requireSignin, read); route, an error occurs: Error: Route.get() requires a callback function but r ...

What are some potential problems that could arise when making a POST request for signing authentication in a MERN stack using JWT?

I'm currently in the process of developing a social media application using the MERN stack. To ensure the functionality of the backend API, I am utilizing POSTMAN. Here is an overview of the dependencies outlined in the package.json file: { "name": ...

Challenges with removing jwt token cookie in Express

//token creation res.cookie('jwt', token, { httpOnly: true, maxAge : 60 * 60 * 24}); //logout and destroying the token exports.logout = (req, res) => { res.cookie('jwt', "token", {httpOnly:true,maxAge:1000}) //unfo ...

What is causing the error message "TypeError: expressJwt is not a function" to appear? Is there a way to resolve it and fix the issue?

Authentication with JWT in Node.js: const expressJwt = require('express-jwt') function setupAuth() { const secret = process.env.SECRET_KEY return expressJwt({ secret, algorithms: ['HS256'] }) } module.expor ...

Are JSON Web Tokens (JWT) too lengthy to transmit via client URL? Exploring Node.js and Express for authentication purposes

I need to authenticate a user's email address using JWT instead of OAuth. This is necessary because users will be signing up with their work email and need to verify it. To do this, I have added an "isVerified" field to my User model. When a user sign ...

RS256 algorithm not utilized for Node.js JWT token generation

For my node.js REST api calls, I implemented JWT as a security measure. Below is the code snippet I used to generate the token: jwt.sign({ foo: 'bar' }, private_key, { algorithm: 'RS256'}, (err, token) => { res.json({ ...

The expiration time of the JWT signed token remains unchanged in the browser application even after being updated in the code

Here is the code snippet: const token = jwt.sign({ _id: user._id }, process.env.JWT_SECRET, { expiresIn: '1d' }); res.cookie('token', token, { expiresIn: '1d' }); Initially, everything was functioning properly with the token expiring after one da ...

The JWT Cookie has successfully surfaced within the application tab and is now being transmitted in the request

When sending a JWT token to an authorized user in Express, the following code is used: The cookie-parser module is utilized. module.exports.getUser = async (req, res, next) => { console.log('i am in getuser'); const { SIT } = req.query; const { o ...

Issue encountered with express-jwt and express-graphql: TypeScript error TS2339 - The 'user' property is not found on the 'Request' type

Implementing express-jwt and graphql together in typescript has been a challenge for me. import * as express from 'express' import * as expressGraphql from 'express-graphql' import * as expressJwt from 'express-jwt' import s ...