byte encoding changed to ASCII
This commit is contained in:
parent
73e1eba43a
commit
d98ca0c5ae
3 changed files with 9 additions and 9 deletions
12
clientsdb.py
12
clientsdb.py
|
@ -23,8 +23,8 @@ def addclient(vmid, vmname, clientid, clientname, clientemail, vmpass):
|
|||
newpass = utils.genpassword(30)
|
||||
ioconfig.logger.info('client[{}]> initial password is: {}'.format(clientid, newpass))
|
||||
salt = bcrypt.gensalt()
|
||||
b_newpass = newpass.encode('utf-8')
|
||||
encpasswd = bcrypt.hashpw(b_newpass, salt).decode('utf-8')
|
||||
b_newpass = newpass.encode('ascii')
|
||||
encpasswd = bcrypt.hashpw(b_newpass, salt).decode('ascii')
|
||||
vcard = { 'name':str(clientname), 'email':str(clientemail), 'encpasswd':str(encpasswd) }
|
||||
newclient = { str(clientid):vcard }
|
||||
clientsdb.update(newclient)
|
||||
|
@ -42,8 +42,8 @@ def addclient(vmid, vmname, clientid, clientname, clientemail, vmpass):
|
|||
def setencpasswd(clientemail, newpass):
|
||||
""" setup a new management password """
|
||||
salt = bcrypt.gensalt()
|
||||
b_newpass = newpass.encode('utf-8')
|
||||
encpasswd = bcrypt.hashpw(b_newpass, salt).decode('utf-8')
|
||||
b_newpass = newpass.encode('ascii')
|
||||
encpasswd = bcrypt.hashpw(b_newpass, salt).decode('ascii')
|
||||
|
||||
try:
|
||||
clientsdb = readclientsdb()
|
||||
|
@ -82,8 +82,8 @@ def validate(clientemail, password):
|
|||
|
||||
#2. check the password
|
||||
encpass = clientsdb[c_id]['encpasswd']
|
||||
b_srvpass = password.encode('utf-8')
|
||||
b_encpass = encpass.encode('utf-8')
|
||||
b_srvpass = password.encode('ascii')
|
||||
b_encpass = encpass.encode('ascii')
|
||||
|
||||
if (hmac.compare_digest(bcrypt.hashpw(b_srvpass, b_encpass), b_encpass)):
|
||||
#login successful
|
||||
|
|
4
grid.py
4
grid.py
|
@ -45,8 +45,8 @@ def sync(cached=True):
|
|||
slave_masterip = config.get(slave_section, 'masterip')
|
||||
slave_password = config.get(slave_section, 'password')
|
||||
slave_regionid = config.get(slave_section, 'regionid')
|
||||
enc_slave_password = base64.b64encode(slave_password.encode('ascii')) #encode base64 to avoid shoulder surfers
|
||||
decoded_password = enc_slave_password.decode('utf-8')
|
||||
enc_slave_password = base64.b64encode(slave_password.encode('ascii')) #encode base64 in grid
|
||||
decoded_password = enc_slave_password.decode('ascii')
|
||||
real_slave = { "id":slave_id, "slave":slave_name, "masterip":slave_masterip, "password":decoded_password }
|
||||
optional_slave = {}
|
||||
cache_file = 'cache-slave-' + slave_id + '.json'
|
||||
|
|
|
@ -46,7 +46,7 @@ def apicheck(params):
|
|||
#API methods
|
||||
class Validate(object):
|
||||
def on_post(self, req, resp):
|
||||
""" get clientemail and mgmt pass and compare it with the client db and returns an authed object ID """
|
||||
""" get clientemail and password and compare it with the client db and returns a list of managed object IDs """
|
||||
clientemail = req.params['clientemail']
|
||||
passwd = req.params['password']
|
||||
logger.info('grid> access requested for {} with {}'.format(clientemail, passwd))
|
||||
|
|
Loading…
Reference in a new issue