Edgewall Software

Changes between Version 116 and Version 117 of TracStandalone


Ignore:
Timestamp:
Apr 25, 2015, 9:13:32 PM (9 years ago)
Author:
Ryan J Ollos
Comment:

The script on this page just duplicates what is provided in contrib.

Legend:

Unmodified
Added
Removed
Modified
  • TracStandalone

    v116 v117  
    171171=== Generating Passwords Without Apache
    172172
    173 Basic Authorization can be accomplished via this [http://aspirine.org/htpasswd_en.html online HTTP Password generator] which also supports `SHA-1`.  Copy the generated password-hash line to the .htpasswd file on your system. Note that Windows Python lacks the "crypt" module that is the default hash type for htpasswd ; Windows Python can grok MD5 password hashes just fine and you should use MD5.
    174 
    175 You can use this simple Python script to generate a '''digest''' password file:
    176 
    177 {{{#!python
    178 from optparse import OptionParser
    179 # The md5 module is deprecated in Python 2.5
    180 try:
    181     from hashlib import md5
    182 except ImportError:
    183     from md5 import md5
    184 realm = 'trac'
    185 
    186 # build the options
    187 usage = "usage: %prog [options]"
    188 parser = OptionParser(usage=usage)
    189 parser.add_option("-u", "--username",action="store", dest="username", type = "string",
    190                   help="the username for whom to generate a password")
    191 parser.add_option("-p", "--password",action="store", dest="password", type = "string",
    192                   help="the password to use")
    193 parser.add_option("-r", "--realm",action="store", dest="realm", type = "string",
    194                   help="the realm in which to create the digest")
    195 (options, args) = parser.parse_args()
    196 
    197 # check options
    198 if (options.username is None) or (options.password is None):
    199    parser.error("You must supply both the username and password")
    200 if (options.realm is not None):
    201    realm = options.realm
    202    
    203 # Generate the string to enter into the htdigest file
    204 kd = lambda x: md5(':'.join(x)).hexdigest()
    205 print ':'.join((options.username, realm, kd([options.username, realm, options.password])))
    206 }}}
    207 
    208 Note: If you use the above script you must set the realm in the `--auth` argument to '''`trac`'''. Example usage (assuming you saved the script as trac-digest.py):
    209 
    210 {{{#!sh
    211  $ python trac-digest.py -u username -p password >> c:\digest.txt
    212  $ tracd --port 8000 --auth=proj_name,c:\digest.txt,trac c:\path\to\proj_name
     173Basic Authorization can be accomplished via this [http://aspirine.org/htpasswd_en.html online HTTP Password generator] which also supports `SHA-1`.  Copy the generated password-hash line to the .htpasswd file on your system. Note that Windows Python lacks the "crypt" module that is the default hash type for htpasswd. Windows Python can grok MD5 password hashes just fine and you should use MD5.
     174
     175Trac also provides `htpasswd` and `htdigest` scripts in `contrib`:
     176{{{#!sh
     177$ ./contrib/htpasswd.py -cb htpasswd user1 user1
     178$ ./contrib/htpasswd.py -b htpasswd user2 user2
     179}}}
     180
     181{{{#!sh
     182$ ./contrib/htdigest.py -cb htdigest trac user1 user1
     183$ ./contrib/htdigest.py -b htdigest trac user2 user2
    213184}}}
    214185
    215186==== Using `md5sum`
    216187It is possible to use `md5sum` utility to generate digest-password file:
    217 {{{
     188{{{#!sh
    218189user=
    219190realm=