Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
a5f3f1cb
Commit
a5f3f1cb
authored
6 years ago
by
Dillon Dumesnil
Browse files
Options
Downloads
Patches
Plain Diff
Ensuring password to be normalized is unicode
parent
3619ec0d
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/util/password_policy_validators.py
+10
-3
10 additions, 3 deletions
common/djangoapps/util/password_policy_validators.py
openedx/core/djangoapps/user_api/accounts/utils.py
+2
-0
2 additions, 0 deletions
openedx/core/djangoapps/user_api/accounts/utils.py
with
12 additions
and
3 deletions
common/djangoapps/util/password_policy_validators.py
+
10
−
3
View file @
a5f3f1cb
...
...
@@ -91,9 +91,17 @@ def password_validators_restrictions():
def
normalize_password
(
password
):
"""
Converts the password to utf-8 if it is not unicode already.
Normalize all passwords to
'
NFKC
'
across the platform to prevent mismatched hash strings when comparing entered
passwords on login. See LEARNER-4283 for more context.
"""
if
not
isinstance
(
password
,
text_type
):
try
:
# some checks rely on unicode semantics (e.g. length)
password
=
text_type
(
password
,
encoding
=
'
utf8
'
)
except
UnicodeDecodeError
:
# no reason to get into weeds
raise
ValidationError
([
_
(
'
Invalid password.
'
)])
return
unicodedata
.
normalize
(
'
NFKC
'
,
password
)
...
...
@@ -101,7 +109,7 @@ def validate_password(password, user=None):
"""
EdX
'
s custom password validator for passwords. This function performs the
following functions:
1)
Convert
s the password
to unicode if it is not already
1)
Normalize
s the password
according to NFKC unicode standard
2) Calls Django
'
s validate_password method. This calls the validate function
in all validators specified in AUTH_PASSWORD_VALIDATORS configuration.
...
...
@@ -114,8 +122,7 @@ def validate_password(password, user=None):
None
Raises:
ValidationError if unable to convert password to utf8 or if any of the
password validators fail.
ValidationError if any of the password validators fail.
"""
if
not
isinstance
(
password
,
text_type
):
try
:
...
...
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/user_api/accounts/utils.py
+
2
−
0
View file @
a5f3f1cb
"""
Utility methods for the account settings.
"""
from
__future__
import
unicode_literals
import
random
import
re
import
string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment