-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cognito - No password validation in admin_set_user_password/sign_up #5259
Comments
Hi @JorisLimousin, will mark it as an enhancement to add validation here. If this is something you'd like to add yourself, PR's are always welcome! |
I find this interesting and I want to work on this. It would be great if I can get the approval from the owner. |
Any solution to this should add the same validation to the |
hi i want to contribute to this issue |
import re class InvalidPasswordException(Exception): def admin_set_user_password(password):
This is the code I drafted to check the validation of password, Let me know whether it is correct so that I can raise pr for this. |
Thanks @aarushisoni - the logic looks correct to me. I may have some suggestions to improve things, but I'll add them to the PR itself - that's easier to review. |
I worked very hard to solve this issue |
You should be able to raise a PR from your own fork. See this GitHub help page on how to do this: https://docs.github.com/en/get-started/quickstart/contributing-to-projects We have some tips on how to setup Moto: http://docs.getmoto.org/en/latest/docs/contributing/installation.html And, while I'm sharing links to read: if running |
I have raised this Validate Password function is added #5757. Please review it. |
i have updated changes in pr kindly review |
@bblommers could you please check my latest changes and let me know. |
@bblommers hi! Thank you for merging my pr. Can you please tell me by when the issue will be closed |
Done! Thanks again for contributing to Moto @aarushisoni |
Hi,
There is currently no password validation being performed on the
admin_set_user_password
function. (and I believe the same is applicable tochange_password
but I haven't tested it)As you can see, the password being provided is simply just put into the variable without any checks happening: https://github.com/spulec/moto/blob/d03891e80577be85a49b61cfa686222516d753e9/moto/cognitoidp/models.py#L1786
Same for
change_password
here: https://github.com/spulec/moto/blob/d03891e80577be85a49b61cfa686222516d753e9/moto/cognitoidp/models.py#L1458Passwords should be validated against the default Cognito requirements when it comes to minimum password length, (>5 characters) maximum password length (<99 characters), valid characters and against the password policy that has been configured on the user pool. (see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-policies.html)
If validations fail, it should raise either a
ClientError
exception with the codeInvalidPasswordException
, or aParamValidationError
exception. I'm not too sure I remember in which cases one is raised over the other though.The text was updated successfully, but these errors were encountered: