Skip to content
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

Adding fall back method for sha1 in case default algo is sha256 #33345

Merged
merged 4 commits into from
Oct 11, 2023

Conversation

awais786
Copy link
Contributor

@awais786 awais786 commented Sep 26, 2023

https://docs.djangoproject.com/en/3.2/ref/settings/#default-hashing-algorithm

https://docs.djangoproject.com/en/4.2/releases/4.0/#features-removed-in-4-0
The DEFAULT_HASHING_ALGORITHM transitional setting is removed.

its defined in django-global settings as 256
https://github.com/django/django/blob/stable/3.2.x/django/conf/global_settings.py#L450

Initially we were assuming that platform is going to use sha256 as default algorithm for every thing. But now we got clarity that safesessionmiddleware will use the sha1 so created new PR with new variable.

Testing steps
1. create sandbox with master branch and login on sandbox.
2. install django42 and restart lms only.
3. keep continue using the site, some middleware call that method. It will mismatch due to algorithm and logouts the user.
4. Also moving to django42 will invalidates the forgot passwords links generated via django32.

Picking SHA256 value from internal config for stage. https://github.com/edx/edx-internal/pull/9332
For production it will remain sha1.

@awais786 awais786 changed the title feat!: sha1 has been deprecated in django32 and removed in django42. sha1 has been deprecated in django32 and removed in django42. Sep 26, 2023
iamsobanjaved
iamsobanjaved previously approved these changes Sep 26, 2023
@iamsobanjaved iamsobanjaved dismissed their stale review September 27, 2023 11:04

Found multiple instances of sha1

@jmbowman
Copy link
Contributor

It looks like most/all of the sha1 instances are imported from the standard library via hashlib. We may want to revisit those to see if another hash is more appropriate, but that shouldn't block the Django upgrade.

@awais786 awais786 closed this Sep 27, 2023
@awais786 awais786 reopened this Sep 28, 2023
@awais786 awais786 closed this Sep 28, 2023
@awais786 awais786 reopened this Oct 2, 2023
@awais786 awais786 changed the title sha1 has been deprecated in django32 and removed in django42. Adding fall back method for sha1 in case default algo is sha256 Oct 3, 2023
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of minor comments around monitoring.

openedx/core/djangoapps/cache_toolbox/middleware.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/cache_toolbox/middleware.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/safe_sessions/middleware.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/safe_sessions/middleware.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/safe_sessions/middleware.py Outdated Show resolved Hide resolved
cms/envs/common.py Outdated Show resolved Hide resolved
@awais786 awais786 marked this pull request as ready for review October 3, 2023 19:01
@awais786 awais786 closed this Oct 3, 2023
@awais786 awais786 reopened this Oct 3, 2023
@iamsobanjaved
Copy link
Contributor

@robrap Just fixing tests, will then implement your suggestions regarding monitoring

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Minor comments. You don't need to wait for another round from me before approving/merging when you are ready.

openedx/core/djangoapps/cache_toolbox/middleware.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/safe_sessions/middleware.py Outdated Show resolved Hide resolved
@awais786 awais786 closed this Oct 4, 2023
@awais786 awais786 reopened this Oct 4, 2023
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok, but it is hard to review with all the test duplication, and not knowing what is changing in each case. I made a potential suggestion.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably all set with my PR. I just wanted to ensure that all cases were being covered.

robrap and others added 2 commits October 11, 2023 15:48
I was wondering about all the cases, so I
updated the test to reflect this. I also
made some other minor adjustments.
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this.

A possible deployment plan:

  1. Merge
  2. Create (and share) a small New Relic dashboard (ask if you need help). If you FACET by appName (or add separate charts for Stage), we can watch in Stage for a bit before going to Prod.
  3. Enable in Stage and ensure all is well. (Maybe leaves this for a day?)
  4. Enable in Prod.
    Thoughts?

@iamsobanjaved
Copy link
Contributor

iamsobanjaved commented Oct 11, 2023

Yeah, this is what we had in our minds for deployment. I will try to create a New Relic dashboard and surely ask for help if I will get stuck. Also merging this PR now.

@iamsobanjaved iamsobanjaved merged commit 2549035 into master Oct 11, 2023
61 checks passed
@iamsobanjaved iamsobanjaved deleted the removing-sha1 branch October 11, 2023 14:54
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@awais786 awais786 restored the removing-sha1 branch October 11, 2023 18:08
awais786 added a commit that referenced this pull request Oct 11, 2023
iamsobanjaved added a commit that referenced this pull request Oct 13, 2023
…a256` (#33345)

---------

Co-authored-by: Muhammad Soban Javed <[email protected]>
Co-authored-by: Robert Raposa <[email protected]>
Co-authored-by: Muhammad Soban Javed <[email protected]>
@iamsobanjaved iamsobanjaved deleted the removing-sha1 branch October 30, 2023 14:13
shURenZHOUluxun pushed a commit to EduTrigger/edx-platform that referenced this pull request Jan 3, 2024
…a256` (openedx#33345)

---------

Co-authored-by: Muhammad Soban Javed <[email protected]>
Co-authored-by: Robert Raposa <[email protected]>
Co-authored-by: Muhammad Soban Javed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants