Member
Member
jphilbert   2013-03-26, 16:15
#1

This might be some kind of security issue but after 2 days I have not been able to track it down.

Now it seems that it does not affect everyone but this one install of Zenphoto 1.4.4.3 will not authenticate no matter what I do even with a fresh install. I created a new user and it work temporarily then some how stopped..

Is there any insight that you can give me?


function authorize($args) {
global $_zp_authority;

$args = decode64($args);

if (!preg_match('#^1.4#', ($version = getVersion())))
    return new IXR_Error(-2, 'Zenphoto version '.$version.' but v1.4.x required!');

$_zp_authority = new Zenphoto_Authority();

$hash = $_zp_authority->passwordHash($args['loginUsername'], $args['loginPassword']);
$userobj = $_zp_authority->getAnAdmin(array('`user`=' => $args['loginUsername'], '`pass`=' => $hash, '`valid`=' => 1));
if($userobj) {
    return true;
} else {
    return new IXR_Error(-1, 'Incorrect username or password '.$args['loginUsername'].' '.$args['loginPassword']);
}

}

Member
Member
sbillard   2013-03-26, 18:51
#2

you can use the DEBUG_LOGIN define to gather more data on your problem.

But some comments on the code snippet you have posted.

is "decode64" supposed to be base64_decode?

$_zp_authority should probably already be defined unless the plugin is loading "bare" in which case you won't have other needed functions, so I doubt that is true.

Otherwise the code looks right. If you get an empty result form the getAnAdmin it means that there was no database entry that matched your parameters.

I suggest you log the input parameters to be sure they are not being corrupted.

Member
Member
jphilbert   2013-03-26, 19:10
#3

Thank you will try some things..its not my code so I have been going over every thing and cleaning it up.

Optimizing and adding new features ...so thank you for the suggestions

Member
Member
jphilbert   2013-03-26, 19:14
#4

your decode64 question


Quote:function decode64($args) {
foreach($args as $key=>$value)
$args[$key] = base64_decode($value);

    return $args;
}
Member
Member
jphilbert   2013-03-26, 19:50
#5

@sbillard
The working installation zp-1.4.4.3
["passhash"]=>

string(1) "2"

Not working zp-1.4.4.3
["passhash"]=>

string(1) "0"

The ONLY significant difference between the 2 is that passhash string any insight on this?

Member
Member
sbillard   2013-03-26, 20:08
#6

Neither of these hashes look correct. They should be fairly long strings. They are matched against the string in the pass field of the database.

The first case would work since the empty string will tend to match anything. But of course it should not be empty in the first place.

Are the user and password decoded correct?

If you set the DEBUG_LOGIN define to true the debug log will record the parameters and result of your call to passwordHash(). But it seems most likely that the Zenphoto environment has not been setup correctly.

Member
Member
jphilbert   2013-03-26, 20:40
#7

O boy did I get caught in the spam filter smh

Administrator
Administrator
fretzl   2013-03-26, 20:43
#8

Yep, you were. It's retrieved now.

Member
Member
jphilbert   2013-03-26, 21:00
#9

So studying the debug log and looking at the code again I need some clarification.


$_zp_authority->getAnAdmin(array('user=' => $args['loginUsername'], 'pass=' => $hash, 'valid=' => 1));


[passhash] changes from 0 and higher depending on some variable (the code makes sense now) but why on my other installation is my passhash 0 and not higher and my password is correct...curious

I might have to make some changes to get this to work OR see why the the other instance of Zenphoto operates differently

Member
Member
sbillard   2013-03-26, 22:01
#10

Take a look at the passwordHash function. You will see that it uses different algorithms depending on the setting for the strong_hash option. So the two installs may have different settings for this. The debug log would show this value.

I might also note that the actual value of this may be different by user, so your code would probably have to check each version (currently 0, 1, and 2) to be robust.

This is the code we use to check a logon:

foreach(Zenphoto_Authority::$hashList as $hash=>$hi) { $auth = Zenphoto_Authority::passwordHash($post_user, $post_pass, $hi); $success = ($auth == $check_auth) && $post_user == $check_user; if (DEBUG_LOGIN) debugLog("zp_handle_password($success): \$post_user=$post_user; \$post_pass=$post_pass; \$check_auth=$check_auth; \$auth=$auth; \$hash=$hash;"); if ($success) { break; } }

Member
Member
jphilbert   2013-03-26, 23:41
#11

coolness figured out the mindset once I took a look at the debug logs .. thanks for the code it should fix me fix the problem quickly ..

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.