Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

express-jwt integration issues with new v7 #296

Closed
alechartung opened this issue Apr 21, 2022 · 3 comments
Closed

express-jwt integration issues with new v7 #296

alechartung opened this issue Apr 21, 2022 · 3 comments

Comments

@alechartung
Copy link

I have a project mostly following the express example, and having issues after upgrading to express-jwt 7.4.3.

TypeError: cb is not a function

Haven't looked too deeply yet, could be just the example needs updating.

Thanks!

@nsshunt
Copy link

nsshunt commented Apr 21, 2022

Yes I have same problem and the function sig from the returned function from expressJwtSecret is broken.

I was told to use this instead;

const expressJwtSecret = function (options) {
if (options === null || options === undefined) {
throw new ArgumentError('An options object must be provided when initializing expressJwtSecret');
}

		const client = new jwksRsa.JwksClient(options);
		const onError = options.handleSigningKeyError || handleSigningKeyError;
	  
		return function secretProvider(req, token) {
		  const { header } = token;
		  if (!header || !supportedAlg.includes(header.alg)) {
			return;
		  }
		  return client.getSigningKey(header.kid)
			.then(key => {
			  return key.publicKey || key.rsaPublicKey;
			}).catch(err => {
			  return new Promise((resolve, reject) => {
				onError(err, (newError) => reject(newError));
			  });
			});
		}

However, this also does not work (mine times out when trying to find scopes).

So the "integration" between the two modules is broken. Go back to 6.1.2 until both are fixed.

@trasherdk
Copy link

const expressJwtSecret = function (options) {
  if (options === null || options === undefined) {
    throw new ArgumentError('An options object must be provided when initializing expressJwtSecret');
  }

  const client = new jwksRsa.JwksClient(options);
  const onError = options.handleSigningKeyError || handleSigningKeyError;

  return function secretProvider (req, token) {
    const { header } = token;
    if (!header || !supportedAlg.includes(header.alg)) {
      return;
    }
    return client.getSigningKey(header.kid)
      .then(key => {
        return key.publicKey || key.rsaPublicKey;
      }).catch(err => {
        return new Promise((resolve, reject) => {
          onError(err, (newError) => reject(newError));
        });
      });
  }
}

@jfromaniello
Copy link
Member

fixed in v2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants