Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
vikky

Regarding User Registration

Recommended Posts

Sir,
    
    As mentioned in your book the strong password system is good. So I increased the characters required for the password from 6 to 8.

if (preg_match('/^(\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*){8,}$/', $_POST['pass1']) ) {
        

    }

To test the modification I tried to register with 6 characters password but it had not showed any error and I got registered. Then I cleared the browser's cache and restarted the Apache xampp, but again it had not showed any error and I got registered.

Then I decreased the number of password characters to 4 - it had not showed any error and I got registered.

Please guide me about this.

Thanking You,

Share this post


Link to post
Share on other sites

It's hard to say given the information provided. However, that your code uses 'pass1' suggests this isn't the registration form but rather the password update form. Are you sure you've edited the correct file?

Share this post


Link to post
Share on other sites

Hi Greetings,

    Yes Sir, this is the registration script. There are two fields for the password in the registration script (1) for the password and another (2) for the confirm password. I had posted only the modified password part of the script above. Now the complete modified password part of the script is:

// Check for a password and match against the confirmed password:
    if (preg_match('/^(\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*)
{8,}$/', $_POST['pass1']) ) {
        if ($_POST['pass1'] === $_POST['pass2']) {
            $p = $_POST['pass1'];
        } else {
            $reg_errors['pass2'] = 'Your password did not match the confirmed password!';
        }
    } else {
        $reg_errors['pass1'] = 'Please enter a valid password!';
    }

Many Thanks,

Share this post


Link to post
Share on other sites

Sorry for the delayed reply; had to take the time to set this all up on a server again. I ran the script with the 6 changed to 8 and it did also allow me to register. Then I realized it was probably because of the forward lookahead and the parens and where the minimum does and does not apply. Changing the minimum to apply to the whole grouping works better:

if (preg_match('/^((\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*)){8,}$/', $_POST['pass1']) ) {

All that being said, since I wrote this edition, both the industry and my personal feelings how validating passwords has changed. If I were to do this again today, I'd just require a minimum length (say 12 characters) and not care at all what characters are in that password. With modern computers, "thisismypassword" or "this-is-my-password" is more secure than "1Ad92q" for a number of reasons. 

Share this post


Link to post
Share on other sites

Hi Greetings,

   Thank You Sir for the guidance.

   And there is no need for sorry - I can understand you have lots of work to do.

   If I go with the latter option as you have mentioned. What could be the strongest password system and pattern for the maximum customer security.

   Thank You,

Share this post


Link to post
Share on other sites

Understanding what makes a password strong requires thinking about how passwords can be cracked. Without getting into the system itself (e.g., breaking into the database), passwords are most often cracked by brute force: trying as many possible combinations as possible. 

Dictionary attacks would be an easy way to do this: start by trying common words such as "password", etc. This is why sites wanted you to not use common words as a password, which was enforced by requiring numbers and symbols. Capital letters would also be required, so that "password" wouldn't match "Password". This wasn't an unreasonable solution at the time, but two developments have since occurred. Most importantly, computers are just crazy fast now and they can brute force millions of passwords in seconds, or milliseconds. Second, most people ended up doing number substitutions that were pretty easy to guess, like "passw0rd" or "p4ssw0rd". 

Sidenote: These systems that require numbers and symbols also inadvertently encourage bad behavior on the part of users, such as writing down the password b/c they can't be remembered. 

Given all this, how do you make passwords actually more secure? The answer is by making them longer. Each character added to the length of a password makes it exponentially harder to crack. Just using the lowercase English alphabet, a single-character password can be one of only 26 possible values. A two-character password can be 676. A three-character password can be 17,576. And so on. It's exponential. 

So requiring longer passwords is way more important than putting restrictions on what's in the password. 

Two final thoughts...

- In terms of customer security, the most important factors are out of your control: users shouldn't re-use passwords across sites and they should store them security (e.g., in a tool like 1Password). 

- Your goal shouldn't be the strongest password system or maximum customer security. Requiring passwords of at least 1,000 characters will be pretty secure--but not maximally so--but is ridiculously impractical. Your goal should be to find the right middle ground between security and user convenience for your application. This forum, for example, doesn't need very strong security, but my bank's website does. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...