Code

Changes between Version 5 and Version 6 of AdminApplication


Ignore:
Timestamp:
08/19/08 14:18:35 (6 years ago)
Author:
hakrrz@…
Comment:

hakrrz@…

Legend:

Unmodified
Added
Removed
Modified
  • AdminApplication

    v5 v6  
    1 = The Admin Application - Common pitfalls = 
    2  
    3 == Creating new users == 
    4  
    5 === Passwords === 
    6  
    7 *Note: This is no longer a problem in the Django development version, as of [3520].* 
    8  
    9 One FAQ about the admin app is how to create new users. In particular how to set the password. It has been decided (and mooted on the lists) that the password field will only accept password hashes rather than plain text password. The problem is how one goes about generating these hashes. The following script will generate passwords on the command line. Run it with: {{{python <scriptname> <password>}}} and you'll get the correct output to paste into the admin app. IMPORTANT SECURITY NOTE: The password will turn up as plain text in your shell history, so take appropriate measures: change permissions, get an administrator you can trust or tweak the script not to use the command line. 
    10  
    11 {{{ 
    12 import sha, random, sys 
    13 try: 
    14     raw_password = sys.argv[1] 
    15 except IndexError: 
    16     print "Oh your Designer. You only had to type one thing in. How easy do I have to make it for you?" 
    17     sys.exit() 
    18 algo = 'sha1' 
    19 salt = sha.new(str(random.random())).hexdigest()[:5] 
    20 hsh = sha.new(salt+raw_password).hexdigest() 
    21 print "%s$%s$%s" % (algo, salt, hsh) 
    22 }}}