6.0.0-RC7
6/19/26

[#3895] Auth::get... in hooks
Summary Auth::get... in hooks
Queue Horde Base
Queue Version HEAD
Type Bug
State Resolved
Priority 1. Low
Owners jan (at) horde (dot) org
Requester adrieder (at) sbox (dot) tugraz (dot) at
Created 5/7/06 (7348 days ago)
Due
Updated 8/4/06 (7259 days ago)
Assigned 5/11/06 (7344 days ago)
Resolved 8/4/06 (7259 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
110 Jan Schneider Comment #27
State ⇒ Resolved
Reply to this comment
Auth::getAuth() is working fine for me in the current code, of course 
only in the hook run *after* the authentication.

The preferences are reloaded right before the authentication for 
technical reasons, during this run Auth::getAuth() is empty of course.
2510 stian_web (at) jordet (dot) nu Comment #26 Reply to this comment
Hi,

I am having also issues on calling Auth::getBareAuth() or
Auth::getAuth() on hooks.php. Auth::getBareAuth() worked on Horde
3.1.1, but it's broken on Horde 3.1.2.
Just a me too. Without Auth::getAuth working, we need desperately an 
alternative...
336 kimmo (dot) liikonen (at) phnet (dot) fi Comment #25 Reply to this comment
Hi,



I am having also issues on calling Auth::getBareAuth() or 
Auth::getAuth() on hooks.php. Auth::getBareAuth() worked on Horde 
3.1.1, but it's broken on Horde 3.1.2.



Reason why i need that, is that i want search from_addr from ldap 
server (with _prefs_hook_from_addr fuction). And i need username for 
search. Is there any other way to get username of current session?



I think this is major problem in bigger installations of Horde/IMP.


599 adrieder (at) sbox (dot) tugraz (dot) at Comment #24 Reply to this comment
Prefs caching was broken for a while. Can you try if your hooks get
called only on login now?
Now, they get called only once on login. But still 3 times on logout.
518 Jan Schneider Comment #23 Reply to this comment
Prefs caching was broken for a while. Can you try if your hooks get 
called only on login now?
335 Jan Schneider Comment #22 Reply to this comment
I have no idea where these double calls are coming from. I can 
reproduce them, and the weird thing is that the backtraces to both 
calls are absolutely identical and at the same time.
265 Jan Schneider Deleted Original Message
 
145 Jan Schneider Deleted Original Message
 
44 adrieder (at) sbox (dot) tugraz (dot) at Comment #21 Reply to this comment
Maybe I didn't get everything, but is there a reason why the hook
gets called 4 times at login?
No, 2 times should be sufficient, we should look into this.
Ok! Thanks for explaining.



So a short summary:

1. If a user logs in the first time on the system the hook 
"_prefs_hook_from_addr" gets called 4 times.

2. On all subsequent logins, the hook gest called 2 times.

3. On every logout the hook gets called 4 times.



p.s: please remove my "stupid" :-) patches
534 Jan Schneider Comment #20
Priority ⇒ 1. Low
Reply to this comment
As I discovered and tried to explain below, the hook is called before
the Auth object is filled. And there I get false from the various
Auth::get... calls.
That's how it is supposed to work. If entering the script you're not 
authenticated, thus Auth::getAuth() returns false. After 
authentication the prefs are reloaded for the authenticated user.
Maybe I didn't get everything, but is there a reason why the hook
gets called 4 times at login?
No, 2 times should be sufficient, we should look into this.
524 adrieder (at) sbox (dot) tugraz (dot) at Comment #19 Reply to this comment
I'm pretty sure that my configs are up to date.



As I discovered and tried to explain below, the hook is called before 
the Auth object is filled. And there I get false from the various 
Auth::get... calls.

But the hook gets recalled later on in the login process and then the 
Auth::get... calls also return the desired values.

Now that I know this, I modified the hook in the way that it just 
returns if Auth::get... returns false. Before I wasn't checking that 
and used the any returned value for doing an ldap lookup. That was 
confusing me, because of errors in the subsequent ldap lookups.



Maybe I didn't get everything, but is there a reason why the hook gets 
called 4 times at login?
313 Jan Schneider Comment #18
State ⇒ Feedback
Reply to this comment
Looking at your patches that you claim have fixed your problem, it 
looks like you didn't update your configuration.
62 adrieder (at) sbox (dot) tugraz (dot) at Comment #17 Reply to this comment
If the from_addr pref is then set in the prefs, the hook gets called
2 times, where again Auth::get... returns just false.
I mean if it is set and the user log out and in again, it is called 
twice during login.
42 adrieder (at) sbox (dot) tugraz (dot) at Comment #16 Reply to this comment
OK, on login the hook (_prefs_hook_from_addr) gets called 4 times, the 
first two times Auth::get... doesn't work, and then it works.

If the from_addr pref is then set in the prefs, the hook gets called 2 
times, where again Auth::get... returns just false.
181 adrieder (at) sbox (dot) tugraz (dot) at Comment #15 Reply to this comment
If I read the code right, they are called when the registry function 
loadPrefs() is used. It gets the preferences via $prefs->retrieve(). 
This retrieve() function uses the private method _callHooks() from the 
Prefs class.



Now there is one place in imp/login.php where loadPrefs() is called 
when the Auth object is cleared. This is when a user logs out (see 
imp/login line 92 and 93). I don't know the exact reason why it is 
called, but anyway at this point the Auth::get...() methods in th hook 
doesn't work.



It is also called via Auth::clearAuth() in which again the auth info 
from the Auth object is already removed before the loadPrefs call. 
Auth::clearAuth() is also called in imp/login.php when a user logs 
out. Therefore the hooks are called twice on a logout and I get also 
the errors twice.



I didn't figure out what happens when  a user logs in (authentication 
is done by IMP), but there it also seams to be the case that the hooks 
are called to early or are not recalled again.




