Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
apache file authorisation fails
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
quart
n00b
n00b


Joined: 14 May 2005
Posts: 6

PostPosted: Fri May 16, 2008 2:36 pm    Post subject: apache file authorisation fails Reply with quote

Hi,

I am trying to protect a single file in a cgi-bin directory from the vqadmin package. I have a clean installation and nothing fancy yet.
This is the relevant part of /etc/apache2/vhosts.d/default_vhost.include

ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"

Code:
<Directory "/var/www/localhost/cgi-bin">
        AllowOverride AuthConfig
        Options All
        Order allow,deny
        Allow from all
</Directory>
<Files "/var/www/localhost/cgi-bin/vqadmin">
        AuthType Basic
        AuthUserFile /var/www/localhost/vqadmin.passwd
        AuthName vqadmin
        Require valid-user
</Files>


I don't get a login screen. I tried to change Files to Location, and that also didn't help. mod_auth_basic does work, as I tested it in another directory. What am I missing here?
_________________
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo VP, 1989
Back to top
View user's profile Send private message
elgato319
Guru
Guru


Joined: 15 Sep 2005
Posts: 546

PostPosted: Mon May 19, 2008 1:11 pm    Post subject: Reply with quote

I would do it like this:

add an .htaccess to the cgi-bin dir


Code:
Options Indexes
AuthType Basic
AuthUserFile /var/www/localhost/vqadmin.passwd
AuthName "vqadmin"

<Files vqadmin>
Require valid-user
</Files>
Back to top
View user's profile Send private message
quart
n00b
n00b


Joined: 14 May 2005
Posts: 6

PostPosted: Mon May 19, 2008 1:29 pm    Post subject: Reply with quote

Yes that did the trick. But why wouldn't it work from the apache configuration? I tried to put the <files></files> between the <directory> tags, and above the directory tags, all with no result. I would expect it should work. Or is this new behaviour in Apache 2.2?
_________________
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo VP, 1989
Back to top
View user's profile Send private message
quart
n00b
n00b


Joined: 14 May 2005
Posts: 6

PostPosted: Mon May 19, 2008 1:49 pm    Post subject: Reply with quote

I found it. Authorisation has to be placed inside directory tags, not the file tags, like this:

<Directory "/var/www/localhost/cgi-bin">
AllowOverride All
Options None
Order allow,deny
Allow from all
Options Indexes
AuthType Basic
AuthUserFile /var/www/localhost/vqadmin.passwd
AuthName "vqadmin"
</Directory>
<Files vqadmin>
Require valid-user
</Files>

Thanks for the help!
_________________
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo VP, 1989
Back to top
View user's profile Send private message
elgato319
Guru
Guru


Joined: 15 Sep 2005
Posts: 546

PostPosted: Tue May 20, 2008 6:13 am    Post subject: Reply with quote

I don't think this is a new feature from apache2. Glad you could get it working :)

http://httpd.apache.org/docs/2.2/en/mod/core.html#files
Quote:

Note that <Files> can be nested inside <Directory> sections to restrict the portion of the filesystem they apply to.
Back to top
View user's profile Send private message
quart
n00b
n00b


Joined: 14 May 2005
Posts: 6

PostPosted: Tue May 20, 2008 7:20 am    Post subject: Reply with quote

elgato319 wrote:
I don't think this is a new feature from apache2. Glad you could get it working :)

http://httpd.apache.org/docs/2.2/en/mod/core.html#files
Quote:

Note that <Files> can be nested inside <Directory> sections to restrict the portion of the filesystem they apply to.


Yeah I know, I was just my own fault ... Thanks for your help anyways, much appreciated!
_________________
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo VP, 1989
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum