Apache 授予经过身份验证的用户访问权限

Apache 授予经过身份验证的用户访问权限,apache,apache2,Apache,Apache2,我的配置文件中有以下内容: Require all granted 我在windows上运行Apache2 我不想给每个人权限-当有人试图访问服务器时,我如何调用身份验证表单 这是一个内部网应用程序,我希望任何能够访问机器的人也能访问服务器 差不多 Require valid-user 我确实试过用谷歌搜索,但没有成功。你要找的信息在这里 这是我在我的apacheconf中为我希望用户使用密码的每个目录所做的 我必须在这里输入我想要访问的每个用户的用户名,但是还有另一种方法可以管理用户,使用

我的配置文件中有以下内容:

Require all granted
我在windows上运行Apache2

我不想给每个人权限-当有人试图访问服务器时,我如何调用身份验证表单

这是一个内部网应用程序,我希望任何能够访问机器的人也能访问服务器

差不多

Require valid-user

我确实试过用谷歌搜索,但没有成功。

你要找的信息在这里

这是我在我的apacheconf中为我希望用户使用密码的每个目录所做的

我必须在这里输入我想要访问的每个用户的用户名,但是还有另一种方法可以管理用户,使用
AuthGroupFile
,但是我没有很多用户名,因为我将其用于yum存储库的简单文件服务器

<Directory "your_dir" >
  AuthType Basic
  AuthName "Restricted Access"
  # Optional line:
  AuthBasicProvider file
  AuthUserFile /usr/local/apache/passwd/passwords
  # AuthGroupFile /usr/local/apache/passwd/groups
  Require user username1 username2 username3
</Directory>
但是该文件不应该手动创建,有一个工具可以实现这一点,
htpasswd

添加新用户时,我的代码中包含以下内容:

def add_password(passwords_file,user,password)
  if File.exists? passwords_file
    unless File.readlines(passwords_file).grep(/#{user}/).size > 0
      %x[htpasswd -b #{passwords_file} #{user} #{password}]
    end
  else
    %x[htpasswd -c -b #{passwords_file} #{user} #{password}]
  end
end
希望这有帮助

def add_password(passwords_file,user,password)
  if File.exists? passwords_file
    unless File.readlines(passwords_file).grep(/#{user}/).size > 0
      %x[htpasswd -b #{passwords_file} #{user} #{password}]
    end
  else
    %x[htpasswd -c -b #{passwords_file} #{user} #{password}]
  end
end