borisrozumnuk / cognitojwt Goto Github PK
View Code? Open in Web Editor NEWDecode and verify Amazon Cognito JWT tokens
License: MIT License
Decode and verify Amazon Cognito JWT tokens
License: MIT License
>>> import cognitojwt
>>>
>>> id_token = '<YOUR_TOKEN_HERE>'
>>> REGION = '**-****-*'
>>> USERPOOL_ID = 'eu-west-1_*******'
>>> APP_CLIENT_ID = '1p3*********'
>>>
>>> # Sync mode
>>> verified_claims: dict = cognitojwt.decode(
... id_token,
... REGION,
... USERPOOL_ID,
... app_client_id=APP_CLIENT_ID, # Optional
... testmode=True # Disable token expiration check for testing purposes
... )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'cognitojwt' has no attribute 'decode'
>>>
Hi,
I'm trying to use this on a lambda.
So I moved your package in a zip along with my function and uploaded.
Then my code is straightforward and works on my laptop - it's the same as the example:
import cognitojwt
id_token = '....'
REGION = 'us-east-2'
USERPOOL_ID = 'us-east-2_XXXX'
APP_CLIENT_ID = '5XXXXX'
verified_claims: dict = cognitojwt.decode(id_token,REGION,USERPOOL_ID, app_client_id=APP_CLIENT_ID, testmode=True)
print (verified_claims)`
However, when running to lambda i get
> "errorMessage": "module 'cognitojwt' has no attribute 'decode'",
I think this has to do with how when doing pip install cognitojwt**[sync]**, the [sync] makes something happens that is not reproduced by just moving the cognitojwt in a zip folder...
Any idea for me to investigate would be appreciated :)
I was getting AttributeError: module 'cognitojwt' has no attribute 'decode' but the actual issue was I didn't had requests installed.
try:
import requests
from .jwt_sync import decode
all.append('decode')
except ImportError:
pass
this explicit pass should be handled
cognitojwt
depends on python-jose
, which in turn depends on ecdsa
.
The latter has a high level vulnerability: GHSA-wj6h-64fc-37mp
Seems like ecdsa
is not going to fix the issue: GHSA-wj6h-64fc-37mp
And python-jose
has not had updates for ages.
Is it possible to switch from using python-jose
to any other, more frequently updated library?
For example, joserfc?
Hi Boris,
Tried this out and got this back at python console:
dict
<class 'dict'>
I can't figure out how to query this class. please advise, and suggest you add some examples in the doc.
Thank you for sharing. After installing it under a 3.6 venv :
I get this error:
In [1]: import cognitojwt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-763e27221cb4> in <module>
----> 1 import cognitojwt
~/projects/python/switch_ui_angular/venv/lib/python3.6/site-packages/cognitojwt/__init__.py in <module>
----> 1 from .async import decode_async
2 from .cognito import decode
3 from .exceptions import CognitoJWTException
4
5 name = "cognitojwt"
~/projects/python/switch_ui_angular/venv/lib/python3.6/site-packages/cognitojwt/async.py in <module>
6 from jose.utils import base64url_decode
7
----> 8 from . import PUBLIC_KEYS_URL_TEMPLATE
9 from .exceptions import CognitoJWTException
10 from .token_utils import get_unverified_headers, get_unverified_claims, check_expired, check_aud
ImportError: cannot import name 'PUBLIC_KEYS_URL_TEMPLATE'
Shouldn't the AWS_COGNITO_JWSK_PATH
environment variable be named AWS_COGNITO_
JWKS
_PATH
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.