The Portland usability walkthrough brought up the suggestion of a password strength indicator. This would be a good idea and pretty easy to implement with jQuery. I'll probably have time to work on it in about a week.

Some links:

I think it will be best to keep the UI simple and only display three strengths: weak/moderate/strong.

CommentFileSizeAuthor
#46 password_dynamic_validation_14.patch13.02 KBChrisKennedy
#44 dynamic_password.patch12.57 KBmatt@antinomia
#39 password_dynamic_validation_13.patch12.7 KBSteven
#37 password_dynamic_validation_12.patch12.52 KBSteven
#36 password_dynamic_validation_11.patch11.45 KBChrisKennedy
#35 password_dynamic_validation_10.patch11.45 KBChrisKennedy
#34 password-validation.PNG7.06 KBChrisKennedy
#33 password_dynamic_validation_9.patch11.4 KBChrisKennedy
#29 password_dynamic_validation_8.patch10.8 KBChrisKennedy
#28 password_dynamic_validation_7.patch10.8 KBChrisKennedy
#25 password_dynamic_validation_6.patch10.78 KBChrisKennedy
#24 password_dynamic_validation_5.patch10.78 KBChrisKennedy
#23 password_dynamic_validation_4.patch10.78 KBChrisKennedy
#20 password_dynamic_validation_3.patch10.59 KBChrisKennedy
#18 password_dynamic_validation_2.patch10.6 KBChrisKennedy
#16 password_dynamic_validation_1.patch10.61 KBChrisKennedy
#15 password_dynamic_validation_0.patch10.61 KBChrisKennedy
#13 password-dynamic-validation.png2.71 KBChrisKennedy
#12 password_dynamic_validation.patch10.61 KBChrisKennedy
#11 password_strength_5.patch8.62 KBChrisKennedy
#10 Configure site_1179934760355.png10.96 KBGurpartap Singh
#9 password_strength_4.patch8.52 KBChrisKennedy
#7 password_strength_3.patch8.5 KBChrisKennedy
#5 password_strength_2.patch7.81 KBStefan Nagtegaal
#4 password_strength_1.patch7.82 KBChrisKennedy
#3 password_strength_0.patch7.73 KBChrisKennedy
#2 password_strength.patch7.72 KBChrisKennedy

Comments

ChrisKennedy’s picture

According to http://www.computerworld.com/securitytopics/security/story/0,10801,82883... ISO 17799 includes these relevant password quality standards:

  • They should be at least six characters long.
  • They should be free of consecutive identical characters.
  • Don't use all numbers or all letters.
ChrisKennedy’s picture

Status: Active » Needs review
StatusFileSize
new7.72 KB

Okay here is an initial stab at a simple implementation. Fire away. It's close to code freeze but I figured I'd give it a shot.

ChrisKennedy’s picture

StatusFileSize
new7.73 KB

Tweaked a code comment.

ChrisKennedy’s picture

StatusFileSize
new7.82 KB

A few more small tweaks.

Stefan Nagtegaal’s picture

StatusFileSize
new7.81 KB

Tweaked CSS..

margin/padding: 0px; is equal to margin/padding: 0;

0 is zero, no matter id it's ems, px, pt, or whatever...

Gurpartap Singh’s picture

Line 31 of user.js is: var newClass = cssClass[result.strength]; Now, when user clears the whole password, result has no value, hence, result.strength returns nothing and undefined class is set. It could be changed to var newClass = cssClass[result.strength] || '';.

Why is there 15px margin on left side? It looks better when it's vertically just below the starting point of the password field, i.e. margin-left: 0;.

For the strength, it never sets it to "High" unless you have a symbol is the password, even if the password is say: s1a2t3n4a5m6.

When a short password is entered, it says "Your password should be at least six characters in length for a minimum level of security.". This may even make impression that they need to provide a password of at least 6 characters length to proceed; or maybe it's just fine?

More that could be included is, let the user type the full password and then evaluate it's strength. In other words, wrap the evaluation code in setTimeout() with a timeout delay of around 400ms. Something like:

    this.timer    = undefined;

    // Monitor keyup event.
    $(this).keyup(function() {
      if (this.timer) {
        clearTimeout(this.timer);
        this.timer = undefined
      }

      this.timer = setTimeout(function() {
        // ... evaluation code ...
      }, 400);
    }

Also, the user may even paste the password using mouse. Keyup event won't detect that.

ChrisKennedy’s picture

StatusFileSize
new8.5 KB

Thanks for the review :)

1. Line 31 of user.js - fixed.
2. The password strength indicator is supposed to be to the right of the field. Did you do a hard refresh (and have aggregation disabled) to get the changes to system.css? If you did and it still shows below the field there must be a bug in the CSS - what browser?
3. Yes, it is intentional that "high strength" passwords must have punctuation. I think this is reasonable and pretty common, but I'm open to tweaking the strength estimation.
4. Good point - I modified the text to make it clear that it's a recommendation and not a requirement.
5. Added an initial delay of 600ms - seems to work well.
6. Hmm the best solution I could find is to monitor the blur event so that the password monitor is triggered after the user switches to another element. I couldn't find any events in jQuery that are triggered after a mouse-paste.

Gurpartap Singh’s picture

#2 Haven't tested it anywhere else, but installation configuration. Ubuntu/FF2.
#3 Maybe let such a password be considered as secure(highly)? Of course if alphabets and numbers both are at least 4 in number, totaling 8..?

ChrisKennedy’s picture

StatusFileSize
new8.52 KB

Okay I made it a bit narrow - does this fix it from going below the field? I also fixed a small bug in the delay handling.

Gurpartap Singh’s picture

StatusFileSize
new10.96 KB

It's still down. (1024x768 resolution).

ChrisKennedy’s picture

StatusFileSize
new8.62 KB

Okay rather than continuing to play with fixed widths, I set it to automatically go below the password field on the installation page. I changed the margin-left on the password strength div to a margin-right on the password div, so when it gets pushed down it doesn't have a weird indentation.

ChrisKennedy’s picture

Title: Password strength indicator » Dynamically check password strength & confirmation
StatusFileSize
new10.61 KB

I got some good feedback from Steven in IRC.

The expanded patch:

  1. Also checks that the password and confirmation match each other.
  2. Keeps the strength indicator to the right of the field but moves the description to below the field.
  3. Changes the timeout handling to be what Gurpartap suggested in #6 (i.e. wait until the user stops typing to check strength/confirmation).
  4. Adds borders and colored fonts to .ok and .warning so that they match .error. This will also make the clean URLs test prettier.
  5. Lots of jQuery & CSS tweaks.
ChrisKennedy’s picture

StatusFileSize
new2.71 KB

Here is an example screenshot.

profix898’s picture

+1 on a password strength indicator.
But I think the 'Your password is complex enough ...' message should be removed. Why bother the user with an additional message if everthing is OK? A simple 'strength: high' on the right should be fine in that case.

ChrisKennedy’s picture

StatusFileSize
new10.61 KB

Agreed - here is an update to not show a message for the high strength case.

ChrisKennedy’s picture

StatusFileSize
new10.61 KB

Correct patch version this time.

Gurpartap Singh’s picture

Maybe you could further have friendly messages.. and "Your password..." could be changed to "The password...". Just an opinion :)

ChrisKennedy’s picture

StatusFileSize
new10.6 KB

Sounds good and makes sense considering that the password checker is also shown on the admin user creation pages. Patch updated.

Gurpartap Singh’s picture

  • Passwords are recommended to be at least six characters in length for a minimum level of security.

    Passwords are..., it's only 1 password, with a confirmation repetition. And this, at first recommends six characters, user does put a six char. pass, and then discovers I need to put numbers, punctuation too(through messages shown on next strength level), that might be bit unexpected. Perhaps, how about something like this:

    It is recommended to choose a password that contains at least six characters and includes a number and punctuation.
    (Maybe it's a long message, but to the point imo.)

  • The password currently only contains letters. Please add a number and punctuation to strengthen it.
    How about:
    It is recommended to include numbers and punctuation in the password.
  • To increase the password's strength please add punctuation characters.
    Suggestion:
    It is recommended to include punctuation in the password.
  • The password should not be the same as the username.
    Suggestion:
    It is recommended to choose a password different from the username.

So each message's suggestion seems to be stepping down as the user keeps including each suggestion from the first message. If the strength is low, it says It is recommended to choose(a different pass or increase length)..., if medium, it would say It is recommended to include....

More:

  • Confirmation matches password.
    The password and confirmation password match. Maybe?
  • Password and confirmation do not match.
    Confirmation password mismatches. Or The password and confirmation password do not match.

2 english pennies :)

ChrisKennedy’s picture

StatusFileSize
new10.59 KB

I made all of the changes except for the confirmation strings I did:

[Good] "The confirmation is correct."
[Bad] "The password and confirmation do not match."

That way the messages have a clear visual difference and the user doesn't have to read the sentences as closely.

mfer’s picture

subscribing. I'll test this out in the next few days. I really like this functionality.

Gurpartap Singh’s picture

div.ok, tr.ok {
  background: #EDFFED none repeat scroll 0% 50%;
  padding: 2px;
}
div.ok {
  border: 1px solid #00AA00;
}
.ok {
  color: #008000;
}

This combination makes green/ok text readable on low resolution screens. But the same .ok class' color is used else where too, like on "Status report" page, there these colors look a lot fancy and bright no?

Still some suggestions:
"The confirmation is correct." -> "Password confirmed correctly."
"The password and confirmation do not match." -> "Confirmation password mismatched!" or mismatches?

Also at the very first time of installation, "Password strength:" string appeared(without any css) on right to the password field; no field wasn't touched yet. Couldn't reproduce on refresh, but I remember the same happening last time as well.

ChrisKennedy’s picture

StatusFileSize
new10.78 KB

CSS updated - I checked out the status report page and individual form errors and they both look fine with the revised CSS.

I made the passwordSuccess change but the proposed passwordFailure change sounds awkward to me. I prefer to keep the current string. But these can be modified during the code freeze once/if this feature is added beforehand.

I bet the reason "password strength" shows up initially is that your browser is caching the old CSS, which does not include the class to hide the password strength.

ChrisKennedy’s picture

StatusFileSize
new10.78 KB

Minor: added two semicolons to hopefully conform to the js aggregation patch, and changed the double-quoted translation string back to single quotes now that there isn't an apostrophe.

ChrisKennedy’s picture

StatusFileSize
new10.78 KB

Okay I did a full review of the changes to the .ok/.warning/.error classes. I didn't find any problems, although I did realize that the change to div.ok, tr.ok's background suggested in #22 was no longer needed since I had made the color darker. This version reverts that to keep the green saturated.

For future reference, here is where I found the status CSS classes used:
Ok: system.module (aggresive caching success string, status report), system.js (clean URLs test), themes.inc (theme_status_messages())
Warning: system.module (status report), system.js (clean URLs test), themes.inc (theme_status_messages())
Error: forms.inc (form errors), system.module (aggressive caching error string, status report), themes.inc (theme_status_messages())

I verified the colors are okay in both Garland and Bluemarine.

mfer’s picture

Status: Needs review » Needs work

Worked like a champ in firefox. Got nothing in safari. Though, safari is terrible with javascript.

mfer’s picture

Here's something interesting. I tested it in webtoolkit (safari backend) with Drosera (debugging tool) and it didn't show user.js being pulled into the page load. Wonder if there is something in there safari doesn't like to load.

ChrisKennedy’s picture

Status: Needs work » Needs review
StatusFileSize
new10.8 KB

Apparently Safari randomly doesn't allow javascript variables named "class." Fixed.

I also changed the failure string to "The confirmation does not match." so that it fits in one line on the installation page.

ChrisKennedy’s picture

StatusFileSize
new10.8 KB

Had an extra space in it.

dries’s picture

I've tested this and it works as advertised.

dries’s picture

The only minor gripe is that the placement of the status messages are not consistent. The "do not match" message is displayed on the side, the "too short" message is displayed below the textfield. Some errors below, some errors on the side.

It's minor and I don't have a suggestion for improvement so I decided not to mention it in first place. But maybe there are more creative people that do know how to fix this. Either way, it should not hold up this patch IMO.

Another thought that occurred to me, was that at some point, we might want to make a form type for passwords. Not sure if that's feasible with two fields but it might be worth exploring. This isn't a showstopper either.

ChrisKennedy’s picture

I partially disagree about consistency. The password strength component displays both to the right ("Password strength: low/medium/high") and bottom (extended description). The confirmation check does not really have a long enough message to *need* to go below the field.

But I do think you may have a point that the confirmation string is long enough that it might be better to move it below the field, or shorten it.

Considering that it is merely a test of equality, I am more inclined to the shortening tactic. Perhaps the message should just be "Correct" or "Incorrect", maybe with the checkmark or x-mark images from the status report displayed to the left of the message?

There is a form type for passwords: password_confirm. This patch modifies the expansion function to add specific CSS classes for the two individual fields. Although, the way FormAPI splits the password type into two elements has a bug that prevents them from being marked required.

ChrisKennedy’s picture

StatusFileSize
new11.4 KB

Revised after another round of suggestions from Steven in #drupal.

  • Added upper/lower case check to qualify for high strength.
  • Restructured the logic to display medium-strength suggestions as an unordered-list.
  • Increased the delay to 700ms (from 300ms).
  • Shortened the confirmation messages to Correct/Incorrect.

I also looked at using the watchdog icons for the confirmation message (via CSS) but they're too big for that line height.

ChrisKennedy’s picture

StatusFileSize
new7.06 KB

Here's a screenshot.

ChrisKennedy’s picture

StatusFileSize
new11.45 KB

Synced.

ChrisKennedy’s picture

StatusFileSize
new11.45 KB

I think it looks better to not end the Correct/Incorrect messages with a period, like the low/medium/high strength indicator.

Steven’s picture

StatusFileSize
new12.52 KB

Excellent eye for detail, thanks. Still, it can be improved:

  • The "medium" color should be a bit darker, to improve readability on the white background.
  • When clearing the password field, the old tips should go away immediately, not after the delay, since the user is trying a new password.
  • The delay is for dealing with typing, and should not be used when the field is blurred. This means that when you tab away from the field, the password should be checked immediately.
  • Moving the show() to after setting the CSS class and filling in the messages. In theory, there could be flicker in the old patch on really fast machines.

These are all relatively simple to fix, so I did.

I also think it is better to move the tips box to below the confirm field, since it is much tidier, means the fields don't jump around and brings it closer to the normal description.

Before: http://acko.net/dumpx/pwd1.png
After: http://acko.net/dumpx/pwd2.png

I also noticed this change:

-  background: #dfd;
+  background: #dfd none repeat scroll 0% 50%;<

Because of the way shorthand properties like background work, and because there is no image, these two rules should be entirely equivalent. Why was this added?

Finally, the CSS needed to be updated for RTL. New patch attached.

To others wondering why this is so important to get 'right': this is part of the installer, and thus part of our first impression to the user. The previous incarnations were much too "in your face" and would e.g. annoy users by giving unnecessary hints while they were still typing. This needs to be useful and clean.

ChrisKennedy’s picture

Thanks Steven, that all sounds good.

The .ok background CSS was recommended in #22 for low-resolution screens. I wasn't sure what the effect was so I just left it in.

Steven’s picture

StatusFileSize
new12.7 KB

FInal fixes:

  • A password that is long enough, but only has one 'feature' (letters, numbers or punctuation) should count as low, not medium strength.
  • Originally, the description div is visible, but empty. This causes it to take up some space. Tabbing through the fields without typing anything causes it to become invisible, and shifts everything up a bit. Hiding it from the start fixes this.
profix898’s picture

The 'Correct' string after the 'Confirm password' textfield is a little confusing. What does that mean? I guess it means that the entered strings are identical, but you cant read this from the layout or description. Otherwise looks good from a visual inspection.

dries’s picture

'Correct' might be interpreted as (1) passwords match or (2) the strength is good enough. It might be better to write 'Passwords match correctly' or just 'Passwords match: yes/no' (consistent with the other message). We're nitpicking now. ;)

wim leers’s picture

Subscribing.

jacauc’s picture

Subscribing

matt@antinomia’s picture

StatusFileSize
new12.57 KB

Nice patch! I personally think it's requiring too strong of a password in order to qualify as 'strong'... "n38f@k2d" is a very strong password, but it's only scored a 'medium'. Just my $0.02.

Rerolled tracking HEAD.

mfer’s picture

"n38f@k2d" has not uppercase letters. could be stronger ;-)

ChrisKennedy’s picture

StatusFileSize
new13.02 KB

Per Dries' comment in #41, the confirmation text is now: "Passwords match: Yes/No" to be consistent with the password strength indicator.

dries’s picture

Status: Needs review » Fixed

Tested and committed. Thanks Chris and Steven.

siaiweb’s picture

This addition is just great! Is there any chance to see it implemented into Drupal 5 ???

Crell’s picture

Extraordinarily unlikely. Once a Drupal version is released, it doesn't get any new features. If it did, it would be a new version. :-)

Gurpartap Singh’s picture

Status: Fixed » Active

There seems to be reduced side paddings. It can be observed on the first warning about status (the cron one). It's seems to be due to this patch, as it was observed the same day this was committed.

Doesn't seem intentional to me, so, marking the issue back as active.

Crell’s picture

Status: Active » Fixed

Please don't. :-) If there's a bug, please file it as a new bug. Tacking it on here only makes the thread longer and harder to read, and keeps the issue from being auto-closed.

Anonymous’s picture

Status: Fixed » Closed (fixed)
mrgoltra’s picture

subscribing

Dave Faris’s picture

Dave Faris’s picture

(posted in error. please ignore.)

mayur.pimple’s picture

md5(pass);

mayur pimple