403 Chuck Hagenbuch Comment #14
Assigned to Jan Schneider
State ⇒ Assigned
Reply to this comment
That doesn't look right, but it does point towards the problem - looks 
like hooks are being called before the user is authenticated, and then 
not re-called, or the session cache not being cleared, once 
authentication takes place.
111 adrieder (at) sbox (dot) tugraz (dot) at Comment #13
New Attachment: Registry.php.patch
Reply to this comment
And here the second one...
311 adrieder (at) sbox (dot) tugraz (dot) at Comment #12
New Attachment: Prefs.php.patch
Reply to this comment
The attched patches fix the problem. Any comments? Are they ok?
278 adrieder (at) sbox (dot) tugraz (dot) at Comment #11 Reply to this comment
528 Jan Schneider Comment #10 Reply to this comment
And did my fix for Prefs.php make any difference?
418 adrieder (at) sbox (dot) tugraz (dot) at Comment #9 Reply to this comment
Ok, found also the changes that cause my problem, see:

<http://marc.theaimsgroup.com/?l=horde-cvs&m=114678117806849&w=2>



If I copy back the old versions of 
"framework/Horde/Horde/Registry.php" and "framework/Prefs/Prefs.php" 
the problem is gone.


219 adrieder (at) sbox (dot) tugraz (dot) at Comment #8 Reply to this comment
Ok I found out the date now.

I used my May 2nd running version and did a incremental cvs update as follows:

cvs update -Pd  -D 20060503

           -> Auth::get... ok

cvs update -Pd  -D 20060504

           -> Auth::get... ok

cvs update -Pd  -D 20060505

           -> Auth::get... ok

cvs update -Pd  -D 20060506

           -> Auth::get...  _not ok_



maybe this helps
413 Chuck Hagenbuch Comment #7 Reply to this comment
I'm not seeing it, but I don't have a lot of hooks in my local 
install. It's not sexy, but if you could narrow the problem down to a 
specific date, and to changes in either IMP, Horde, or the framework, 
that'd be extremely helpful.
5511 adrieder (at) sbox (dot) tugraz (dot) at Comment #6 Reply to this comment
Any hint where I could start searching or debugging?

Is this reproduceable by someone else?
1410 adrieder (at) sbox (dot) tugraz (dot) at Comment #5 Reply to this comment
This was committed on April 19th, but the May 2nd version is still working.

I also tested it by installing the base.php version before this 
commit. Still the same problem.
466 adrieder (at) sbox (dot) tugraz (dot) at Comment #3 Reply to this comment
Yes, I'm running HEAD of all modules in use.

I don't know the exact date when it stopped working, but I know that 
the version of May 2nd does not show this behaviour
2512 Chuck Hagenbuch Comment #2
State ⇒ Feedback
Reply to this comment
Can you confirm you're using HEAD of everything here? If so, was there 
an update on a specific date where it stopped working?
429 adrieder (at) sbox (dot) tugraz (dot) at Comment #1
Priority ⇒ 3. High
State ⇒ Unconfirmed
Queue ⇒ Horde Base
Type ⇒ Bug
Summary ⇒ Auth::get... in hooks
Reply to this comment
When calling one of the following functions:



Auth::getBareAuth();

Auth::getCredential('password');

Auth::getAuthDomain();



within the hook _prefs_hook_from_addr or _prefs_hook_fullname, these 
calls return just "false".



I'm using IMP for handling authentications

Saved Queries