April 27, 2020
Estimated Post Reading Time ~

Enabling basic authentication for specific website in dispatcher

Create a file dispatcher.htaccess in the dispatcher.
Create the required users by using the following commands.

htpasswd -c /etc/httpd/conf/dispatcher.htaccess user1

Add the following configurations to the httpd.conf, change the site URL and AuthUserFile accordingly:

# unsets authorization header when sending a request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/en* auth=1
AuthName "Please login to access English part"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
# first, allow everybody
Order Allow, Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auth

This will enable the basic authentication for the website path starts with /content/en

If the site is enabled for https then add the following content to the ssl.conf file

<Location />
# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/en* auths=1
AuthName "Please login to access english part"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auths
</Location>


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.