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

Error: Invalid RSA public key when using verifySignedJwtWithCertsAsync with Google IAP JWT token #1724

Closed
ericmalen opened this issue Jan 9, 2024 · 1 comment
Assignees
Labels
external This issue is blocked on a bug with the actual product. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@ericmalen
Copy link

ericmalen commented Jan 9, 2024

Issue Summary

I am encountering an error, "TypeError - Invalid RSA public key", when trying to use the verifySignedJwtWithCertsAsync method from the google-auth-library-nodejs library to validate an IAP JWT token retrieved from the request header. I cannot find the source of this issue, can anyone help?

Code Snippet

const retrieveUserEmail = async (header: Headers) => {
  const token = header.get('x-goog-iap-jwt-assertion');
  
  if(!token){
    return 'Unidentified User';
  } 
  
  const oAuth2Client = new gAuth.OAuth2Client();
  const keys = await oAuth2Client.getIapPublicKeys();
  const audience = '/projects/***************/global/backendServices/***************';
  const ticket = await oAuth2Client.verifySignedJwtWithCertsAsync(
    token,
    keys.pubkeys,
    audience,
    ['https://cloud.google.com/iap']
  );
  
  const payload = ticket.getPayload();
  
  return payload?.email;
};

Expected Behavior

I expected the verifySignedJwtWithCertsAsync method to successfully validate the IAP JWT token and for my function to return the user's email.

Actual Behavior

The method is throwing a TypeError - Invalid RSA public key error.

Additional Information

runtime: deno
deno version: 1.39.1
google-auth-library-nodejs version: 9.4.1
@ericmalen ericmalen added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Jan 9, 2024
@danielbankhead danielbankhead added the external This issue is blocked on a bug with the actual product. label Jan 22, 2024
@danielbankhead
Copy link
Contributor

I believe this is an upstream issue in Deno:

Today, we don't officially support Deno, however we have a tracking issue for support:

@danielbankhead danielbankhead closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external This issue is blocked on a bug with the actual product. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants