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

feat: Disallow repeating last 5 passwords. #7552

Merged
merged 12 commits into from
Jul 9, 2024

Conversation

chriswk
Copy link
Member

@chriswk chriswk commented Jul 5, 2024

We'll store hashes for the last 5 passwords, fetch them all for the user wanting to change their password, and make sure the password does not verify against any of the 5 stored hashes.

Includes some password-related UI/UX improvements and refactors. Also some fixes related to reset password rate limiting (instead of an unhandled exception), and token expiration on error.

We'll store hashes for the last 5 passwords, fetch them all for the user
wanting to change their password, and make sure the password does not
verify against any of the 5 stored hashes.
Copy link

vercel bot commented Jul 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 9, 2024 2:03pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jul 9, 2024 2:03pm

@chriswk chriswk self-assigned this Jul 5, 2024
Copy link
Contributor

github-actions bot commented Jul 5, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@chriswk
Copy link
Member Author

chriswk commented Jul 5, 2024

I'll update the frontend to handle the new PreviouslyUsedPassword Error.

src/lib/db/user-store.ts Outdated Show resolved Hide resolved
@@ -62,6 +63,7 @@ export interface ILoginUserRequest {
}

const saltRounds = 10;
const disallowNPreviousPasswords = 5;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be configurable instead of a constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think for now we do the same as we do with salt rounds, just leave it as a constant

async setPasswordHash(
userId: number,
passwordHash: string,
disallowNPreviousPasswords: number,
Copy link
Member

@nunogois nunogois Jul 9, 2024

Choose a reason for hiding this comment

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

Should this have a default so we don't need to pass it every time?

@@ -13,6 +13,7 @@ function mergeAll<T>(objects: Partial<T>[]): T {
}

export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
getLogger.setMuteError(true);
Copy link
Member

Choose a reason for hiding this comment

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

I wonder what's this, and whether it should be included in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's muting the error logger of our test outputs, so we don't end up with tons of error logging that isn't actually an error when running tests.

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

LGTM. Left a few comments that we can optionally address.

I suggest manually going through the password screens just to confirm that the new behaviors make sense to you as well.

@chriswk chriswk merged commit f65afff into main Jul 9, 2024
14 checks passed
@chriswk chriswk deleted the feat/disallow5MostRecentlyUsedPassword branch July 9, 2024 14:18
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.

2 participants