| 289 | |
| 290 | === Creating authentication with tracd on Windows (Standalone) === |
| 291 | |
| 292 | If you are running tracd without Apache, you can use this simple Python script to generate your passwords for tracd. Copy the contents below into a new file called 'C:\Python25\scripts\trac-digest.py'. |
| 293 | |
| 294 | {{{ |
| 295 | #!python |
| 296 | from optparse import OptionParser |
| 297 | import md5 |
| 298 | |
| 299 | # build the options |
| 300 | usage = "usage: %prog [options]" |
| 301 | parser = OptionParser(usage=usage) |
| 302 | parser.add_option("-u", "--username",action="store", dest="username", type = "string", |
| 303 | help="the username for whom to generate a password") |
| 304 | parser.add_option("-p", "--password",action="store", dest="password", type = "string", |
| 305 | help="the password to use") |
| 306 | (options, args) = parser.parse_args() |
| 307 | |
| 308 | # check options |
| 309 | if (options.username is None) or (options.password is None): |
| 310 | parser.error("You must supply both the username and password") |
| 311 | |
| 312 | # Generate the string to enter into the htdigest file |
| 313 | realm = 'trac' |
| 314 | kd = lambda x: md5.md5(':'.join(x)).hexdigest() |
| 315 | print ':'.join((options.username, realm, kd([options.username, realm, options.password]))) |
| 316 | }}} |
| 317 | |
| 318 | You can create a new password file, or add new users to the file, by executing this command from the command line: |
| 319 | {{{ |
| 320 | C:\Python25\Scripts\trac-digest.py -u "My User Name" -p my@user@password >> C:\projects\passwords.txt |
| 321 | }}} |
| 322 | |
| 323 | To start tracd with authentication, execute this command from the command line: |
| 324 | {{{ |
| 325 | C:\Python25\Scripts\tracd-script.py -p 8000 --auth=dev,C:\projects\passwords.txt,trac c:\projects\trac\my-project |
| 326 | }}} |
| 327 | |