AEM provides SAML Authentication Module built-in which can be configured as Service Provider (SP) to authenticate, for instance, with  your corporate Identity Provider (IdP). Please go over the terminologies of SAML for a good understanding of how the SP and IdP interacts and exchanges information using SAML protocol.

Following are the pre-requisites that you need to do or have it handy before you start configuring on the AEM Side

1.  Register your Service Provider (SP) with the IdP –  Service Providers needs to be registered with the IdP for the IdP to recognise the SAML request that is being sent by the Service Provider.  There are two pieces of information that are typically required by the IdP for registration. Please check with your IdP Provider if they require more information :

  1. Service Provider Entity Id  –  Eg.  – Used by IdP to uniquely identify the Service Provider (This information is sent by SP in the SAML Request that is sent to the IdP)
  2. Service Provider Redirect URL –  Eg. –  IdP, upon authentication sends POSTs the SAML response to this URL. For AEM,  the SAML response needs to be sent to /saml_login as  the SAML Authentication Handlers seems to be written to process SAML for this specific URL pattern.

Make sure to provide this information to the folks managing the IdP before you start sending SAML Request.

2. IdP’s information  – You will need to have keep few information of IdP handy to configure AEM

  1. IdP URL  – URL of the IDP where the SAML Authentication Request should be sent to (quoting AEM’s documentation) – This is where the SAML Request will be sent by AEM
  2. IdP’s Public Certificate –   This is required to sign the SAML request that is sent to IdP from the AEM.  Download copy of the certificate in PEM certificate format (example idp.pem) in your local before getting started.

3. SAML Tracer Plug-in for Firefox (Optional) –  This is a very handy Firefox Add-on to see the SAML Request and Response

4. Enable debug logs for the SAML Authenticate Handlers –  Create new configuration under Apache Sling Logging Logger Configuration (configuration screenshot below)

Enable SAML Log


Configuring SAML Authentication Handler on AEM – Its a three step process

Following configurations are done on AEM Instance, say Publisher, to enable to use SAML

1. Import IdP Public Certificate to binary property “idp_cert”  on /etc/keys/saml  –

  1. Create the node structure –  /etc/key/saml in the repository
  2. Run the following command from where you have the “idp.pem” (2.2 of the pre-requisite) certificated downloaded

curl -u admin:admin -F idp_cert=\<idp.pem -F idp_cert@TypeHint=Binary http://<hostname>:4503/etc/key/saml

saml idp key


2. Configure Adobe Granite 2.0 Authentication Handler

Navigate to  “Adobe Granite SAML 2.0 Authentication Handler” Configuration through /system/console/configMgr and provide the following configurations

  1. Path – Provide “/”  or specific URL pattern “/content/private/”  – based on where you want this Authentication Handler to be applied
  2. IDP URL – Information that you have from pre-requisite 2.1
  3. Service Provider Entity Id – This is the same Id provided to the IdP (pre-requisite 1.1) to uniquely identify this AEM SP (Example –
  4. UserID Attribute (optional) –   This is useful if you would enable autoCreateUser. The exact value of this can be obtained from your IdP or can be looked at the SAML Response

Screen Shot 2014-10-26 at 11.58.08 am

3. Configure Apache Sling Referrer Filter

IdP upon successful authentication sends SAML Response to the Service Provider to the URL already provided to the IdP (ref pre-requisite 1.2). Now, the URL of the IdP which does the POST will need to be added to the Sling Referrer filter for the AEM to accept this request.

1.  Edit “Apache Sling Referrer Filter” configuration from /system/console/configMgr

2. Allowed Host – Add your IdP’s hostname


That should be it on the configuration and you should be ready to go at this point.. 

Following are the rough sequence that can be observed in the handshake between the IdP and SP during the Authentication process

1.  Hit any authenticated URL on your AEM publisher  (open the SAML Tracker Firefox plug-in to observe the SAML Request being sent to the IdPURL)

2. The users browser should get redirected to the IdP Login Page

3.  User keys in credentials and submits –  User gets authenticated at the IdP

4. Idp redirects  to the /saml_login of the AEM with the SAML response

5. AEM SAML Authenticator module intercepts the /saml_login url and extracts the userid and creates users in the repository if autoCreateUser is enabled

 Debugging tips

  • saml.log is the key if the redirection to IdP and back is working fine and there is a failure during redirection to /saml_login. There are several checks on the SAML Authentication Handler to make sure that the SAML response is valid and the signatures match, failures or warning messages are logged on debug mode.
  • SAML Trace FF plug-in is key to see if your Service Provider Id etc sent from AEM is configured correctly
  • If IdP does not recognise the request going in from your SP one of the check that can be done is on the IdP Certificate, make sure the key value is correct. Also, something can be incorrect on the IdP side during registration of SP (id, redirect url).

Please provide your comments if you find it useful or any suggestions that you may have to the content. Thanks!