-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Upgrade to django5 #13210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Upgrade to django5 #13210
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
8d2c7e4
Upgrade to django5
mattiagiupponi 14ec9e0
Merge branch 'master' of github.com:GeoNode/geonode into ISSUE_13122
mattiagiupponi 605922f
Upgrade to django5
mattiagiupponi 0d115a4
Upgrade to django5
mattiagiupponi f1fefe5
Upgrade to django5
mattiagiupponi 962e1c4
Merge branch 'master' of github.com:GeoNode/geonode into ISSUE_13122
mattiagiupponi ea629c8
Upgrade to django5
mattiagiupponi c642e17
Upgrade to django5
mattiagiupponi 79d822f
Upgrade to django5
mattiagiupponi b809bed
Upgrade to django5
mattiagiupponi 2fef765
Merge branch 'master' of github.com:GeoNode/geonode into ISSUE_13122
mattiagiupponi c102301
Upgrade to django5
mattiagiupponi b888984
Upgrade to django5
mattiagiupponi fdf6d9b
merge with master
mattiagiupponi 33fbda1
merge with master
mattiagiupponi 4110462
merge with master
mattiagiupponi 6ffdf01
Fixes #13122 django5 upgrade
mattiagiupponi 394af2e
Fixes #13122: Added Pbk2sha1 hasher migration from sha1
sijandh35 ff7847d
Fixes #13122: solved not null voilation on test case fail due to null…
sijandh35 cd1bb93
Fixes #13122: changes from assertQuerysetEqual to assertQuerySetEqual
sijandh35 bdc09f3
Fixes #13122: disable the session serialization for service handler w…
sijandh35 c526ca6
Fixes #13122: test case for migrations of sha password
sijandh35 f381e17
Merge branch 'master' into ISSUE_13122
sijandh35 58c0da9
Fixes #13122: boto3 back to previous
sijandh35 d26724f
Fixes #13122: solves 'LoginRequiredMiddleware' object has no attribut…
sijandh35 a0df6dc
Fixes #13122: solves 'LoginRequiredMiddleware' object has no attribut…
sijandh35 467450b
Fixes #13122: remove unnecessary import
sijandh35 a1320d9
Fixes #13122: commented reason on middlewaremixin for test case fail …
sijandh35 ef715a0
Fixes #13122: add super call to resolve ansync issue on MiddlewareMixin
sijandh35 226f788
Fixes #13122: add super call to resolve ansync issue on MiddlewareMixin
sijandh35 80fb10e
[Fixes #13122] Fix unwanted changes
mattiagiupponi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import hashlib | ||
| import math | ||
| from django.utils.translation import gettext_noop as _ | ||
| from django.utils.crypto import ( | ||
| RANDOM_STRING_CHARS, | ||
| constant_time_compare, | ||
| ) | ||
| from django.contrib.auth.hashers import PBKDF2SHA1PasswordHasher, BasePasswordHasher | ||
|
|
||
|
|
||
| def mask_hash(hash, show=6, char="*"): | ||
| """ | ||
| Return the given hash, with only the first ``show`` number shown. The | ||
| rest are masked with ``char`` for security reasons. | ||
| """ | ||
| masked = hash[:show] | ||
| masked += char * len(hash[show:]) | ||
| return masked | ||
|
|
||
|
|
||
| def must_update_salt(salt, expected_entropy): | ||
| # Each character in the salt provides log_2(len(alphabet)) bits of entropy. | ||
| return len(salt) * math.log2(len(RANDOM_STRING_CHARS)) < expected_entropy | ||
|
|
||
|
|
||
| class SHA1PasswordHasher(BasePasswordHasher): | ||
| """ | ||
| This is the legecy SHA1 password hasher which will be removed in future releases. | ||
| """ | ||
|
|
||
| algorithm = "sha1" | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def encode(self, password, salt): | ||
| self._check_encode_args(password, salt) | ||
| hash = hashlib.sha1((salt + password).encode()).hexdigest() | ||
| return "%s$%s$%s" % (self.algorithm, salt, hash) | ||
|
|
||
| def decode(self, encoded): | ||
| algorithm, salt, hash = encoded.split("$", 2) | ||
| assert algorithm == self.algorithm | ||
| return { | ||
| "algorithm": algorithm, | ||
| "hash": hash, | ||
| "salt": salt, | ||
| } | ||
|
|
||
| def verify(self, password, encoded): | ||
| decoded = self.decode(encoded) | ||
| encoded_2 = self.encode(password, decoded["salt"]) | ||
| return constant_time_compare(encoded, encoded_2) | ||
|
|
||
| def safe_summary(self, encoded): | ||
| decoded = self.decode(encoded) | ||
| return { | ||
| _("algorithm"): decoded["algorithm"], | ||
| _("salt"): mask_hash(decoded["salt"], show=2), | ||
| _("hash"): mask_hash(decoded["hash"]), | ||
| } | ||
|
|
||
| def must_update(self, encoded): | ||
| decoded = self.decode(encoded) | ||
| return must_update_salt(decoded["salt"], self.salt_entropy) | ||
|
|
||
| def harden_runtime(self, password, encoded): | ||
| pass | ||
|
|
||
|
|
||
| class PBKDF2SHA1WrappedSHA1PasswordHasher(PBKDF2SHA1PasswordHasher): | ||
| """ | ||
| A password hasher that wraps SHA1 hashes in a PBKDF2SHA1 hash. | ||
| """ | ||
|
|
||
| algorithm = "pbkdf2sha1_wrapped_sha1" | ||
|
|
||
| def encode_sha1_hash(self, sha1_hash, salt, iterations=None): | ||
| return super().encode(sha1_hash, salt, iterations) | ||
|
|
||
| def encode(self, password, salt, iterations=None): | ||
| _, _, sha1_hash = SHA1PasswordHasher().encode(password, salt).split("$", 2) | ||
| return self.encode_sha1_hash(sha1_hash, salt, iterations) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from django.db import migrations | ||
|
|
||
| from geonode.people.hashers import PBKDF2SHA1WrappedSHA1PasswordHasher | ||
|
|
||
|
|
||
| def forwards_func(apps, schema_editor): | ||
| User = apps.get_model("people", "Profile") | ||
| users = User.objects.filter(password__startswith="sha1$") | ||
| hasher = PBKDF2SHA1WrappedSHA1PasswordHasher() | ||
| for user in users: | ||
| algorithm, salt, sha1_hash = user.password.split("$", 2) | ||
| user.password = hasher.encode_sha1_hash(sha1_hash, salt) | ||
| user.save(update_fields=["password"]) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("people", "0036_merge_20210706_0951"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(forwards_func), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.