Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Custom Authentication Handler Problems.

Avatar

Former Community Member

Hi guys.

I'm new to CQ and I have some questions regarding authentication handlers.

First of all, let me describe the overall problem/solution:

We will be working in a site that has a complex social logic (not related to any of the current social sites). That's why we would use AEM to administer the site's contents and another system which will handle all the complex funcionality, which will be embedded on some pages of AEM (we will use apache to access this system as a subdomain of the mail AEM domain).

Since the logic will be on the other system, we plan to encapsulate the registration/user management on it, but still want some content of AEM be displayed regarding whether or not the user is logged in. So in order to share sessions, we plan to:

a) Delegate the username/password verification on the other system (implementing a Custom Login Module).

b) Implement a Custom Authentication Handler that extracts the credentials of a JAAS based form (which will then be authenticated in our Custom Login Module), and writes a cookie in the AEM domain (requesting part of its value to the external system via some Web Service) when the "authenticationSucceeded" method is called. This way the cookie will be shared to the external system since, as explained, it will be a subdomain of the current domain.

 

We were able to deploy the Custom Login Module, but we are having some troubles developing the authentication handler. We are using the embedded crx lite to create and build the bundle (but we end up installing it from the bundles console with level 15).

When we restart the server, the bundle is installed successfully and it appears as active. It evens raises a service:

Service ID 177 Types: org.apache.sling.auth.core.spi.AuthenticationHandler, org.apache.sling.auth.core.spi.AuthenticationFeedbackHandler
Service PID: XXX
Component Name: XXX
Component ID: 49
Description: XXX
Vendor: XX

But it does not appear on the authenticators screen (http://localhost:4502/system/console/slingauth), and its methods are never called. I´ve also looked at all the implementations of Custom Authentication Handlers that I could find (even ours is based on the Form Based Authentication Handler), but I can't seem to find where the problem is. Since I'm also new to Sling and OSGi, so there might be something I'm missing (I guess with the bundle construction).

Can you please help me with this?

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

To learn how to build an AEM bundle using maven -- here are some community articles:

http://helpx.adobe.com/experience-manager/using/first-osgi.html

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

http://helpx.adobe.com/experience-manager/using/using-query-builder-api1.html

just to list a few. 

However - for a custom authentication handler - you will need to update your POM to include the given APIs. I would recommend learning how to build OSGi bundles via Maven and the Adobe Archetype and then build the custom authent bundle using this way. Also - look at the out of the box one as an example.

We will add this to the list of community articles too to give more examples around this use case. 

View solution in original post

6 Replies

Avatar

Level 6

Assuming that you have written authentication handler code correctly, Can you open config manager in Felix console corresponding to your bundle and click on save/ok and then see if you are able to see in Sling authenticator  (http://localhost:4502/system/console/slingauth)or not.

Avatar

Level 10

Here is a good community article on this subject:

http://www.wemblog.com/2013/03/how-to-create-custom-authentication.html

Any reason why you are using CRXDE lite to build the bundle? Instead, try to use Maven. 

Avatar

Former Community Member

Hi! Thanks for the reply.

I was using that same article, but it does not have many details of how to create and deploy the bundle, and if there is some extra configuration needed. I used crx since It seemed a good idea to follow the steps on the Adobe Documentation, but maybe it was not meant for a bundle like this one.

Is there a specific guide or archetype to create a bundle (with a specific directory structure)? Or my best shoot is to open one of the bundles for the other authenticators and copy the structure?

Avatar

Correct answer by
Level 10

To learn how to build an AEM bundle using maven -- here are some community articles:

http://helpx.adobe.com/experience-manager/using/first-osgi.html

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

http://helpx.adobe.com/experience-manager/using/using-query-builder-api1.html

just to list a few. 

However - for a custom authentication handler - you will need to update your POM to include the given APIs. I would recommend learning how to build OSGi bundles via Maven and the Adobe Archetype and then build the custom authent bundle using this way. Also - look at the out of the box one as an example.

We will add this to the list of community articles too to give more examples around this use case. 

Avatar

Former Community Member

It worked! Creating the plugin via Maven did the trick! Thanks very much!

Avatar

Former Community Member

I will try on this approach then, and let you know how it went.

Thanks for your help!