Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authorization failure (no authenticated user) - .htaccess error, Apache

I'm running Apache/2.4.7 (Ubuntu) Server and I'm trying to protect one of the directories 'myFolder' which is located at /var/www/html/myFolder

I made the following edits in /etc/apache2/apache2.conf file

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


<Directory /var/www/html/myFolder>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

I created .htaccess in /var/www/myFolder with the following contents

AuthUserFile /var/www/html/myFolder/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user

Also created htpasswd by

htpasswd -c /var/www/html/myFolder/.htpasswd admin

which then prompts for password.

I then try to access the file on the browser www.mydoman.com/myFolder/hello.html and it prompts for username and password. However, the authentication does not go through.

Here is the error from the error.log file

[authz_core:error] [pid 30042] [client xxx.xxx.xx.xxx:53348] AH01629: authorization failure (no authenticated user): /myFolder/hello.html

How can I resolve this issue?

like image 571
am3 Avatar asked Mar 16 '15 15:03

am3


People also ask

How do I password protect Apache with basic authentication?

The htpasswd command allows you to create a password file that Apache can use to authenticate users. You'll create a hidden file for this purpose called . htpasswd within your /etc/apache2 configuration directory. The first time you use this utility, you need to add the -c option to create the specified .

What is AuthName?

The AuthName directive sets the Realm to be used in the authentication. The realm serves two major functions. First, the client often presents this information to the user as part of the password dialog box. Second, it is used by the client to determine what password to send for a given authenticated area.


1 Answers

A loaded mod-shib2 can cause this problem. According to this bug comment, setting ShibCompatValidUser On solves it.

Require valid-user does also work with mod_shib enabled. According to https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPApacheConfig this is only necessary for shib versions 2.5.2 and above. Note that ShibCompatValidUser is a server / virtual host option.

like image 183
Kilian Röhner Avatar answered Sep 20 '22 03:09

Kilian Röhner