Apache2 Auth dbd - 数据库中的md5哈希密码,但apache将其与原始密码进行比较。

问题描述 投票:1回答:1

我在Apache2中遇到了通过pgsql进行身份验证的问题,连接数据库成功,如果我在密码字段中输入哈希值,它就会被验证,但我如何让apache2.4将数据库密码与本地插入的密码进行比较?连接到数据库是成功的,如果我在密码字段中输入哈希值,它就会被验证,但我如何使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 "[email protected]"
    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个回答
1
投票

找到答案了。

Apache自己解析密码,在密码前加{SHA1}或$apr1$即可。

AuthDBDUserPWQuery "SELECT CONCAT('{SHA}',parool_sha1) as password FROM _usr WHERE email = %s"
© www.soinside.com 2019 - 2024. All rights reserved.