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

Secure passwords #25

Merged

Conversation

krishnasharmak05
Copy link
Contributor

Closes #11

  • Title : Hash the password during login and signup
  • Name: Krishna Sharma K
  • Idenitfy yourself: SSOC Contributor

Describe the add-ons or changes you've made 📃

Give a clear description of what have you added or modifications made

I have done the following:

  • Created a file called encrypt.py in page/auth folder which contains two functions - secure_password and check_password. secure_password returns the hash of the password, which is done using argon2 hashing algorithm. The check_password function verifies whether the hashed password stored in the database and the password entered during login are the same.
  • Secured the passwords entered during signup using the secure_password function and checked the secured password against the repeat password before approving the signup request.
  • Enabled checking of the password entered during login with the password stored in the database to enable successful login.
  • Replaced the plaintext passwords in the database with the new hashed passwords for User, Admin and Super Admin as given in the README file.

Type of change ☑️

What sort of change have you made:

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested? ⚙️

I throughly tested the changes by creating new users, and logging them in (See screenshot below).

Checklist: ☑️

  • My code follows the Contributing Guidelines & Code of Conduct of this project.
  • This PR does not contain plagiarized content.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly wherever it was hard to understand.
  • My changes generate no new warnings.

Screenshots 📷

SignUp testing 👇

SignUp testing

Login testing 👇
Login testing

Copy link

Thank you for submitting your pull request! We'll review it as soon as possible. For further communication, join our discord server https://discord.gg/tSqtvHUJzE.

Copy link
Owner

@Avdhesh-Varshney Avdhesh-Varshney left a comment

Choose a reason for hiding this comment

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

@krishnasharmak05 don't change db, revoke it. And you have hashing the password but on during login, you have to verifying the password using hash codes?

@Avdhesh-Varshney Avdhesh-Varshney added bug 🐛 Something isn't working Requested Changes ⚙️ Some changes have been requested in this PR labels Jun 12, 2024
@krishnasharmak05
Copy link
Contributor Author

@krishnasharmak05 don't change db, revoke it. And you have hashing the password but on during login, you have to verifying the password using hash codes?

  1. If I revoke the database, signups and logins will fail because the hashed passwords (checked against the user’s password field in the database) will be in the format $argon2id$..., while the database will contain plaintext passwords. What’s the purpose of hashing passwords if they’re stored in plaintext? If you have an alternative idea, @Avdhesh-Varshney , please share it so that I can implement it.

  2. Yes, I’ve implemented and tested code that verifies user passwords during login. It uses hash codes stored in the database.

Copy link
Owner

@Avdhesh-Varshney Avdhesh-Varshney left a comment

Choose a reason for hiding this comment

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

@krishnasharmak05 PR Approved 🎉

@Avdhesh-Varshney Avdhesh-Varshney merged commit 02b5e4f into Avdhesh-Varshney:main Jun 15, 2024
1 check passed
@Avdhesh-Varshney Avdhesh-Varshney added Intermediate Intermediate level issues/pull requests SSOC These issue/pull request will be considered for SSOC'24 Approved ✔️ This PR is approved by the PR or, Mentors enhancement 🧑‍💻 New feature or request and removed bug 🐛 Something isn't working Requested Changes ⚙️ Some changes have been requested in this PR labels Jun 15, 2024
@krishnasharmak05 krishnasharmak05 deleted the secure-passwords branch June 19, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved ✔️ This PR is approved by the PR or, Mentors enhancement 🧑‍💻 New feature or request Intermediate Intermediate level issues/pull requests SSOC These issue/pull request will be considered for SSOC'24
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hash the password during login and signup
2 participants