Hello,
is there any way to use a http authenticated user for zenphoto.
Here is the scenario:
I have a home nas running apache2 and want to add a web gallery. Apache2 does always a http authentication. Can zenphoto use this information to automatically login the user with the same login name?
Bye
TL
Comments
You will have to setup a Zenphoto user with the same ID and password as for the HTTP login. Then put this script into your plugins folder and enable it.
Let us know how it works out.
`
<?php
/* Tries to authorize user based on HTTP credentials
*
* @package plugins
*/
$plugin_is_filter = 5|CLASS_PLUGIN;
$plugin_description = gettext('Checks for HTTP authoized user');
$plugin_author = "Stephen Billard (sbillard)";
$plugin_version = '1.4.2';
zp_register_filter('authorization_cookie', 'http_auth_check');
function http_auth_check($authorized) {
global $_zp_authority;
if (!$authorized) {
$userobj = $_zp_authority->getAnAdmin(array('
user=' => $PHP_AUTH_USER, 'pass=' => $PHP_AUTH_PW, 'valid=' => 1));if ($userobj) {
$authorized = $userobj->getRights();
}
}
return $authorized;
}
?>
`
Many thanks. I will try it asap and report back!
i'm happy. It works very well. Thank you!
On a quick test i found only one little drawback:
You can't log off!
And, to prevent false bug reports, you should mention that this only works if the auth method used by the web server does send a cleartext password. I have configured a auth using radius and that sends the password as cleartext (using https, of course).
But, if i'm not wrong, kerberos or ntlm for example will not work.
To make that auths (and every auth else) working: If there is a remote_user available, the authentication always was successful. Can the http_auth plugin modified (maybe using a non config switch that is disabled by default) to make zp happy if only the user is set, without doing any password checks?
The documentation does say that the password must be cleartext. Currently that is only in the script header but will appear in the documentation link when the plugin makes it into a full release where we have re-generated the documents. I was not able to determine if the password is kept in cleartext for the encrypted versions or not.
The plugin can be modified fairly easily to just use the user ID. I will make that change as an option.
[edit] The option is included in the changes for tonight's build.