[horde] how to determine horde username from a different app

Michael J Rubinsky mrubinsk at horde.org
Thu Oct 18 04:26:43 UTC 2012


Quoting Uttiya Chowdhury <chowdhury_uttiya at yahoo.com>:

>> See http://wiki.horde.org/Doc/Dev/LegacyApps
>> though that's still for Horde 3.
>
>
> Thanks! That link, followed by some more reading got me there. I  
> used the following code to implement SSO single-sign-on in Wordpress  
> using horde authentication. This needed the use of two wordpress  
> plugins:
> * restricted-site-access (to prevent Wordpress to give access without login)
> * http-authentication (use external login mechanism)
>
> Then the code below was used in the http-authentication.php to  
> determine if anybody is logged-in and the value of username/e-mail/
>
> Tested using unreleased H5.
>

This may very well work for your purposes, but see below for some comments.

> ==
> define('HORDE_BASE',__DIR__ . '/path/to/horde');
>
> /* Horde determine username */
> require_once HORDE_BASE . '/lib/core.php';
> Horde_Registry::appInit('horde', array('authentication' => 'none',  
> 'nologintasks' => true));

Using authentication => 'none' will allow any horde unauthenticated  
user to execute this script. Given what I think you are after though,  
this is probably what you want.

> $injector=$GLOBALS['injector'];
> $identity=$injector->getInstance('Horde_Core_Factory_Identity')->create();
> global $horde_username;
> $horde_username=$identity->getDefaultFromAddress();

If what you are after is the horde *username* then this is not what  
you want. You want:

$horde_username = $GLOBALS['registry']->getAuth();

Your code will return the logged in Horde user's configured email  
address. This may or may not be populated for all logged in users, it  
is not guaranteed not to change (since the user may change their  
default identity) and, most importantly, is entered by the user. I.e.,  
there is nothing stopping userone from entering usertwo's email  
address in their identity, making it trivial for userone to look like  
usertwo from Wordpress' point of view.

-- 
mike

The Horde Project (www.horde.org)
mrubinsk at horde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6062 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.horde.org/archives/horde/attachments/20121018/118798fa/attachment.bin>


More information about the horde mailing list