Score:0

Apache 2.4 ignoring basic authentication

es flag

I'm currently searching a solution to re-enable basic authentication with .htpasswd file in Apache 2.4. Everything was ok using Apache 2.2 and then I upgraded to MAMP Pro 6.4 that implements Apache 2.4. The authentication is now just ignored.

I understood that the key thing is the Directory content of the httpd.conf file.

Currently, it is configured like that :

<Directory "/Users/Shared/Shared_Items/hostname.domain.eu">  
        Options Indexes Includes FollowSymLinks  
        AllowOverride All  
        Require all granted  
        AuthType Basic  
AuthName "Munki Repository"  
AuthUserFile /Users/Shared/Shared_Items/hostname.domain.eu/munki_repo/.htpasswd    
Require valid-user
</Directory>  

So I just added the 4 latest lines in the GUI and the app creates the whole thing.

I tried many solutions suggested and found nothing that works.

I really doubt that there's a bug in Apache 2.4 that prevents totally the usage of basic authentication.

digijay avatar
mx flag
Does it work if you remove `Require all granted`?
djdomi avatar
za flag
The Question is a bit ugly formatted, but due to fact, I can't edit as I have too much pending I already added an answer
Franck Sartori avatar
es flag
@digijay : You genius ! In MAMP Pro, when you unselect the option "(Require) all granted", it changes the line to "Require host localhost". And then the authentication is working as expected ! Many thanks !
digijay avatar
mx flag
Glad I could help!
Score:1
za flag

`This is a complete working Virtalhost, you have to adapt it to your Solution.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/html">
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
    </Directory>
</VirtualHost>
Franck Sartori avatar
es flag
Thank you also, I have now a straightforward solution but I keep your solution on my notes !
djdomi avatar
za flag
if it is solved and I did it not answered, please add on your own the answer and mark it as solution as else the question is open and seeking answers for the next decade
Score:0
es flag

In MAMP, I disabled the option "Require all granted" as suggested by digijay and then in the configuration file, the option is automatically set to "Require host localhost". Then the basic authentication works from a remote client (not on the server locally but this is ok like that).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.