Skip to content

Commit 0969fa8

Browse files
authored
User Password: Add toggle to require on creation (#10962)
1 parent fb41238 commit 0969fa8

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

dojo/api_v2/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def validate(self, data):
553553
if self.context["request"].method in ["PATCH", "PUT"] and "password" in data:
554554
msg = "Update of password though API is not allowed"
555555
raise ValidationError(msg)
556-
if self.context["request"].method == "POST" and "password" not in data:
556+
if self.context["request"].method == "POST" and "password" not in data and settings.REQUIRE_PASSWORD_ON_USER:
557557
msg = "Passwords must be supplied for new users"
558558
raise ValidationError(msg)
559559
else:

dojo/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ def clean(self):
21702170
class AddDojoUserForm(forms.ModelForm):
21712171
email = forms.EmailField(required=True)
21722172
password = forms.CharField(widget=forms.PasswordInput,
2173-
required=True,
2173+
required=settings.REQUIRE_PASSWORD_ON_USER,
21742174
validators=[validate_password],
21752175
help_text="")
21762176

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f7e63afa0003d1992f8247f9a7a830847bd7498fa1e2d46d6ea04e3006bb9ee2
1+
aa4ec1520b0bc612431ecb7f80a53cca997fd415ff39d8b9c718fb3fc30b2fef

dojo/settings/settings.dist.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@
304304
DD_QUALYS_LEGACY_SEVERITY_PARSING=(bool, True),
305305
# Use System notification settings to override user's notification settings
306306
DD_NOTIFICATIONS_SYSTEM_LEVEL_TRUMP=(list, ["user_mentioned", "review_requested"]),
307+
# When enabled, force the password field to be required for creating/updating users
308+
DD_REQUIRE_PASSWORD_ON_USER=(bool, True),
307309
)
308310

309311

@@ -527,6 +529,7 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
527529

528530
CLASSIC_AUTH_ENABLED = True
529531
FORGOT_PASSWORD = env("DD_FORGOT_PASSWORD")
532+
REQUIRE_PASSWORD_ON_USER = env("DD_REQUIRE_PASSWORD_ON_USER")
530533
FORGOT_USERNAME = env("DD_FORGOT_USERNAME")
531534
PASSWORD_RESET_TIMEOUT = env("DD_PASSWORD_RESET_TIMEOUT")
532535
# Showing login form (form is not needed for external auth: OKTA, Google Auth, etc.)

0 commit comments

Comments
 (0)