The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP5 - Confirming a new user (simple questions)
Discuss Confirming a new user (simple questions) in the PHP Development forum on Dev Shed. Confirming a new user (simple questions) PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 11th, 2013, 01:37 PM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 25
  
Time spent in forums: 23 h 47 m 32 sec
Reputation Power: 0
|
|
|
PHP5 - Confirming a new user (simple questions)
I have a few questions regarding a person registering for my site.
I have the php code working, but I want to make sure there are no major loop holes that I might have missed.
Here's my confirmation page where I have $passkey generated by a random unique MD5 string. I figure my registration password is much stronger than that and all I am doing is trying to make sure the person is who they say they are. Am I wrong in thinking this way? or do I need to do something stronger?
Here is a snippet of my confirmation page that retrieves the confirmation number from the database. I can supply more code if needed:
PHP Code:
$confirmed = 0;
if (isset($_GET['passkey'])) {
// Passkey that got from link
$passkey=htmlspecialchars($_GET['passkey']);
// Confirm the New User
$confirmed = get_confirmation_code($passkey);
if ($confirmed == 1){
set_comfirmed_code($confirmed, $passkey);
echo "Congrats, You have been validated!";
} else {
echo "I'm sorry, but I can't validate you.";
}
}
My last question is should I have some kind of CAPTCHA? I heard pros and cons over the years on this. I remember running a bbs a long time ago and creating a system similar to this, I wrote a routine where my bbs would actually call back the person's telephone number to verify them. Writing this sure has sure brought back those memories...talk about the fun I had back then.
Thanks John
|

March 11th, 2013, 03:27 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
Hi,
I don't quite understand your question. OK, you have randomly generated confirmation key. And now what? What do you mean by "my registration password is much stronger than that"?
The key factors to security are a strong pseudo-random number generator and a good password hashing algorithm. When you talk about MD5, that already makes be doubtful.
As to the CAPTCHA, yeah, you'll probably need it to fight off bot registrations.
|

March 11th, 2013, 04:10 PM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 25
  
Time spent in forums: 23 h 47 m 32 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by Jacques1 Hi,
I don't quite understand your question. OK, you have randomly generated confirmation key. And now what? What do you mean by "my registration password is much stronger than that"?
The key factors to security are a strong pseudo-random number generator and a good password hashing algorithm. When you talk about MD5, that already makes be doubtful.
As to the CAPTCHA, yeah, you'll probably need it to fight off bot registrations. |
Maybe if I reword it I can make myself clearer (I hope), My Registration Password has a good algorithm and a strong pseudo-random number generated. It doesn't use MD5. Does the confirmation number need to be the same? (Rewording the what I mean I think I probably answered my own question and that is probably yes - I wished the internet was like a BBS where a telephone line is hardwired.  ).
Thanks for the help.
John
|

March 11th, 2013, 04:34 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Quote: | Originally Posted by Strider64 My Registration Password has a good algorithm |
Which one? If it's some "special algorithm" that you need to keep secret, this would be a bad sign.
Quote: | Originally Posted by Strider64 and a strong pseudo-random number generated. |
Which algorithm do you use?
Quote: | Originally Posted by Strider64 Does the confirmation number need to be the same? |
You mean if the confirmation number has to be the user password? No! It mustn't be, because this would mean sending the password via e-mail (which isn't a secure channel, as we all know). It also means that the password will reside in the inbox for an indefinite time.
The confirmation key is a separate random string not related to the password in any way. Its only purpose is allow a secure account confirmation (in order to make sure the e-mail address is correct).
|

March 11th, 2013, 07:53 PM
|
 |
Lost in code
|
|
|
|
|
A confirmation/activation key doesn't need to be hashed at all, it just has to be random and sufficiently long. There's no benefit to hashing it besides the fact that PHP's hashing functions are a fairly simple way of converting a random string of bits into ASCII so that you can pass it through a URL.
If the activation link automatically logs the user in, just make sure you protect against brute force guessing of activation keys though.
CAPTCHAs are usually put on the sign up form, I haven't seen too many on an activation form.
|

March 11th, 2013, 08:13 PM
|
|
Registered User
|
|
Join Date: Mar 2013
Posts: 21
Time spent in forums: 5 h 27 m 59 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by E-Oreo PHP's hashing functions are a fairly simple way of converting a random string of bits into ASCII so that you can pass it through a URL.
If the activation link automatically logs the user in, just make sure you protect against brute force guessing of activation keys though. |
I agree. When generating the hash be sure to use something that is at least as random as mt_rand().
That is probably sufficient for an activation link, since those typically expire after a short time anyway.
If you want a more secure way to generate the activation string:
Code:
$bytes = openssl_random_pseudo_bytes(32);
$activationString = bin2hex($bytes);
But on a busy site, there may be performance implications of generating 256-bit encryption grade random numbers.
|

March 11th, 2013, 10:21 PM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 25
  
Time spent in forums: 23 h 47 m 32 sec
Reputation Power: 0
|
|
I first like to say Thanks for everyone that help, it has answer a lot of my questions.
While I'm at it, I just want to clear a few things up, I never used my password in any manner and as a matter of fact I have modified the "How to program a basic but secure login system" Tutorial that E-Oreo posted here.
I developed a simple random number generator that I will be using for my verification code or a modified version. I know from past experience not to touch the password as much of possible. I think of it having its own file cabinet that no other variable can touch. I have been testing this on my local server and so far so good. I will not post on my web server until I'm 99 percent sure it is secure. Though nothing is really 100 percent secure.
I know years ago running a BBS (Bulletin Board Service) that a lot of crazy things can happen and that always be on the guard for something fishy. An to expect the unexpected, you should have seen what they used to do back in the modem days. It never happen to me, but other sysops have had people make long distance calls on their bbs.  What I'll do if I see anything strange is pull the system off line, I did that to my BBS a couple of times. Hopefully though if I take the measures up front that it won't happen in the first place or have very little effect.
Anyways again thanks for the all the help and information.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|