Software Freedom Law Center

Changeset 204

Show
Ignore:
Timestamp:
08/10/08 04:56:53 (3 months ago)
Author:
landon
Message:

Started a good portion of work on a password authentication system

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/antimatter/luke/myplugs/libtracker/auth.py

    r203 r204  
    77from gozerbot.persistconfig import PersistConfig 
    88 
    9 from user import User 
     9from myplugs.libtracker.user import User 
     10 
     11from myplugs.libtracker.entry import pass_check, pass_set 
    1012 
    1113authenticated = Persist(datadir + '/authenticated') 
     
    1416if not config.has_key('max_auth'): 
    1517    config.define('max_auth',86400) 
     18 
     19if not config.has_key('pass_auth'): 
     20    config.define('pass_auth', True) 
    1621 
    1722if not authenticated.data: 
     
    4550            return False 
    4651    else: 
     52 
    4753        username = reply.txt 
     54        if config.get('pass_auth'): 
     55            valid = pass_authenticate(bot, ievent, username) 
     56            if not valid: 
     57                ievent.reply("Bad username/password, authenticate again") 
     58                return False 
    4859 
    4960    bot.say(ievent.nick, "You have been authenticated for 1 day.") 
     
    5162 
    5263    return True 
     64 
     65def pass_authenticate(bot, ievent, username): 
     66    bot.say(ievent.nick, "Password?") 
     67    reply = waitforuser(bot, ievent.userhost, 30) 
     68    if (reply == None): 
     69        ievent.reply("No Password") 
     70        return False 
     71    res = pass_check(username) 
     72    if not res.data == reply.txt: 
     73        return False 
     74    ievent.reply(repr(res.data)) 
     75    return True 
     76 
     77def set_pass(bot, ievent): 
     78    bot.say(ievent.nick, "Username") 
     79    name = waitforuser(bot, ievent.userhost, 30) 
     80    name = name.txt 
     81    bot.say(ievent.nick, "New Password?") 
     82    passwd = waitforuser(bot, ievent.userhost, 30) 
     83    passwd = passwd.txt 
     84    result = pass_set(name, passwd) 
     85    if result.error: 
     86        bot.say(ievent.nick, result.error) 
     87    else: 
     88        bot.say(ievent.nick, "%s set to %s : %s" % (name, passwd, result.data)) 
    5389 
    5490def check_auth(ievent): 
  • trunk/antimatter/luke/myplugs/libtracker/entry.py

    r196 r204  
    2424    result = restconn.delete(recordnum) 
    2525    return result 
     26 
     27def pass_set(user, password): 
     28    restconn = RestClient(baseurl + '/users') 
     29    result = restconn.add(name=user, passwd=password) 
     30    return result 
     31 
     32def pass_check(user, password): 
     33    restconn = RestClient(baseurl + '/users') 
     34    result = restconn.get(user) 
     35    return result 
     36 
     37 
  • trunk/antimatter/luke/myplugs/libtracker/tracker.py

    r186 r204  
    2121    auth.del_auth(ievent) 
    2222 
    23 cmnds.add('auth', authenticate, 'USER') 
    24 cmnds.add('unauth', unauthenticate, 'USER') 
     23def password_set(bot, ievent): 
     24    auth.set_pass(bot, ievent) 
     25 
     26cmnds.add('lt-auth', authenticate, 'USER') 
     27cmnds.add('lt-unauth', unauthenticate, 'USER') 
     28cmnds.add('lt-pass', password_set, 'USER') 
    2529 
    2630#Check for commands in timeparser.msgparse as well 

SFLC Main Page

[frdm] Support SFLC