diff --git a/README.rst b/README.rst index 01565b3..3ce6647 100644 --- a/README.rst +++ b/README.rst @@ -71,3 +71,18 @@ you can use the ``COGNITO_USER_MODEL`` setting. .. code-block:: python COGNITO_USER_MODEL = "myproject.AppUser" + + +Example authentication flow +=========================== +1) Client sends username and password to DRF using a POST request. + +2) DRF authenticates it with AWS Cognito using ``AdminInitiateAuth`` (`boto3 `_) and sends the tokens recived from AWS Congnito back to the client. + +3) Client sends request (with the recived ``IdToken`` set as the authentication header) to the API which uses ``django_cognito_jwt.JSONWebTokenAuthentication`` as the ``authentication_classes`` + +.. code-block:: python + header = {'Authorization': 'token {}'.format(authentication_result['IdToken'])} + response = requests.post("http://127.0.0.1:8000//", headers=header) + +Note: the `get_or_create_for_cognito` method of the User model needs to be implementated. (refer to: `#11 `_