DEV Community

Discussion on: JWT Authorization for serverless APIs on AWS Lambda

Collapse
 
mgligoric profile image
petar petric

This was great and really helped me, thank you!

I have one question here : If I use RS2564 algorithm to generate private and public key, and then deploy them on server with lambda's (not on Git) and read from those files like this:

const publicKey = fs.readFileSync('jwtRS256.key.pub')
// verifies token
const decoded = jwt.verify(token, publicKey, { algorithms: ['RS256'] })

Does it will be also correct?

Collapse
 
tmaximini profile image
Thomas Maximini

Hi!
Yes, this will work similarly!

  const decoded = jwt.verify(
    token,
    publicKey,
    { algorithm: 'RS256' },
  );
Enter fullscreen mode Exit fullscreen mode