CognitoIDP: Replace email with username in cogntio JWT tokens (#5652)

This commit is contained in:
Mateusz Głowiński 2022-11-10 18:08:56 +01:00 committed by GitHub
parent ea8718d402
commit 8c9838cc8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -538,7 +538,7 @@ class CognitoIdpUserPool(BaseModel):
"token_use": token_use,
"auth_time": now,
"exp": now + expires_in,
"email": flatten_attrs(self._get_user(username).attributes).get("email"),
"username": username,
}
payload.update(extra_data or {})
headers = {"kid": "dummy"} # KID as present in jwks-public.json

View File

@ -2838,6 +2838,7 @@ def test_token_legitimacy():
id_token = outputs["id_token"]
access_token = outputs["access_token"]
client_id = outputs["client_id"]
username = outputs["username"]
issuer = "https://cognito-idp.us-west-2.amazonaws.com/{}".format(
outputs["user_pool_id"]
)
@ -2851,6 +2852,7 @@ def test_token_legitimacy():
access_claims["iss"].should.equal(issuer)
access_claims["aud"].should.equal(client_id)
access_claims["token_use"].should.equal("access")
access_claims["username"].should.equal(username)
@mock_cognitoidp