lepture / authlib

The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
https://authlib.org/
BSD 3-Clause "New" or "Revised" License
4.45k stars 445 forks source link

Add several different public keys for one Tokenvalidator, or allow several Validators for one auth_type in ResourceProtector #606

Open danilovmy opened 8 months ago

danilovmy commented 8 months ago

We use AWS Cognito for token generation. Following this, we implement ResourceProtector in various Python sources.

To verify a token, AWS provides documentation at: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-verifying-a-jwt.html AWS Cognito offers several public keys to decode a token. Among them, the key declared in the header should be used.

However, I can only define a TokenValidator with a single public key. ResourceProtector consumes only one TokenValidator for one auth_type. In the case of Cognito, I would need to hard override all classes because everything is hardcoded.

I ask to add possibility to work with couple of public keys for tocken.decode.

p.s. Translated with Chat GPT. If my ask is not clear - i can add information.