Forums / Developer / Custom Authentication in eZ 3.7

Custom Authentication in eZ 3.7

Author Message

Josep Mª Balcells

Wednesday 05 July 2006 9:03:34 am

Hi all,

I am a newbie in eZpublish and I would like to customize the authentication method (instead of fetching data from a DB it should be done against a web service). I've been reading documentation, "eZ feature papers" and forum messages and it seems it could be done, but I haven't found exactly how...Should I rewrite the user module? Should I write a new module and configure ezPublish in some way to use it? Anybody had a similar problem?

Thanks in advance,

Josep Mª

Philipp Kamps

Monday 17 July 2006 2:18:26 pm

You have to write you own authentication handler:

1. Edit [eZ publish root dir]/settings/site.ini

2. Look for 'LoginHandler[]' and change the value 'standard' to 'soap'

3. go to [eZ publish root dir]/kernel/classes/datatypes/ezuser/

4. create a file there 'ezsoapuser.php'

5. Start with:


class eZSOAPUser extends eZUser
{

    function eZSOAPUser()
    {
    }

    function &loginUser( $login, $password, $authenticationMatch = false )
    {
         // your custom code to access the web service
    }

}

6. make sure that your custom loginUser function returns an 'eZUser'. That also means that the user has to exist in your eZ publish installation (and not only exists for the web service you're accessing)

7. Once it is working for you I suggest that you move your code to an eZ extension. That is much more cleaner.

Hope that gives you an idea how to solve your problem. Post a reply in case you would need more help,

regards

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

Łukasz Serwatka

Monday 17 July 2006 11:34:01 pm

As extension the directory structure will be following:

extension
	|
	|---myloginhandlerext
			|
			|---login_handler
			|	|
			|	|---myloginhandler.php
			|
			|---settings
				|
				|---site.ini.append.php


In site.ini.append.php put:

<?php /*

[UserSettings]
LoginHandler[]=myloginhandler
ExtensionDirectory[]=myloginhandlerext

*/ ?>

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Norbert App

Friday 12 October 2007 4:34:53 am

Hello,

I am planning to do the same, a SOAP authentication. But what do you mean by: The user hast to exist in your ezP installation.

I am planning to do this in order not to have a second DB with all my existing customers.

Thanks

Łukasz Serwatka

Friday 12 October 2007 6:56:26 am

[...] But what do you mean by: The user hast to exist in your ezP installation. [...]

It means that you have to create user contentobject in database. Take a look on example with text login handler.

kernel/classes/datatypes/ezuser/eztextfileuser.php

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog