【问题标题】:Apache2 Auth dbd - md5 hashed password in database, but apache compares it with rawApache2 Auth dbd - 数据库中的 md5 哈希密码,但 apache 将其与原始密码进行比较
【发布时间】:2015-08-15 22:01:41
【问题描述】:

我在通过 pgsql 在 Apache2 中进行身份验证时遇到问题。与数据库的连接成功,如果我将散列放入密码字段,它会通过身份验证,但是如何让 apache 2.4 将数据库密码与本地插入的尚未散列的密码进行比较。我想我必须将身份验证哈希方法放入 md5,但由于某种原因文档有些不完整。

<Location "/something">
    Header add Pragma "must-revalidate no-cache"
    Header add X-RequestTime "%t %D"
    ExpiresActive on
    ExpiresDefault "now"

    AuthName "Something"
    AuthType Basic 
    AuthUserFile "L:\Docs\mgrpass.txt" #does not take usernames and passwords
     #from there anymore. Takes them from database instead.

    Order allow,deny
    Allow from all

    SetEnv ERR_MAIL "sysadmin@mywebsite.com"
    SetEnv SCHEMA   "manager"
    SetEnv AUTHTYPE "manager"

    AuthBasicProvider socache dbd
    AuthnCacheProvideFor dbd
    AuthnCacheContext myServer

    # Here should be some hash config to convert local password
    # to md5 encrypted one... Help please :(

    Require valid-user

    AuthDBDUserPWQuery "SELECT parool as password FROM _usr WHERE email = %s"

    SetEnv "FORMAT"     "json"

    php_flag pgsql.log_notice off
    php_flag magic_quotes_gpc off
    php_flag output_buffering off
    php_admin_flag safe_mode_gid on

    Header add X-Timing "%D microseconds"
</Location>

【问题讨论】:

    标签: hash config basic-authentication apache2.4


    【解决方案1】:

    找到了答案。

    Apache 自己解析密码。只需在密码前添加 {SHA1} 或 $apr1$

    AuthDBDUserPWQuery "SELECT CONCAT('{SHA}',parool_sha1) as password FROM _usr WHERE email = %s"
    

    【讨论】:

      猜你喜欢
      • 2017-08-05
      • 1970-01-01
      • 2016-03-06
      • 2021-09-27
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      • 1970-01-01
      • 2023-03-29
      相关资源
      最近更新 更多