Recommended way to login using external user database

843 views
Skip to first unread message

digithill

unread,
Jul 14, 2010, 3:27:12 AM7/14/10
to Joomla! General Development
Hi all,

I am trying to log users into Joomla using an external database, and
just wondered if there was a recommended way to do this without
hacking around at the core code.

The steps I have taken so far, are to created a new Authentication
plugin (using example.php as a base) that uses SOAP to validate the
username and password.

This step seems to work fine, but this is where I get stuck and need
some pointers.

What else needs to be done to ensure that the user can access
'Registered' level pages during the session. At present the login form
redirects back to itself, even though I am setting $response->status =
JAUTHENTICATE_STATUS_SUCCESS within the new Authentication plugin;.

Do I need to create a new User plugin, and if so how do I tell Joomla
to use this new lugin rather than the default.

I would be grateful of any help with this.

Thanks in advance.

Prasit Gebsaap

unread,
Jul 14, 2010, 4:39:42 AM7/14/10
to joomla-de...@googlegroups.com
Hi,
            You still have to create user in Joomla! (jos_users) and assigned them 'registered' group. If you want to create user in Joomla database on the fly you can do in your plugin.
 
Cheers,
Prasit Gebsaap

 

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


Azamat Tokhtaev

unread,
Jul 14, 2010, 4:42:43 AM7/14/10
to joomla-de...@googlegroups.com
Thats right. You still need to create a new user in Joomla.

2010/7/14 Prasit Gebsaap <prasit....@gmail.com>



--
Life Be Good mon

Sam Moffatt

unread,
Jul 14, 2010, 7:52:26 AM7/14/10
to joomla-de...@googlegroups.com
Joomla! will automatically create a user so long as the relevant
fields in the response are filled out:
- Name
- Email
- Username

Obviously you need to return a success code as well but you've gotten
that far. You should also set the plugin type as well but that
information isn't particularly deeply used in core (though others
could use it if they wanted to). If you set those, Joomla! will
automatically create a new registered user for anyone that you
authenticate and assign them to the registered user group. Joomla!
won't store their password and also won't let you update it if it has
created them from an external authentication source.

Check out the LDAP and GMail plugins for working examples, GMail is
perhaps the easier code example.

Sam Moffatt
http://pasamio.id.au

digithill

unread,
Jul 14, 2010, 8:54:40 AM7/14/10
to Joomla! General Development
Thanks everyone this is a great help and much appreciated.

I have found the autoregister code in the User plugin, and also
noticed this:

// No existing user and autoregister off, this is a temporary user.
$instance->set( 'tmp_user', true );.

I tried to disabled autoregister in Global config to see if I could
authenticate with the external database and then login as a temp user,
but autoregister always seems to be enabled. Is this a bug in 1.5.18?

When I manually set autoregister = false in the User plugin I am able
to authenticate and login as a temp user.

Obviously its not ideal that I am hacking a core plugin, but is there
any other downsides to logging in my users as temp users?

Thanks again for all your help.

Martin


On Jul 14, 12:52 pm, Sam Moffatt <pasa...@gmail.com> wrote:
> Joomla! will automatically create a user so long as the relevant
> fields in the response are filled out:
> - Name
> - Email
> - Username
>
> Obviously you need to return a success code as well but you've gotten
> that far. You should also set the plugin type as well but that
> information isn't particularly deeply used in core (though others
> could use it if they wanted to).  If you set those, Joomla! will
> automatically create a new registered user for anyone that you
> authenticate and assign them to the registered user group. Joomla!
> won't store their password and also won't let you update it if it has
> created them from an external authentication source.
>
> Check out the LDAP and GMail plugins for working examples, GMail is
> perhaps the easier code example.
>
> Sam Moffatthttp://pasamio.id.au
>
>
>
> On Wed, Jul 14, 2010 at 5:27 PM, digithill <em...@digithill.co.uk> wrote:
> > Hi all,
>
> > I am trying to log users into Joomla using an external database, and
> > just wondered if there was a recommended way to do this without
> > hacking around at the core code.
>
> > The steps I have taken so far, are to created a new Authentication
> > plugin (using example.php as a base) that uses SOAP to validate the
> > username and password.
>
> > This step seems to work fine, but this is where I get stuck and need
> > some pointers.
>
> > What else needs to be done to ensure that the user can access
> > 'Registered' level pages during the session. At present the login form
> > redirects back to itself, even though I am setting $response->status =
> > JAUTHENTICATE_STATUS_SUCCESS within the new Authentication plugin;.
>
> > Do I need to create a new User plugin, and if so how do I tell Joomla
> > to use this new lugin rather than the default.
>
> > I would be grateful of any help with this.
>
> > Thanks in advance.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> > To post to this group, send an email to joomla-de...@googlegroups.com.
> > To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/joomla-dev-general?hl=en-GB.- Hide quoted text -
>
> - Show quoted text -

Ian MacLennan

unread,
Jul 14, 2010, 9:01:35 AM7/14/10
to joomla-de...@googlegroups.com
Autoregister is a parameter of the Joomla! User Plugin IIRC.

Ian

digithill

unread,
Jul 14, 2010, 9:17:09 AM7/14/10
to Joomla! General Development
Brilliant, thanks Ian!
> > joomla-dev-gene...@googlegroups.com<joomla-dev-general%2Bunsubs­cr...@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/joomla-dev-general?hl=en-GB.- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Joomla! General Development" group.
> > To post to this group, send an email to
> > joomla-de...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > joomla-dev-gene...@googlegroups.com<joomla-dev-general%2Bunsubs­cr...@googlegroups.com>
> > .
> > For more options, visit this group at

Sam Moffatt

unread,
Jul 14, 2010, 9:17:16 AM7/14/10
to joomla-de...@googlegroups.com
Extensions -> Plugin Manager -> User - Joomla -> Plugin Params on the
right. Toggle autocreate to your hearts content.

Temporary users aren't stored in the database so whilst they are
logged in they don't have a persistent user record. If you're only
after people to look at things this will suffice however if you
require them to interact (add stuff/edit stuff/etc) it would make more
sense to leave autoregister on and have Joomla! create the user record
for them. This will give them a persistent user ID and is the
equivalent of creating them by hand. It also then tracks when they
last accessed the site and when they first connected.

Cheers,

Sam Moffatt
http://pasamio.id.au

digithill

unread,
Jul 14, 2010, 10:33:40 AM7/14/10
to Joomla! General Development
Thanks Sam for the great explanation, and thanks everyone else for
your contributions...its all really helped me.

Cheers,

Martin

On Jul 14, 2:17 pm, Sam Moffatt <pasa...@gmail.com> wrote:
> Extensions -> Plugin Manager -> User - Joomla -> Plugin Params on the
> right. Toggle autocreate to your hearts content.
>
> Temporary users aren't stored in the database so whilst they are
> logged in they don't have a persistent user record. If you're only
> after people to look at things this will suffice however if you
> require them to interact (add stuff/edit stuff/etc) it would make more
> sense to leave autoregister on and have Joomla! create the user record
> for them. This will give them a persistent user ID and is the
> equivalent of creating them by hand. It also then tracks when they
> last accessed the site and when they first connected.
>
> Cheers,
>
> Sam Moffatthttp://pasamio.id.au
>
> >> > > athttp://groups.google.com/group/joomla-dev-general?hl=en-GB.-Hide quoted
Reply all
Reply to author
Forward
0 new messages