cleanup to work on new server
This commit is contained in:
parent
a0bf0ebcdf
commit
5ddee41d8a
15
auth.py
15
auth.py
|
@ -1,22 +1,33 @@
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
import hashlib
|
import hashlib
|
||||||
import config
|
import config
|
||||||
|
import bcrypt
|
||||||
|
import traceback
|
||||||
|
|
||||||
class NoopAuth(object):
|
class NoopAuth(object):
|
||||||
def FAuthorized(self, user, passwd):
|
def FAuthorized(self, user, passwd):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class DrupalAuth(object):
|
class DrupalAuth(object):
|
||||||
|
def FHashMatches(self, md5, dbhash):
|
||||||
|
return md5 == dbhash
|
||||||
def FAuthorized(self, user, passwd):
|
def FAuthorized(self, user, passwd):
|
||||||
conn = MySQLdb.connect(host = config.drupaldb_host, user = config.drupaldb_user, passwd = config.drupaldb_password, db = config.drupaldb)
|
conn = MySQLdb.connect(host = config.drupaldb_host, user = config.drupaldb_user, passwd = config.drupaldb_password, db = config.drupaldb)
|
||||||
try:
|
try:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute("SELECT name, pass FROM users WHERE name = %s AND pass = %s", (user, hashlib.md5(passwd).hexdigest()))
|
firsthash = hashlib.md5(passwd).hexdigest()
|
||||||
return cursor.fetchone() != None
|
cursor.execute("SELECT pass FROM users WHERE name = %s", (user,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
return row and self.FHashMatches(firsthash, row[0])
|
||||||
finally:
|
finally:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
class DrupalBcryptAuth(DrupalAuth):
|
||||||
|
def FHashMatches(self, md5, dbhash):
|
||||||
|
return bcrypt.checkpw(md5, dbhash)
|
|
@ -8,8 +8,9 @@ BIND_HOSTNAME = ""
|
||||||
W = 80
|
W = 80
|
||||||
H = 25
|
H = 25
|
||||||
# directory to save ANSI pictures to. leave as "." for current directory. no trailing slash required. "" == /
|
# directory to save ANSI pictures to. leave as "." for current directory. no trailing slash required. "" == /
|
||||||
DIR_ANSI = "."
|
DIR_ANSI = "/home/jeremy/sites/marmots/ansi"
|
||||||
# authorization. Options are "Noop" (make up a username, no password), "Drupal" (fetches from MySQL Drupal database)
|
# authorization. Options are "Noop" (make up a username, no password), "Drupal" (fetches from MySQL Drupal database),
|
||||||
|
#"DrupalBcrypt" (fetches from MySQL Drupal database hacked to bcrypt the md5 hash - basically just Glorious Trainwrecks)
|
||||||
AUTH = "Noop"
|
AUTH = "Noop"
|
||||||
# if Drupal, configure these options:
|
# if Drupal, configure these options:
|
||||||
#drupaldb = "database"
|
#drupaldb = "database"
|
||||||
|
|
2
savecycle.sh
Normal file → Executable file
2
savecycle.sh
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
fnnew="whiteboard.marm.`date "+%F_%H-%M"`"
|
fnnew="whiteboard.marm.`date "+%F_%H-%M"`"
|
||||||
|
|
||||||
cd /home/jeremy/marmots
|
cd /home/jeremy/src/marmots
|
||||||
|
|
||||||
save ()
|
save ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue