I trying to decode some JWT tokens using Python 3 and AWS Lambda@Edge.
Here are the limitations and restrictions:
- AWS Lambda@Edge limits the code to be a maximum of 1 MB (zipped). This includes all third party packages
- I must use Firebase's Public PEM Certificate: https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com
There is a list of libraries available on
One of the problems that I am facing is that there are only two Python libraries on jwt.io which are less than 1MB when zipped: python-jose (573KB) and pyJWT (42KB).
Python-jose accepts PEM certificates to verify JWT claims (works locally, but not on AWS Lambda). Here is the issue: https://github.com/mpdavis/python-jose/issues/133
The solution to the issue with Python-jose which I am experiencing on AWS Lambda is to install the library/package "cryptography", but this package in itself is (3.6MB), which won't work out with AWS Lambda.
The problem with pyJWT is that it does not accept PEM certificates, so another package is required to get that to work, which breaks one of our limits.
So the question and challenge is: How can I verify JWT claims from Firebase tokens in Python 3 without having to install any third party libraries above 1MB in size?