feat: Add strict_password_checking config option to relax password requirements#124
feat: Add strict_password_checking config option to relax password requirements#124
strict_password_checking config option to relax password requirements#124Conversation
strict_password_checking config option to relax password requirements
d6a7cf0 to
cf69418
Compare
…quirements - Add `strict_password_checking: bool = Field(default=False)` to InvokeAIAppConfig - Add `get_password_strength()` function to password_utils.py (returns weak/moderate/strong) - Add `strict_password_checking` field to SetupStatusResponse API endpoint - Update users_base.py and users_default.py to accept `strict_password_checking` param - Update auth.py router to pass config.strict_password_checking to all user service calls - Create shared frontend utility passwordUtils.ts for password strength validation - Update AdministratorSetup, UserProfile, UserManagement components to: - Fetch strict_password_checking from setup status endpoint - Show colored strength indicators (red/yellow/blue) in non-strict mode - Allow any non-empty password in non-strict mode - Maintain strict validation behavior when strict_password_checking=True - Update SetupStatusResponse type in auth.ts endpoint - Add passwordStrength and passwordHelperRelaxed translation keys to en.json - Add tests for new get_password_strength() function Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
d351e1d to
0fd4038
Compare
lstein
left a comment
There was a problem hiding this comment.
Test failure:
========================================================================== FAILURES ==========================================================================
_______________________________________________________________ test_setup_admin_weak_password _______________________________________________________________
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7a68f9c32630>, mock_invoker = <invokeai.app.services.invoker.Invoker object at 0x7a68f9d37d10>
client = <starlette.testclient.TestClient object at 0x7a68fa0f3080>
def test_setup_admin_weak_password(monkeypatch: Any, mock_invoker: Invoker, client: TestClient) -> None:
"""Test setup fails with weak password."""
monkeypatch.setattr("invokeai.app.api.routers.auth.ApiDependencies", MockApiDependencies(mock_invoker))
response = client.post(
"/api/v1/auth/setup",
json={
"email": "admin3@example.com",
"display_name": "Admin User",
"password": "weak",
},
)
> assert response.status_code == 400
E assert 200 == 400
E + where 200 = <Response [200 OK]>.status_code
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
|
@copilot ========================================================================== FAILURES ========================================================================== monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7a68f9c32630>, mock_invoker = <invokeai.app.services.invoker.Invoker object at 0x7a68f9d37d10>
E assert 200 == 400 |
... Fixed in commit 035745b. The test was failing because |
…-relax-password-checking' into copilot/enhancement-relax-password-checking
Summary
Adds a
strict_password_checkingboolean toinvokeai.yaml(default:False) that controls whether password complexity is enforced or merely reported. WhenFalse, any non-empty password is accepted and a live strength indicator (Weak/Moderate/Strong) is shown in the UI as the user types.Backend
config_default.py: Newstrict_password_checking: bool = Field(default=False)in theMULTIUSERconfig blockpassword_utils.py: Newget_password_strength(password) → Literal["weak", "moderate", "strong"]users_base.py/users_default.py:create(),update(),create_admin()acceptstrict_password_checking: bool = True; whenFalse, only requires non-empty passwordauth.pyrouter:SetupStatusResponsenow includesstrict_password_checking; all four password-touching endpoints passconfig.strict_password_checkingto the user serviceFrontend
features/auth/util/passwordUtils.tswithvalidatePasswordField()andgetPasswordStrength(), replacing three duplicated inline functionsAdministratorSetup,UserProfile,UserManagementall fetchstrict_password_checkingfrom/v1/auth/status(RTK Query, cached) and:True): existing behavior — blocks submission if requirements not metFalse): any non-empty password accepted; shows colored strength label below the fielderror.300)warning.300)invokeBlue.300)en.jsonkeys:auth.passwordStrength.{weak,moderate,strong}andauth.setup.passwordHelperRelaxedTests
TestGetPasswordStrength(11 cases) totest_password_utils.pytest_setup_admin_weak_passwordintest_auth.pyto explicitly enablestrict_password_checking = Trueon the mock config, reflecting the new default ofFalsetest_setup_admin_weak_password_non_strictto verify weak passwords are accepted when strict checking is disabled (the default)test_create_user_weak_passwordintest_user_service.pyto explicitly passstrict_password_checking=Truetest_create_user_weak_password_non_strictto verify weak passwords are accepted in non-strict modeRelated Issues / Discussions
QA Instructions
multiuser: trueand default config (strict_password_checkingabsent /false)strict_password_checking: trueininvokeai.yaml, restart, and verify weak passwords are blocked with an error message (existing behavior)Merge Plan
Checklist
What's Newcopy (if doing a release after this PR)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.