Cognito: Validate password in NEW_PASSWORD_REQUIRED (#6174)
This commit is contained in:
parent
f424c6ac05
commit
bbb07b4e7e
@ -1474,6 +1474,9 @@ class CognitoIdpBackend(BaseBackend):
|
|||||||
if challenge_name == "NEW_PASSWORD_REQUIRED":
|
if challenge_name == "NEW_PASSWORD_REQUIRED":
|
||||||
username: str = challenge_responses.get("USERNAME") # type: ignore[assignment]
|
username: str = challenge_responses.get("USERNAME") # type: ignore[assignment]
|
||||||
new_password = challenge_responses.get("NEW_PASSWORD")
|
new_password = challenge_responses.get("NEW_PASSWORD")
|
||||||
|
if not new_password:
|
||||||
|
raise InvalidPasswordException()
|
||||||
|
self._validate_password(user_pool.id, new_password)
|
||||||
user = self.admin_get_user(user_pool.id, username)
|
user = self.admin_get_user(user_pool.id, username)
|
||||||
|
|
||||||
user.password = new_password
|
user.password = new_password
|
||||||
|
@ -132,7 +132,7 @@ def test_admin_create_user_without_authentication():
|
|||||||
data = {
|
data = {
|
||||||
"UserPoolId": user_pool_id,
|
"UserPoolId": user_pool_id,
|
||||||
"Username": "test@gmail.com",
|
"Username": "test@gmail.com",
|
||||||
"TemporaryPassword": "12345678",
|
"TemporaryPassword": "A!1a12345678",
|
||||||
}
|
}
|
||||||
res = test_client.post(
|
res = test_client.post(
|
||||||
"/",
|
"/",
|
||||||
@ -148,7 +148,7 @@ def test_admin_create_user_without_authentication():
|
|||||||
data = {
|
data = {
|
||||||
"ClientId": client_id,
|
"ClientId": client_id,
|
||||||
"AuthFlow": "USER_PASSWORD_AUTH",
|
"AuthFlow": "USER_PASSWORD_AUTH",
|
||||||
"AuthParameters": {"USERNAME": "test@gmail.com", "PASSWORD": "12345678"},
|
"AuthParameters": {"USERNAME": "test@gmail.com", "PASSWORD": "A!1a12345678"},
|
||||||
}
|
}
|
||||||
res = test_client.post(
|
res = test_client.post(
|
||||||
"/",
|
"/",
|
||||||
@ -163,7 +163,7 @@ def test_admin_create_user_without_authentication():
|
|||||||
"ChallengeName": "NEW_PASSWORD_REQUIRED",
|
"ChallengeName": "NEW_PASSWORD_REQUIRED",
|
||||||
"ChallengeResponses": {
|
"ChallengeResponses": {
|
||||||
"USERNAME": "test@gmail.com",
|
"USERNAME": "test@gmail.com",
|
||||||
"NEW_PASSWORD": "abcdefgh",
|
"NEW_PASSWORD": "A!1aabcdefgh",
|
||||||
},
|
},
|
||||||
"Session": session,
|
"Session": session,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user