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

Require password complexity #3205

Merged
merged 10 commits into from
Sep 12, 2016
Merged

Require password complexity #3205

merged 10 commits into from
Sep 12, 2016

Conversation

skofman1
Copy link
Contributor

@skofman1 skofman1 commented Aug 18, 2016

Require password complexity: atleast 8 characters, one uppercase letter, one lowercase letter, and a digit.

image

@maartenba @blowdart @yishaigalatzer @qianjun22

@@ -395,4 +395,7 @@ The {2} Team</value>
<data name="PackageCreatedFromApi" xml:space="preserve">
<value>Package created from API.</value>
</data>
<data name="PasswordValidationFailure" xml:space="preserve">
<value>Use atleast 8 characters and include one uppercase letter, one lowercase letter and a digit. </value>
Copy link
Contributor

@scottbommarito scottbommarito Aug 18, 2016

Choose a reason for hiding this comment

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

at least (missing the space) #Resolved

@scottbommarito
Copy link
Contributor

scottbommarito commented Aug 19, 2016

Correct me if I'm wrong, but this only enforces that the password is secure on registration, right? This doesn't prevent users from resetting their password to something that's not allowed on the accounts page or by following the forgot my password flow, right? #Resolved

internal static readonly Regex UsernameNormalizationRegex =
new Regex(@"[^A-Za-z0-9_\.-]");
internal const string PasswordValidationRegex =
@"^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{1,64}$";
Copy link
Contributor

@maartenba maartenba Aug 19, 2016

Choose a reason for hiding this comment

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

Comment would indeed be good, the {1,64} confuses me - Is this RegEx allowing passwords of 1 character length? #Resolved

@maartenba
Copy link
Contributor

maartenba commented Aug 19, 2016

The atleast should be updated, other than that LGTM #Resolved

@shishirx34
Copy link
Contributor

shishirx34 commented Aug 19, 2016

I'd be interested to hear answer to @scottbommarito's question above about password reset flow, other than that LGTM. #Resolved

@skofman1
Copy link
Contributor Author

Good catch :)


In reply to: 240892895 [](ancestors = 240892895)

@skofman1
Copy link
Contributor Author

skofman1 commented Aug 19, 2016

Added hints:
image
image
image

@harikmenon?

#Resolved

@harikmenon
Copy link

harikmenon commented Aug 19, 2016

We should change the text to the below. Otherwise looks good.

Your password must be at least 8 characters, should include at least one uppercase letter, one lowercase letter and a digit #Resolved

@scottbommarito
Copy link
Contributor

scottbommarito commented Aug 19, 2016

I think you're still missing the ResetPassword flow, I only see Register and Change Password.
https://github.com/NuGet/NuGetGallery/blob/master/src/NuGetGallery/ViewModels/PasswordResetViewModel.cs#L14 #Resolved

@skofman1
Copy link
Contributor Author

Thanks!


In reply to: 241141008 [](ancestors = 241141008)

@@ -53,6 +53,7 @@ public class ChangePasswordViewModel

[Required]
[Display(Name = "New Password")]
[RegularExpression(RegisterViewModel.PasswordValidationRegex, ErrorMessage = RegisterViewModel.PasswordHint)]
Copy link
Contributor

@scottbommarito scottbommarito Aug 19, 2016

Choose a reason for hiding this comment

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

Nit, but I think it would better to have a help class somewhere containing these RegEx and hints statically so we don't have ViewModels referring to other ViewModels, but it's fine to have it like that. #Resolved

Copy link

@yishaigalatzer yishaigalatzer Sep 6, 2016

Choose a reason for hiding this comment

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

+1 #Resolved

@scottbommarito
Copy link
Contributor

scottbommarito commented Aug 19, 2016

LGTM! #Closed

@skofman1
Copy link
Contributor Author

skofman1 commented Sep 6, 2016

@yishaigalatzer @harikmenon , can I merge? #Closed

@yishaigalatzer
Copy link

yishaigalatzer commented Sep 6, 2016

  1. This is going to break existing users of the gallery, I would make this configurable. Thoughts?
  2. I don't want this to sneak into a deployment, lets hold off until we can review this change with the directors next week #Closed

@skofman1
Copy link
Contributor Author

skofman1 commented Sep 6, 2016

This change won't break users. Simply, the next time they create a password, the requirements will be more severe. #Closed

[InlineData("aaAAaaAAaaAA")] // No digit
[InlineData("12345678a")] // No upperscase letter
[InlineData("12345678A")] // No lowercase letter
[InlineData("1aA")] // Too short
Copy link

@yishaigalatzer yishaigalatzer Sep 6, 2016

Choose a reason for hiding this comment

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

Add more trivial cases

single letter
single upper case letter
single number
just a number
special chars #Resolved

@skofman1
Copy link
Contributor Author

skofman1 commented Sep 7, 2016

We are considering making password complexity configurable. This will allow users deploying gallery on their own servers to control the password complexity they require from their users.
There are 2 options:

  1. Have a turn on/off flag to enforce complexity using regex as suggested in this PR (when turned off only password length will be required).
  2. Have the regex used configurable.

Do you think this feature is important for our users? Should we enforce password complexity by default to make our customers more secure, even if they have their own deployments?
Which of the options above do you prefer?

@yishaigalatzer @robertmuehsig @maartenba @xavierdecoster @dtivel @qianjun22
#Closed

@dtivel
Copy link
Contributor

dtivel commented Sep 7, 2016

An on/off flag would be useful for toggling the feature. I think a configurable regex can be implemented later based on feedback. #Closed

@yishaigalatzer
Copy link

yishaigalatzer commented Sep 7, 2016

The cost of implementing configuration is negligible, compared to a switch. Lets not push it out, either do it or not. #Closed

@xavierdecoster
Copy link
Member

xavierdecoster commented Sep 12, 2016

+1 on configurable regex with default value enforcing the rules outlined in this issue #Closed

@skofman1
Copy link
Contributor Author

skofman1 commented Sep 12, 2016

a new version: password regex was made configurable. Please review again #Closed

@@ -174,6 +174,14 @@ public class AppConfiguration : IAppConfiguration
/// </summary>
public string EnforcedAuthProviderForAdmin { get; set; }

[Required]
[DefaultValue("^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{8,64}$")]
Copy link
Contributor

@shishirx34 shishirx34 Sep 12, 2016

Choose a reason for hiding this comment

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

I think the default should be any string. That way if anyone wants to use it will set it as appropriate, or may be provide a way to disable configuration?

.*
``` #WontFix

Copy link

@yishaigalatzer yishaigalatzer Sep 12, 2016

Choose a reason for hiding this comment

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

I think the default behavior should be as specified above (unless I'm missing something). I would add a comment explaining what this regex supposed to do #Resolved

@shishirx34
Copy link
Contributor

shishirx34 commented Sep 12, 2016

Looks good. #Closed

namespace NuGetGallery.Infrastructure
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class GalleryPasswordValidationAttribute : ValidationAttribute
Copy link

@yishaigalatzer yishaigalatzer Sep 12, 2016

Choose a reason for hiding this comment

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

nit: I would call this PasswordValidationAttribute the gallery is unnecessary #Resolved

@yishaigalatzer
Copy link

:shipit: When nit comments addressed

@skofman1 skofman1 merged commit 93fa02b into dev Sep 12, 2016
@skofman1 skofman1 deleted the feature-passwordComplexity branch September 12, 2016 23:49
@maartenba maartenba mentioned this pull request Sep 30, 2016
5 tasks
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.

9 participants