使用 MySQL 身份验证设置 SVN 服务器

使用 MySQL 身份验证设置 SVN 服务器

最近几天,我一直在尝试使用 MySQL 身份验证来设置我的家庭 SVN 服务器。我相信我已经安装了所有应用程序,并希望一切都配置正确……但它仍然不起作用。

我正在运行 Debian 服务器、svn 1.5.1 和 apache2。这是我的 dav_svn.conf 文件:

<Location /svn>
  DAV svn
  SVNParentPath /var/svn-repos
  AuthBasicAuthoritative Off

  # our access control policy
  AuthzSVNAccessFile /var/svn-access/accessfile

  AuthMYSQL on
  AuthMySQL_Authoritative on
  AuthMySQL_DB svn
  AuthMySQL_Password_Table users
  AuthMySQL_Username_Field login
  AuthMySQL_Password_Field pass
  AuthMySQL_Empty_Passwords off
  AuthMySQL_Encryption_Types Crypt_MD5

  # try anonymous access first, resort to real
  # authentication if necessary.
  Satisfy Any
  Require valid-user

  AuthType Basic
  AuthName "Subversion repository"
  #AuthUserFile /var/www/svn-access/htpasswdsvnrepos
</Location>

我真的不知道应该在“accessfile”中放什么,但也许有人可以为我解释一下。

我的日志中出现以下错误:

==> access.log <==
10.0.1.1 - - [25/Aug/2010:17:20:00 +0200] "GET /svn/project_wombat HTTP/1.1" 401 384 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"

==> error.log <==
[Wed Aug 25 17:20:00 2010] [error] [client 10.0.1.1] Failed to load the AuthzSVNAccessFile: An authz rule refers to group '@project_wombat', which is undefined

==> access.log <==
10.0.1.1 - paulp [25/Aug/2010:17:20:03 +0200] "GET /svn/project_wombat HTTP/1.1" 401 384 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"

==> error.log <==
[Wed Aug 25 17:20:03 2010] [error] Internal error: pcfg_openfile() called with NULL filename
[Wed Aug 25 17:20:03 2010] [error] [client 10.0.1.1] (9)Bad file descriptor: Could not open password file: (null)

除了这些问题之外,我想在 mysql db 中定义哪些用户可以访问哪些存储库。

这是我的数据库设置:

CREATE TABLE IF NOT EXISTS `groups` (
  `gid` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`gid`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

CREATE TABLE IF NOT EXISTS `usergroup` (
  `uid` int(10) unsigned NOT NULL default '0',
  `gid` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`uid`,`gid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `users` (
  `uid` int(10) unsigned NOT NULL auto_increment,
  `login` varchar(20) NOT NULL default '',
  `pass` varchar(60) NOT NULL default '',
  `firstname` varchar(255) NOT NULL default '',
  `lastname` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`uid`),
  UNIQUE KEY `login` (`login`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

谁能帮助我,也许能给我指明正确的方向?

问候,保罗·皮伦

答案1

我现在让它工作了。

我仍然无法使项目分组正常工作,但那是以后的问题。

我使用了 drupal 用户表布局(不要问我为什么!;))这是我的 dav_svn.conf:

<Location /svn>
    DAV svn
    SVNParentPath /var/svn-repos
    Order Deny,Allow
    Allow from All

    # basic settings
    AuthType Basic
    AuthName "Stare SVN Server"
    Auth_MySQL On
    Auth_MySQL_Authoritative On

    # work-around for "Bad file descriptor"
    AuthUserFile /dev/null
    AuthBasicAuthoritative Off

    #MySQL DB
    Auth_MySQL_Host localhost
    Auth_MySQL_DB "svn"
    Auth_MySQL_User "root"
    Auth_MySQL_Password "password"

    #User Tables
    Auth_MySQL_Password_Table "users"
    Auth_MySQL_Username_Field "name"
    Auth_MySQL_Password_Field "pass"
    Auth_MySQL_Encryption_Types PHP_MD5
    Auth_MySQL_Empty_Passwords off

    #Group Tables
    Auth_MySQL_Group_Table "users, users_roles"
    Auth_MySQL_Group_Field users_roles.rid

    #WHERE Clauses
    Auth_MySQL_Password_Clause " AND status = 1"
    Auth_MySQL_Group_Clause " AND users_roles.uid = users.uid"

    #read access
    <Limit GET PROPFIND OPTIONS REPORT>
        Require valid-user
    </Limit>

    #write access
    <LimitExcept GET PROPFIND OPTIONS REPORT>
        # change this to the rid of the role you allow to commit
        Require group 4
    </LimitExcept>

</Location>

/P

相关内容