Questions tagged [express-jwt]

Connect/express middleware that validates a JsonWebToken (JWT) and set the req.user with the attributes

Middleware that validates JsonWebTokens and set req.user.

This module lets you authenticate HTTP requests using JWT tokens, in your Node.js applications. JWT tokens are typically used protect API endpoints, and are often issued using OpenID Connect.

GitHub: https://github.com/auth0/express-jwt

375 questions
4
votes
3 answers

JWT Returns Invalid Signature Error Even When I enter the token in Authorization

I already looked at this stack overflow entry Node.js - Express.js JWT always returns an invalid token error in browser response but I couldn't find a solution there. I have attempted to write a small node app as a proof of concept for using JWT…
flipvinyl
  • 41
  • 1
  • 1
  • 3
4
votes
1 answer

express-jwt Not respecting unprotected paths

Information on the express-jwt module can be found here: https://github.com/auth0/express-jwt https://www.npmjs.com/package/express-jwt In my main.js server file, I have the following: import ExpressJwt from 'express-jwt'; // import other…
Kenny Worden
  • 4,335
  • 11
  • 35
  • 62
4
votes
1 answer

AngularJS interceptor not putting JWT Bearer in every request of node.js app

I put a JWT authentication system in a node app. I used an interceptor to put the Bearer in every request. It works well if I call a restricted route within Angular or if I curl and specify the token in the header. But if I enter the restricted…
Jean Reptile
  • 107
  • 7
4
votes
0 answers

JSON web token size

I'm currently using the node-jsonwebtoken (https://github.com/auth0/node-jsonwebtoken) library to generate an auth token. I simply call jwt.sign to generate the token. On my staging and development servers, the token that is generated is 941…
Edward Sun
  • 1,541
  • 3
  • 15
  • 26
3
votes
1 answer

Type is not assignable to type 'GetVerificationKey' in express-jwt.(using auth0)

I'm build an auth0 implementation according to here using a combination of express-jwt and jwks-rsa. However, an error like the below occurred and the tsc can't finish properly. Error:(102, 5) TS2322: Type 'SecretCallbackLong | GetVerificationKey'…
Pierogi
  • 341
  • 1
  • 3
  • 17
3
votes
2 answers

Arguments against creating JWT on client side

A partner company is creating an RESTful Endpoint which we want to consume. Instead some proper way of authentication they want to give use the JWT signature key so that we can create a JWT clientside and send the JWT as JSON body to the API…
CrazyTea
  • 297
  • 1
  • 3
  • 13
3
votes
1 answer

JWT signed token expiresIn not changing in browser application even after changed in the code

Original code: const token = jwt.sign({ _id: user._id }, process.env.JWT_SECRET, { expiresIn: '1d' }); res.cookie('token', token, { expiresIn: '1d' }); This worked. The token expired in exactly one day from its creation. The change: const…
Matthew Wolman
  • 645
  • 9
  • 18
3
votes
0 answers

UnauthorizedError: invalid signature - nodejs

I have so far succeeded in acquiring a jwt token passed from front-end - angular to nodejs server. However, I get the error - UnauthorizedError: invalid signature can you please point out what is wrong with my syntax/code ? app.component.ts var…
Techdive
  • 997
  • 3
  • 24
  • 49
3
votes
2 answers

How to change default response of express-jwt for a custom response?

i want to know how to change de response of express-jwt when is unauthorized, i tried with handlers but doesnt work i need help // Authorization const auth = require('express-jwt'); router.get('/', auth({secret:…
3
votes
1 answer

router.get without parameter but asking for param

I am trying to use express nodejs and JWT. Here is the source code of what I've been through: link. I protect all routes, except routes that I declare inside the jwt.js file. the '/trial' url, is not protected. The controller is inside…
Akza
  • 1,033
  • 3
  • 19
  • 37
3
votes
2 answers

How to mock Express JWT unless function?

I'm using Express and Express-JWT. In a Express() instance I use: const api = express() api.use(jwt({ // my options })) To mock this in tests, I use a mocks\express-jwt\index.js file containing: const jwt = jest.fn().mockImplementation(options =>…
Joost den Boer
  • 4,556
  • 4
  • 25
  • 39
3
votes
1 answer

JWT decode fails with invalid exp value

I am using module jsonwebtoken 8.4.0 in a nodejs 10.2.0 app. A JWT token is generated on https://jwt.io for test purpose: Here in payload, the exp is expiration date and the string is correctly formatted in JSON. Then the JWT token on the left is…
user938363
  • 9,990
  • 38
  • 137
  • 303
3
votes
1 answer

JWT Authentication with Alamofire download function

I'm trying to download a zip file and save it from server using JWT token authentication thanks to Alamofire. The download works well without token authentication, the file is saved with success. When I activate the server-side authentication (using…
Jibeee
  • 822
  • 1
  • 11
  • 26
3
votes
1 answer

jest.mock express-jwt middleware behavior for protected routes

So right now I have something like this (which doesn't work) import app from '../src/app'; beforeAll(() => jest.mock('../src/middleware/auth', () => (req: Request, res: Response, next: NextFunction) => { req.user = {}; return next(); …
Zia
  • 2,735
  • 3
  • 30
  • 27
3
votes
1 answer

ExpressJs JWT secret or public key must be provided

I would like to make check-auth but return to me JsonWebTokenError: secret or public key must be provided I can take token successful how can i fix this? I am following this tutorial ; https://www.youtube.com/watch?v=8Ip0pcwbWYM&t=633s const jwt =…
Emre
  • 495
  • 2
  • 6
  • 19