28 | | With htdigest authentication. The file /tmp/users.htdigest contain user accounts for project1 with the realm "mycompany.com". |
| 26 | |
| 27 | You can't have the last portion of the path identical between the projects since that's how trac keeps the URLs of the |
| 28 | different projects unique. So if you use /project1/path/to and /project2/path/to, you will only see the second project. |
| 29 | |
| 30 | == Using Authentication == |
| 31 | |
| 32 | Tracd provides support for both Basic and Digest authentication. The default is to use Digest; to use Basic authentication, replace `--auth` with `--basic-auth` in the examples below, and omit the realm. |
| 33 | |
| 34 | If the file `/path/to/users.htdigest` contain user accounts for project1 with the realm "mycompany.com", you'd use the following command-line to start tracd: |
30 | | $ tracd -p 8080 --auth project1,/tmp/users.htdigest,mycompany.com /path/to/project1 |
| 36 | $ tracd -p 8080 --auth project1,/path/to/users.htdigest,mycompany.com /path/to/project1 |
| 37 | }}} |
| 38 | ''Note that the project “name” passed to the `--auth` option is actually the base name of the project environment directory."" |
| 39 | |
| 40 | Of course, the digest file can be be shared so that it is used for more than one project: |
| 41 | {{{ |
| 42 | $ tracd -p 8080 \ |
| 43 | --auth project1,/path/to/users.htdigest,mycompany.com \ |
| 44 | --auth project2,/path/to/users.htdigest,mycompany.com \ |
| 45 | /path/to/project1 /path/to/project2 |
| 48 | == Generating Passwords Without Apache == |
| 49 | |
| 50 | If you don't have Apache available, you can use this simple Python script to generate your passwords: |
| 51 | |
| 52 | {{{ |
| 53 | from optparse import OptionParser |
| 54 | import md5 |
| 55 | |
| 56 | # build the options |
| 57 | usage = "usage: %prog [options]" |
| 58 | parser = OptionParser(usage=usage) |
| 59 | parser.add_option("-u", "--username",action="store", dest="username", type = "string", |
| 60 | help="the username for whom to generate a password") |
| 61 | parser.add_option("-p", "--password",action="store", dest="password", type = "string", |
| 62 | help="the password to use") |
| 63 | (options, args) = parser.parse_args() |
| 64 | |
| 65 | # check options |
| 66 | if (options.username is None) or (options.password is None): |
| 67 | parser.error("You must supply both the username and password") |
| 68 | |
| 69 | # Generate the string to enter into the htdigest file |
| 70 | realm = 'trac' |
| 71 | kd = lambda x: md5.md5(':'.join(x)).hexdigest() |
| 72 | print ':'.join((options.username, realm, kd([options.username, realm, options.password]))) |
| 73 | }}} |