【问题标题】:Auth MySQL with blowfish Encryption使用河豚加密验证 MySQL
【发布时间】:2012-04-03 10:26:22
【问题描述】:

我的用户名和密码存储在带有河豚加密的 mysql 数据库中。 在 php 中,我可以像这样加密密码:

crypt($pwd, _SALT_)

$pwd = 'userpwd'_SALT_ = $2a$07... 的位置

我正在寻找一种在带有mod_auth_mysql 的虚拟主机中使用用户表的方法。我知道使用 Auth_MySQL_Encryption_Types PHP_MD5 的 md5 是可能的,但我宁愿继续使用河豚。

我如何告诉 mysql_auth 使用河豚?我在哪里输入盐?

编辑:

这里的基本问题是我必须在 vhost 文件中的关键字之间使用“_”。所以它看起来像:

<Location /webdav>
AuthType Basic
AuthName "jst-development"
AuthUserFile /dev/null
AuthBasicAuthoritative Off
Auth_MySQL on
Auth_MySQL_Authoritative on
Auth_MySQL_DB user
Auth_MySQL_User user
...

而不是[取自http://modauthmysql.sourceforge.net/CONFIGURE]

AuthMySQLDB authdata
AuthMySQLUserTable user_info
AuthMySQLGroupField user_group

停止 apache 抱怨语法。有人可以告诉我原因或告诉我AuthMySQLSaltField &lt;&gt; 的“_”语法

//编辑 2: 版本:libapache2-mod-auth-mysql (4.3.9-13ubuntu1)

//编辑 3: 服务器版本:Apache/2.2.14 (Ubuntu) 使用不带“_”的“官方语法”时的确切错误: 无效的命令“AuthMySQLDB”,可能拼写错误或由服务器配置中未包含的模块定义

【问题讨论】:

  • 既然 apache 抱怨...你有哪个确切版本的 apache?也许你得到的确切错误是什么(粘贴)?
  • "无效命令 'AuthMySQLDB',可能拼写错误或由未包含在服务器配置中的模块定义" 服务器版本:Apache/2.2.14 (Ubuntu)

标签: php mysql authentication webdav virtualhost


【解决方案1】:

使用

AuthMySQLPwEncryption crypt

http://modauthmysql.sourceforge.net/CONFIGURE

AuthMySQLPwEncryption none | crypt | scrambled | md5 | aes | sha1
  The encryption type used for the passwords in AuthMySQLPasswordField:
    none: not encrypted (plain text)
    crypt: UNIX crypt() encryption
    scrambled: MySQL PASSWORD encryption
    md5: MD5 hashing
    aes: Advanced Encryption Standard (AES) encryption
    sha1: Secure Hash Algorihm (SHA1)

  WARNING: When using aes encryption, the password field MUST be a BLOB type
  (i.e.  TINYBLOB).  MySQL will strip trailing x'20' characters (blanks), EVEN
  IF THE COLUMN TYPE IS BINARY!

AuthMySQLSaltField <> | <string> | mysql_column_name

  Contains information on the salt field to be used for crypt and aes
  encryption methods.  It can contain one of the following:
    <>: password itself is the salt field (use with crypt() only)
    <string>: "string" as the salt field
    mysql_column_name: the salt is take from the mysql_column_name field in the
      same row as the password

  This field is required for aes encryption, optional for crypt encryption.
  It is ignored for all other encryption types.

【讨论】:

  • 嗯,问题是,apache 抱怨语法,所以我不得不使用 (Auth_MySQL on; Auth_MySQL_Authoritative on;...) [使用'_']。所以 AuthMySQLSaltField 不起作用。我也试过 Auth_MySQL_SaltField; Auth_MySQL_Salt_Field,...
【解决方案2】:

modauthmysql 似乎在 7 年多的时间里没有看到任何开发人员的喜爱。我目前对您的问题的猜测是这会导致您使用的 apache 2.2 出现一些不兼容问题。

在查看了我将如何解决同样的问题之后,我遇到了这个文档: http://httpd.apache.org/docs/2.2/mod/mod_authn_dbd.html

这似乎可以做你想做的事,只要你用它的所有选项正确配置它。

【讨论】:

  • 我很抱歉,但我仍然无法弄清楚:我必须告诉(SQL 语句?)用河豚加密传入的密码(输入我的 $2$.. .盐)
  • 对不起,我在 Apache 和 Mysql 方面都对此进行了深入研究。河豚是不行的。 DES 和 AES 或标准 CRYPT 以一种或另一种形式提供,当然还有 SHA1 和 MD5 散列,但这些系统似乎没有使用河豚。我还没有详细研究它,但也许 apache 中的其他身份验证模块之一将允许您指定一个可以为您解决问题的系统调用(脚本)?
  • 有趣的是,有一个使用“其他”语法的解决方案。我仍然没有弄清楚语法的区别,如果它们取决于 lib 版本或 apache2 版本
  • 恕我直言,我同意,某处存在不兼容问题。虽然在你的情况下,我会放弃河豚并使用盐渍 SHA1。无论如何,您都不希望这些密码被加密,它们仍然可以被检索到,这也不符合您的最佳利益。
  • 反正我用的是https,所以应该没问题。只是我想使用现有的用户表,其中密码以河豚加密方式存储..
【解决方案3】:

在 /usr/share/doc/libapache2-mod-auth-mysql/DIRECTIVES.gz 中查找指令

路径应该特定于您的系统,上面的路径是针对 Debian Lenny 的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-28
    • 2014-04-30
    相关资源
    最近更新 更多