[Solar-talk] Alternate authentication object for Solar_User
Paul M Jones
pmjones at paul-m-jones.com
Mon Mar 17 08:33:21 CDT 2008
On Mar 16, 2008, at 19:59 , Leo Chiao wrote:
> In the current app I am developing, I need to use two distinct
> authentication sources so I am planning to use two Solar_User
> objects: one which uses the default Solar_Auth settings I have
> defined in my config file and the other with a custom config
> setting. To accomplish this, I am calling
> Solar::factory('Solar_User') with the optional $config as the second
> constructor param.
>
> For most config parameters, they are either integers or strings, but
> Solar_User expects an actual authentication object which means I
> have to specify the config via code. I just wanted to confirm that
> there isn't a more elegant way to accomplish this:
>
> if (! Solar_Registry::exists('user')) {
> Solar_Registry::set('user', Solar::factory('Solar_User'));
> }
>
> if (! Solar_Registry::exists('member')) {
> $config = array(
> 'auth' => Solar::factory('Solar_Auth',
> Solar::config('Vendor_Auth'))
> );
> Solar_Registry::set('member', Solar::factory('Solar_User',
> $config));
> }
My initial suggestion would be to write a custom authentication
adapter that examines both auth sources (called, e.g.,
Vendor_Auth_Adapter_Dual). You can then set the Solar config for
Solar_Auth to default to your custom adapter in the config file:
$config['Solar_Auth']['adapter'] = 'Vendor_Auth_Adapter_Dual';
Solar_User will automatically pick up the new adapter through its
(Solar_User's) dependency.
That way you don't need two separate user objects just to use two
different auth stores simultaneously.
Given my limited understanding of your situation, I hope that makes
sense; please let me know if it does not.
-- pmj
More information about the Solar-talk
mailing list