eZPublish SSO Handler or not...
On my last eZPublish project, i have developped a SSO handler which aim was to automatically log out a user if a session cookie is set. This experience allowed me to clarify the process which is not or hardly documented on ez.no.
Back to the roots
Little recall, the SSO(Single Sign On) is a fonctionnality very powerfull which allows the user of a heterogen applications set to log in once and be authentified on the application set without giving again his login / passsword couple.
This need appear soon enough in companies wich were installing applications for their intranet without thinking about technology or authentication management. The consequency was desastrous because the user had to handle a different login and password for each application. In order to insure the minimum consistency, the establishment of directories allowed to centralized connection data but the user had to enter it for each application.
This type of mechanism inevitably leads to one or more exchanges between a client (the application where the user is located in) and a server (the server that determines whether the user is authenticated or not). Many tools exist to manage the server side with a more or less similar approach, but I shall mention only one: CAS.
The advantage of such a service is to manage a set of authentication sources (backends) on one side (eg a MySQL database, a flat file, a LDAP, a web service ...) and an application set (frontend) on the other side. The CAS server only ensure that the application has the right to authenticate and make available all or part of the authentication sources.
The SSO established can do two things
- First to authenticate. The user arrives at website A, authenticates, gets on site B, he is automatically authenticated.
- In addition to disconnect. The user disconnects from the website, it returns to the site B where he was authenticated, he is automatically disconnected.
In summary, for a company concerned about the comfort of its users, SSO is a real revolution because it gives access to all resources with a single pair username / password and enables unified management of authentication methods.
eZPublish SSO Handler
Out of respect for my client, I do not disclose their sources even if they are a very good example of SSO management by eZPublish. We will study the integration of an SSO-type CAS or equivalent.
eZPublish has a handler that is integrated with the traditional authentication mechanism which is triggered at two points:
- When the user is not logged on any pages.
- Only when the user has authenticated through the user module and its function loginafter login authentication via a Login Handler.
I think that this feature was designed to serve as a eZPublish SSO server and not be a client of an SSO server. This means that eZPublish serves as a reference for other applications and once logged in eZPublish the SSO Handler must allow to authenticate the user directly within each application.
The SSO mechanism positions a SSO token that allows third party applications to detect whether they should contact the SSO server to check if the user is already authenticated or not. After analysis it is found to handle the following 4 cases:
| Action | SSO token existing |
SSO token not existing or invalid |
| Logged in user | Nothing is done | Case never reached |
| Logged out user | The user is logged in | Nothing is done |
As you can see, the case of automatic disconnection is never reached in eZPublish since the SSO handler is hidden behind the Login Handler in the case of the connection and is not called when the user is already authenticated. The problem is that even if you have a token out of date or even better invalid in the current application, you're never disconnected.
A palliative
The implemented solution is quite simple since it is to disconnect the user eZPublish for him to trigger again the SSO Handler. This is done simply by setting a SessionTimeoutbelow the validity of the token in the SSO configuration file site.ini. This maneuver forces eZPublish to disconnect the user . At the next page display, the user triggers the SSO handler that evaluate the invalid token and removes it.
The idea being that is that in later versions of eZPublish, eZSystems functionally correct this point.
