def set_password(self, password): """ Set the user's password. """ logging.debug("IndxUser, set_password for user {0}".format( self.username)) return_d = Deferred() pw_hash = make_hash(password) def connected_cb(conn): logging.debug("IndxUser, set_password, connected_cb") insert_q = "UPDATE tbl_users SET password_hash = %s WHERE username = %s" insert_p = [pw_hash, self.username] def inserted_cb(empty): logging.debug( "IndxUser, set_password, connected_cb, inserted_cb") return_d.callback(True) return conn.runOperation(insert_q, insert_p).addCallbacks(inserted_cb, return_d.errback) self.db.connect_indx_db().addCallbacks(connected_cb, return_d.errback) return return_d
def signup(): try: _username = request.form["inputName"] _password = request.form["inputPassword"] print('serving signup request...') if _username and _password: print "Username[" + _username + "] password[" + _password + "]" conn = mysql.connect() cursor = conn.cursor() _hashed_password = make_hash(_password) cursor.callproc('sp_createUser', (_username, _hashed_password, 0)) data = cursor.fetchall() print data if len(data) is 0: conn.commit() return redirect("/showSignIn") # return json.dumps({'message':'User created successfully'}) else: return showErrorPage("Username already exists!!") # return json.dumps({'error':str(data[0])}) conn.close() else: return showErrorPage("Enter required field") # return json.dumps({'html':'<span>Enter the required fields</span>'}) except Exception as e: return showErrorPage(str(e))
def create_user(self, new_username, new_password): """ Create a new INDX user. """ return_d = Deferred() pw_hash = make_hash(new_password) pw_encrypted = encrypt(new_password, self.db_pass) def connected(conn): d = conn.runOperation("INSERT INTO tbl_users (username, username_type, password_hash, password_encrypted) VALUES (%s, %s, %s, %s)",[new_username, 'local_owner', pw_hash, pw_encrypted]) d.addCallbacks(lambda *x: return_d.callback(None), return_d.errback) return self.connect_indx_db().addCallbacks(connected, return_d.errback) return return_d
def create_user(self, new_username, new_password): """ Create a new INDX user. """ return_d = Deferred() pw_hash = make_hash(new_password) pw_encrypted = encrypt(new_password, self.db_pass) def connected(conn): d = conn.runOperation( "INSERT INTO tbl_users (username, username_type, password_hash, password_encrypted) VALUES (%s, %s, %s, %s)", [new_username, 'local_owner', pw_hash, pw_encrypted]) d.addCallbacks(lambda *x: return_d.callback(None), return_d.errback) return self.connect_indx_db().addCallbacks(connected, return_d.errback) return return_d
def set_password(self, password): """ Set the user's password. """ logging.debug("IndxUser, set_password for user {0}".format(self.username)) return_d = Deferred() pw_hash = make_hash(password) def connected_cb(conn): logging.debug("IndxUser, set_password, connected_cb") insert_q = "UPDATE tbl_users SET password_hash = %s WHERE username = %s" insert_p = [pw_hash, self.username] def inserted_cb(empty): logging.debug("IndxUser, set_password, connected_cb, inserted_cb") return_d.callback(True) return conn.runOperation(insert_q, insert_p).addCallbacks(inserted_cb, return_d.errback) self.db.connect_indx_db().addCallbacks(connected_cb, return_d.errback) return return_d
def _upgrade(self): """ Upgrades config file from previous verisions and bumps up config version """ if self.CONFIG_VERSION == 0: self.CONFIG_VERSION = 1 if self.CONFIG_VERSION == 1: # Change home_stats_cards to list if self.HOME_STATS_CARDS: home_stats_cards = ''.join(self.HOME_STATS_CARDS).split(', ') if 'watch_statistics' in home_stats_cards: home_stats_cards.remove('watch_statistics') self.HOME_STATS_CARDS = home_stats_cards # Change home_library_cards to list if self.HOME_LIBRARY_CARDS: home_library_cards = ''.join( self.HOME_LIBRARY_CARDS).split(', ') if 'library_statistics' in home_library_cards: home_library_cards.remove('library_statistics') self.HOME_LIBRARY_CARDS = home_library_cards self.CONFIG_VERSION = 2 if self.CONFIG_VERSION == 2: self.CONFIG_VERSION = 3 if self.CONFIG_VERSION == 3: if self.HTTP_ROOT == '/': self.HTTP_ROOT = '' self.CONFIG_VERSION = 4 if self.CONFIG_VERSION == 4: self.CONFIG_VERSION = 5 if self.CONFIG_VERSION == 5: self.MONITOR_PMS_UPDATES = 0 self.CONFIG_VERSION = 6 if self.CONFIG_VERSION == 6: if self.GIT_USER.lower() == 'drzoidberg33': self.GIT_USER = '******' self.CONFIG_VERSION = 7 if self.CONFIG_VERSION == 7: self.CONFIG_VERSION = 8 if self.CONFIG_VERSION == 8: self.CONFIG_VERSION = 9 if self.CONFIG_VERSION == 9: if self.PMS_UPDATE_CHANNEL == 'plexpass': self.PMS_UPDATE_CHANNEL = 'beta' self.CONFIG_VERSION = 10 if self.CONFIG_VERSION == 10: self.GIT_USER = '******' self.GIT_REPO = 'Tautulli' self.CONFIG_VERSION = 11 if self.CONFIG_VERSION == 11: self.ANON_REDIRECT = self.ANON_REDIRECT.replace( 'http://www.nullrefer.com/?', 'https://www.nullrefer.com/?') self.CONFIG_VERSION = 12 if self.CONFIG_VERSION == 12: self.BUFFER_THRESHOLD = max(self.BUFFER_THRESHOLD, 10) self.CONFIG_VERSION = 13 if self.CONFIG_VERSION == 13: self.CONFIG_VERSION = 14 if self.CONFIG_VERSION == 14: if plexpy.DOCKER: self.PLEXPY_AUTO_UPDATE = 0 self.CONFIG_VERSION = 15 if self.CONFIG_VERSION == 15: if self.HTTP_ROOT and self.HTTP_ROOT != '/': self.JWT_UPDATE_SECRET = True self.CONFIG_VERSION = 16 if self.CONFIG_VERSION == 16: if plexpy.SNAP: self.PLEXPY_AUTO_UPDATE = 0 self.CONFIG_VERSION = 17 if self.CONFIG_VERSION == 17: home_stats_cards = self.HOME_STATS_CARDS if 'top_users' in home_stats_cards: top_users_index = home_stats_cards.index('top_users') home_stats_cards.insert(top_users_index, 'top_libraries') else: home_stats_cards.append('top_libraries') self.HOME_STATS_CARDS = home_stats_cards self.CONFIG_VERSION = 18 if self.CONFIG_VERSION == 18: if self.CHECK_GITHUB_INTERVAL > 24: self.CHECK_GITHUB_INTERVAL = ( int(self.CHECK_GITHUB_INTERVAL // 60) + (self.CHECK_GITHUB_INTERVAL % 60 > 0)) self.CONFIG_VERSION = 19 if self.CONFIG_VERSION == 19: if self.HTTP_PASSWORD and not self.HTTP_HASHED_PASSWORD: self.HTTP_PASSWORD = make_hash(self.HTTP_PASSWORD) self.HTTP_HASH_PASSWORD = 1 self.HTTP_HASHED_PASSWORD = 1 self.CONFIG_VERSION = 20 if self.CONFIG_VERSION == 20: if self.PMS_UUID: self.FIRST_RUN_COMPLETE = 1 self.CONFIG_VERSION = 21 if self.CONFIG_VERSION == 21: if not self.ANON_REDIRECT_DYNAMIC and not self.ANON_REDIRECT: self.ANON_REDIRECT_DYNAMIC = 1 self.CONFIG_VERSION = 22
#!/usr/bin/env python import sys from getpass import getpass import hashing_passwords as hp # https://raw.github.com/SimonSapin/snippets/master/hashing_passwords.py # requires https://github.com/mitsuhiko/python-pbkdf2.git pw = getpass("Enter password: "******"Re-enter password: "******"Passwords don't match!") print(hp.make_hash(pw))
#!/usr/bin/env python """ Original from: https://github.com/jpmens/mosquitto-auth-plug/tree/master/contrib/python """ import sys from getpass import getpass import hashing_passwords as hp pw = getpass("Enter password: "******"Re-enter password: "******"Passwords don't match!") print(hp.make_hash(pw)) #hashpass = hp.make_hash(pw) #print(hp.check_hash(pw, hashpass))
#!/usr/bin/env python import sys from getpass import getpass import hashing_passwords as hp # https://raw.github.com/SimonSapin/snippets/master/hashing_passwords.py # requires https://github.com/mitsuhiko/python-pbkdf2.git pw = getpass("Enter password: "******"Re-enter password: "******"Passwords don't match!") print hp.make_hash(pw)
def write(self, vals): reset_password = vals.get('reset_password') if reset_password: vals['pw'] = hp.make_hash(reset_password) vals.pop('reset_password') return super(Account, self).write(vals)