前面文章介绍了怎么安装trac,但是新安装的trac虽然可以在浏览器访问到,login按钮点击后,会提示:
无法登录。
下面介绍如何为项目设置用户、分配密码和权限。
1. 创建用户,分配权限
首先启动trac项目:
用trac-admin命令
先看一下命令说明:
先进入交互模式:
输入help可以看到其中有:
这样一个命令,我们用的就是他,看下他的用法
有permission list查看当前的用户和动作:
现在创建一个管理员用户,赋予他trac_admin的权限:
2. 现在创建密码
tracd 支持Basic和Digest两种身份验证方式,默认使用Digest,这种方式来源与Apache的用户管理和身份验证。
Digest方式需要一个特定格式的密码文件,可以用Apache的htdigest命令来生成密码文件。
使用htpasswd命令:
这样就在目录下生成了一个密码文件。看下文件内容:
继续为用户root创建密码,因为用同一个密码文件,命令中的 -c 选项就不要了:
3. 下面用呆验证的方式来启动trac
命令不懂,先看trac的帮助:
使用 --basic-auth 参数,启动服务器
好了,现在访问trac,点击login,输入刚才设置的用户名密码,
登录成功,以后就可以用webadmin插件来管理了。
如下图:
参考:
1. http://trac.edgewall.org/wiki/TracAdmin
2. http://trac.edgewall.org/wiki/TracStandalone
- Authentication information not available. Please refer to the installation documentation.
下面介绍如何为项目设置用户、分配密码和权限。
1. 创建用户,分配权限
首先启动trac项目:
- $ tracd --port 8000 /var/www/trac/svn/AJS
先看一下命令说明:
- [root@localhost ~] trac-admin
- trac-admin - Trac管理控制台 0.12.3
- 用法: trac-admin </path/to/projenv> [command [subcommand] [option ...]]
- 不带命令调用trac-admin将启动交互模式。
- help Show documentation
- initenv Create and initialize a new environment
- [root@localhost ~] trac-admin /var/www/trac/svn/AJS
- Welcome to trac-admin 0.12.3
- Interactive Trac administration console.
- Copyright (C) 2003-2012 Edgewall Software
- Type: '?' or 'help' for help on commands.
- Trac [/var/www/trac/svn/AJS]>
- permission add Add a new permission rule
- Trac [/var/www/trac/svn/AJS> help permission
- permission add <user> <action> [action] [...]
Add a new permission rule
permission list [user]
List permission rules
permission remove <user> <action> [action] [...]
Remove a permission rule
Trac [/var/www/trac/svn/AJS]>
Trac [/var/www/trac/svn/AJS]>permission list
用户 动作
------------------------------
anonymous BROWSER_VIEW
anonymous CHANGESET_VIEW
anonymous FILE_VIEW
anonymous LOG_VIEW
anonymous MILESTONE_VIEW
anonymous REPORT_SQL_VIEW
anonymous REPORT_VIEW
anonymous ROADMAP_VIEW
anonymous SEARCH_VIEW
anonymous TICKET_VIEW
anonymous TIMELINE_VIEW
anonymous WIKI_VIEW
authenticated TICKET_CREATE
authenticated TICKET_MODIFY
authenticated WIKI_CREATE
authenticated WIKI_MODIFY
可选动作:
BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, EMAIL_VIEW, FILE_VIEW,
LOG_VIEW, MILESTONE_ADMIN, MILESTONE_CREATE, MILESTONE_DELETE,
MILESTONE_MODIFY, MILESTONE_VIEW, PERMISSION_ADMIN, PERMISSION_GRANT,
PERMISSION_REVOKE, REPORT_ADMIN, REPORT_CREATE, REPORT_DELETE,
REPORT_MODIFY, REPORT_SQL_VIEW, REPORT_VIEW, ROADMAP_ADMIN, ROADMAP_VIEW,
SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE,
TICKET_EDIT_CC, TICKET_EDIT_COMMENT, TICKET_EDIT_DESCRIPTION,
TICKET_MODIFY, TICKET_VIEW, TIMELINE_VIEW, TRAC_ADMIN,
VERSIONCONTROL_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, WIKI_MODIFY,
WIKI_RENAME, WIKI_VIEW
可以看到匿名用户的权限,当然可应用 permission remove 来移除某些权限。
用户 动作
------------------------------
anonymous BROWSER_VIEW
anonymous CHANGESET_VIEW
anonymous FILE_VIEW
anonymous LOG_VIEW
anonymous MILESTONE_VIEW
anonymous REPORT_SQL_VIEW
anonymous REPORT_VIEW
anonymous ROADMAP_VIEW
anonymous SEARCH_VIEW
anonymous TICKET_VIEW
anonymous TIMELINE_VIEW
anonymous WIKI_VIEW
authenticated TICKET_CREATE
authenticated TICKET_MODIFY
authenticated WIKI_CREATE
authenticated WIKI_MODIFY
可选动作:
BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, EMAIL_VIEW, FILE_VIEW,
LOG_VIEW, MILESTONE_ADMIN, MILESTONE_CREATE, MILESTONE_DELETE,
MILESTONE_MODIFY, MILESTONE_VIEW, PERMISSION_ADMIN, PERMISSION_GRANT,
PERMISSION_REVOKE, REPORT_ADMIN, REPORT_CREATE, REPORT_DELETE,
REPORT_MODIFY, REPORT_SQL_VIEW, REPORT_VIEW, ROADMAP_ADMIN, ROADMAP_VIEW,
SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE,
TICKET_EDIT_CC, TICKET_EDIT_COMMENT, TICKET_EDIT_DESCRIPTION,
TICKET_MODIFY, TICKET_VIEW, TIMELINE_VIEW, TRAC_ADMIN,
VERSIONCONTROL_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, WIKI_MODIFY,
WIKI_RENAME, WIKI_VIEW
现在创建一个管理员用户,赋予他trac_admin的权限:
- Trac [/var/www/trac/svn/AJS]> permission add admin(这个是可以自己修改和添加的用户名) TRAC_ADMIN
- 可以多添加几个,根据情况而定。
- Trac [/var/www/trac/svn/AJS]>exit
- 退出。
2. 现在创建密码
tracd 支持Basic和Digest两种身份验证方式,默认使用Digest,这种方式来源与Apache的用户管理和身份验证。
Digest方式需要一个特定格式的密码文件,可以用Apache的htdigest命令来生成密码文件。
使用htpasswd命令:
- [root@localhost AJS]# htpasswd -c ./trac.htpasswd admin
- New password:
- Re-type new password:
- Adding password for user admin
- $ cat trac.htpasswd
- admin:35ttomzPLkie6
- [root@localhost AJS]# htpasswd -c ./trac.htpasswd root
- New password:
- Re-type new password:
- Adding password for user root
命令不懂,先看trac的帮助:
- [root@localhost ~]# tracd --port 8000 /var/www/trac/svn/AJS --help
Usage: tracd [options] [projenv] ...
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-a DIGESTAUTH, --auth=DIGESTAUTH
[projectdir],[htdigest_file],[realm]
--basic-auth=BASICAUTH
[projectdir],[htpasswd_file],[realm]
-p PORT, --port=PORT the port number to bind to
-b HOSTNAME, --hostname=HOSTNAME
the host name or IP address to bind to
--protocol=PROTOCOL http|scgi|ajp|fcgi
-q, --unquote unquote PATH_INFO (may be needed when using ajp)
--http10 use HTTP/1.0 protocol version instead of HTTP/1.1
--http11 use HTTP/1.1 protocol version (default)
-e PARENTDIR, --env-parent-dir=PARENTDIR
parent directory of the project environments
--base-path=BASE_PATH
the initial portion of the request URL's "path"
-r, --auto-reload restart automatically when sources are modified
-s, --single-env only serve a single project without the project list
-d, --daemonize run in the background as a daemon
--pidfile=PIDFILE when daemonizing, file to which to write pid
--umask=MASK when daemonizing, file mode creation mask to use, in
octal notation (default 022)
--group=GROUP the group to run as
--user=USER the user to run as
wang@wang-Lenovo-B460:~$
- [root@localhost ~]#tracd --port 8000 --basic-auth="*, /var/www/trac/svn/AJS/trac.htpasswd," /var/www/trac/svn/AJS
- Server starting in PID XXXXX.
- Serving on 0.0.0.0:8000 view at http://127.0.0.1:8000/
- Using HTTP/1.1 protocol version
- 127.0.0.1 - - [26/Feb/2011 13:00:49] "GET /first-trac/wiki HTTP/1.1" 200 -
- 127.0.0.1 - - [26/Feb/2011 13:00:49] "GET /first-trac/chrome/site/your_project_logo.png HTTP/1.1" 404 -
- 127.0.0.1 - - [26/Feb/2011 13:00:51] "GET /first-trac/login HTTP/1.1" 401 -
- 127.0.0.1 - - [26/Feb/2011 13:00:56] "GET /first-trac/login HTTP/1.1" 302 -
- 127.0.0.1 - - [26/Feb/2011 13:00:56] "GET /first-trac/wiki HTTP/1.1" 200 -
- 127.0.0.1 - - [26/Feb/2011 13:00:56] "GET /first-trac/chrome/site/your_project_logo.png HTTP/1.1" 404 -
登录成功,以后就可以用webadmin插件来管理了。
如下图:
参考:
1. http://trac.edgewall.org/wiki/TracAdmin
2. http://trac.edgewall.org/wiki/TracStandalone