安装完trac后如果无法登陆可能就需要设置认证方式了
使用浏览器访问该trac时,页面上方也有一个“Login”连接,但是是无法使用的,点击了会报错,提示:
“Authentication information not available. Please refer to the installation documentation.”,则需要设置用户权限和登陆方式:
一 、创建用户并分配权限
# trac-admin /项目路径/ permission add username TRAC_ADMIN
# trac-admin /项目路径/ permission list
eg: #trac-admin /home/yjl/trac permission add username TRAC_ADMIN
# trac-admin /home/yjl/trac permission add username TRAC_ADMIN
独立运行模式(Running the Standalone Server)下的认证方式:
二、设置登陆方式
Tracd 提供两种认证方式: Basic and Digest authentication.
(一)、Digest authentication.
The Digest authentication is:
$ tracd -p port --auth="base_project_dir,,realm" project_path
where:
- base_project_dir: the base directory of the project specified as follows:
- when serving multiple projects: relative to the project_path
- when serving only a single project (-s): the name of the project directory
Don't use an absolute path here as this won't work. Note: This parameter is case-sensitive even for environments on Windows.
- password_file_path: path to the password file 可以用(安装apache后)htdigest命令生成密码文件
- realm: the realm name (can be anything)
- project_path: path of the project
- --auth in the above means use Digest authentication, replace --auth with --basic-auth if you want to use Basic auth. Although Basic authentication does not require a "realm", the command parser does, so the second comma is required, followed directly by the closing quote for an empty realm name.
Examples:
$ tracd -p 8080 \ --auth="project1,/path/to/passwordfile,mycompany.com" /path/to/project1
Of course, the password file can be be shared so that it is used for more than one project:
$ tracd -p 8080 \ --auth="project1,/path/to/passwordfile,mycompany.com" \ --auth="project2,/path/to/passwordfile,mycompany.com" \ /path/to/project1 /path/to/project2
Another way to share the password file is to specify "*" for the project name:
$ tracd -p 8080 \ --auth="*,/path/to/users.htdigest,mycompany.com" \ /path/to/project1 /path/to/project2
(二)、Basic Authorization: Using a htpasswd password file
可以(安装apache后)使用htpasswd 生成密码文件
Note: It is necessary (at least with Python 2.6) to install the fcrypt package in order to decode some htpasswd formats. Trac source code attempt an import crypt first, but there is no such package for Python 2.6. Only SHA-1 passwords (since Trac 1.0) work without this module.
To create a .htpasswd file use Apache's htpasswd command (see below for a method to create these files without using Apache):
$ sudo htpasswd /path/to/env/ username
then for additional users:
$ sudo htpasswd /path/to/env/.htpasswd username2
Then to start tracd run something like this:
$ tracd -p 8080 --basic-auth="projectdirname,/fullpath/environmentname/.htpasswd,realmname" /fullpath/environmentname
For example:
$ tracd -p 8080 --basic-auth="testenv,/srv/tracenv/testenv/.htpasswd,My Test Env" /srv/tracenv/testenv
Note: You might need to pass "-m" as a parameter to htpasswd on some platforms (OpenBSD)
Web Server 模式(Running the Standalone Server)下的认证方式:
见http://192.168.89.219:8080/trac/wiki/TracModWSGI#ConfiguringAuthentication