feat: implement password_reset_required flag and enforcement logic#16252
feat: implement password_reset_required flag and enforcement logic#16252BasavarajBankolli wants to merge 4 commits intoansible:develfrom
Conversation
There was a problem hiding this comment.
I don't actually believe this works. The model is auth.User, meaning that it comes from the django.contrib app. And this migration is for the main app, basically the AWX app.
The User model being in an app we don't control has been a major thorn in our sides for a long time. But it is difficult to change.
There was a problem hiding this comment.
Thanks for catching that, @AlanCoding. You're right trying to migrate a field into django.contrib.auth from the main app is asking for trouble.
To avoid fighting the built-in User model, I'll pivot to creating a UserProfile (or similar) model in the main app with a OneToOneField to User. This keeps the migration within our control while still allowing us to track the password_reset_required flag. I’ll update the enforcement logic to check user.profile.password_reset_required instead.
|
@BasavarajBankolli I'm not involved in this project. |
|
@AlanCoding |
SUMMARY
This PR implements a "Force Password Reset" feature. It adds a
password_reset_requiredboolean field to the User model, allowing administrators to flag accounts that must change their password before they can access the rest of the API.Design Decisions:
auth.Usermodel viaadd_to_classinawx/main/models/__init__.pyto ensure it is a native attribute of the user.getmethod inUserDetailview. If the flag isTrue, the API returns a403 Forbiddenwith a JSON body indicating a reset is required. This signal allows the frontend to redirect the user to the password change page.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
This change provides a way for security administrators to ensure credentials are rotated when suspected compromise occurs or as part of a standard security policy.
Verification performed:
0205_add_password_reset_flag.py) to handle the database schema update.UserSerializerto ensure the field is accessible and writable by administrators.