Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
0d9ff873
Kaydet (Commit)
0d9ff873
authored
Kas 10, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27467 -- Made UserAttributeSimilarityValidator max_similarity=0/1 work as documented.
Thanks goblinJoel for the report and feedback.
üst
45e01df3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
password_validation.py
django/contrib/auth/password_validation.py
+1
-1
passwords.txt
docs/topics/auth/passwords.txt
+4
-5
test_validators.py
tests/auth_tests/test_validators.py
+16
-1
No files found.
django/contrib/auth/password_validation.py
Dosyayı görüntüle @
0d9ff873
...
...
@@ -147,7 +147,7 @@ class UserAttributeSimilarityValidator(object):
continue
value_parts
=
re
.
split
(
r'\W+'
,
value
)
+
[
value
]
for
value_part
in
value_parts
:
if
SequenceMatcher
(
a
=
password
.
lower
(),
b
=
value_part
.
lower
())
.
quick_ratio
()
>
self
.
max_similarity
:
if
SequenceMatcher
(
a
=
password
.
lower
(),
b
=
value_part
.
lower
())
.
quick_ratio
()
>
=
self
.
max_similarity
:
try
:
verbose_name
=
force_text
(
user
.
_meta
.
get_field
(
attribute_name
)
.
verbose_name
)
except
FieldDoesNotExist
:
...
...
docs/topics/auth/passwords.txt
Dosyayı görüntüle @
0d9ff873
...
...
@@ -545,11 +545,10 @@ Django includes four validators:
is used: ``'username', 'first_name', 'last_name', 'email'``.
Attributes that don't exist are ignored.
The maximum similarity the password can have, before it is rejected, can
be set with the ``max_similarity`` parameter, on a scale of 0 to 1.
A setting of 0 will cause all passwords to be rejected, whereas a setting
of 1 will cause it to only reject passwords that are identical to an
attribute's value.
The minimum similarity of a rejected password can be set on a scale of 0 to
1 with the ``max_similarity`` parameter. A setting of 0 rejects all
passwords, whereas a setting of 1 rejects only passwords that are identical
to an attribute's value.
.. class:: CommonPasswordValidator(password_list_path=DEFAULT_PASSWORD_LIST_PATH)
...
...
tests/auth_tests/test_validators.py
Dosyayı görüntüle @
0d9ff873
...
...
@@ -124,7 +124,22 @@ class UserAttributeSimilarityValidatorTest(TestCase):
max_similarity
=
0.3
,
)
.
validate
(
'testclient'
,
user
=
user
)
self
.
assertEqual
(
cm
.
exception
.
messages
,
[
expected_error
%
"first name"
])
# max_similarity=1 doesn't allow passwords that are identical to the
# attribute's value.
with
self
.
assertRaises
(
ValidationError
)
as
cm
:
UserAttributeSimilarityValidator
(
user_attributes
=
[
'first_name'
],
max_similarity
=
1
,
)
.
validate
(
user
.
first_name
,
user
=
user
)
self
.
assertEqual
(
cm
.
exception
.
messages
,
[
expected_error
%
"first name"
])
# max_similarity=0 rejects all passwords.
with
self
.
assertRaises
(
ValidationError
)
as
cm
:
UserAttributeSimilarityValidator
(
user_attributes
=
[
'first_name'
],
max_similarity
=
0
,
)
.
validate
(
'XXX'
,
user
=
user
)
self
.
assertEqual
(
cm
.
exception
.
messages
,
[
expected_error
%
"first name"
])
# Passes validation.
self
.
assertIsNone
(
UserAttributeSimilarityValidator
(
user_attributes
=
[
'first_name'
])
.
validate
(
'testclient'
,
user
=
user
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment