Protect password when registering using shared secret

This commit is contained in:
Erik Johnston 2016-07-05 17:18:19 +01:00
parent ef535178ff
commit caf33b2d9b
2 changed files with 15 additions and 7 deletions

View file

@ -25,12 +25,17 @@ import urllib2
import yaml
def request_registration(user, password, server_location, shared_secret):
def request_registration(user, password, server_location, shared_secret, admin=False):
mac = hmac.new(
key=shared_secret,
msg=user,
digestmod=hashlib.sha1,
).hexdigest()
)
mac.update(user)
mac.update(password)
mac.update("admin" if admin else "notadmin")
mac = mac.hexdigest()
data = {
"user": user,