如何在Apache 2.2中完成“AuthType None”

时间:2010-04-14 23:02:37

标签: authentication apache2.2

http://httpd.apache.org/docs/trunk/mod/mod_authn_core.html#authtype谈到“AuthType None”,并且有一个很棒的例子,说明我需要做什么 - 不幸的是,它似乎是2.3 / 2.4的新功能。 2.2中是否有任何等效功能?

  

身份验证类型无禁用   认证。身份验证时   启用后,通常会继承   每个后续配置部分,   除非有不同的身份验证类型   已指定。如果没有身份验证   期望的一个小节   认证部分,   认证类型无可使用;   在以下示例中,客户端可以   访问/ www / docs / public目录   没有验证:

<Directory /www/docs> 
AuthType Basic
AuthName Documents
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user 
</Directory>

<Directory /www/docs/public>
AuthType None
Require all granted
</Directory>

6 个答案:

答案 0 :(得分:99)

下面的内容适用于apache 2.2。我是从http://httpd.apache.org/docs/2.2/mod/core.html#require

取的
<Directory /www/docs>
    AuthType Basic
    AuthName Documents
    AuthBasicProvider file
    AuthUserFile /usr/local/apache/passwd/passwords
    Require valid-user 
</Directory>
<Directory /www/docs/public>
    # All access controls and authentication are disabled
    # in this directory
    Satisfy Any
    Allow from all
</Directory>

答案 1 :(得分:8)

你只需要设置全部允许和满足任何

这对我有用:

Alias /example "/opt/example.com"

<Directory "/opt/example.com">
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
  Satisfy Any
</Directory>

答案 2 :(得分:7)

<Directory /www/docs/public>
AuthType None
Require all granted
Satisfy Any
</Directory>

这将有效

答案 3 :(得分:2)

只是想添加这些信息:

在Apache 2.2.22上,您需要让订单正确才能正常工作:

这对我来说不适用于位置&#34; / foo / sub&#34;:

Satisfy Any
Allow from all

即来自位置的认证&#34; / foo&#34;在&#34; / foo / sub&#34;之前定义;仍被应用。

这适用于位置&#34; / foo / sub&#34;:

Allow from all
Satisfy Any

即。来自位置&#34; / foo&#34;的身份验证在&#34; / foo / sub&#34;之前定义;被取消了。

答案 4 :(得分:1)

我认为你是对的:apache 2.2不支持它。

我会在https://issues.apache.org/bugzilla/show_bug.cgi?id=10932

尝试丑陋的解决方法

类似的东西:

<DirectoryMatch "^/www/docs/(?!public)"> 
AuthType Basic
AuthName Documents
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user 
</Directory>

<DirectoryMatch "^/www/docs/[^p][^u][^b][^l][^i][^c]"> 
AuthType Basic
AuthName Documents
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user 
</Directory>

答案 5 :(得分:1)

这对我来说对apache2.2:

    <Location /trac>
       #....
       AuthType Basic
       AuthName "BLA domain"
       AuthUserFile /etc/.passwd
       Require valid-user
       Allow from all
       Satisfy Any
    </Location>