jazzband / djangorestframework-simplejwt

A JSON Web Token authentication plugin for the Django REST Framework.
https://django-rest-framework-simplejwt.readthedocs.io/
MIT License
3.89k stars 655 forks source link

How setup AWS Cognito with djangorestframework-simplejwt #791

Open mateuspadua opened 3 months ago

mateuspadua commented 3 months ago

I've been trying setup AWS Cognito using JWK_URL, but not working. Is there a way to do this?

My settings.py

SIMPLE_JWT = {
    "JWK_URL": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_XXXXXXX/.well-known/jwks.json",
    "ALGORITHM": "RS256",
    "AUDIENCE": "<my cognito app client>",
    "ISSUER": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_XXXXXXX",
}

myview.py


from rest_framework_simplejwt.authentication import JWTAuthentication

class TesteViewSet(
    mixins.ListModelMixin,
    viewsets.GenericViewSet,
):
    queryset = MyModel.objects.all()
    serializer_class = TesteSerializer
    authentication_classes = [JWTAuthentication]

What more I need to do?

Tks in advance, :)

Andrew-Chen-Wang commented 3 months ago

Unfortunately, I'm not really familiar with AWS Cognito. Posting what you did in the end would be helpful:)