def run(): parser = argparse.ArgumentParser(description='Manage OMS passwords') parser.add_argument('user', help="user name") parser.add_argument('-g', help="group(s): comma separated list of " "groups the user belongs to", required=False, default=None) parser.add_argument('-s', action='store_true', help="force password " "prompt even if setting group(s) via -g", required=False, default=None) group = parser.add_mutually_exclusive_group() group.add_argument('-a', action='store_true', help="add user") group.add_argument('-d', action='store_true', help="delete user") group.add_argument('-c', action='store_true', help="check password, useful " "to troubleshoot login issues") args = parser.parse_args() ensure_base_dir() passwd_file = get_config().get('auth', 'passwd_file') if not os.path.exists(passwd_file): with open(passwd_file, 'w'): pass try: if args.d: delete_user(args.user) elif args.a: add_user(args.user, ask_password(), group=args.g) elif args.c: password_checker = FilePasswordDB(passwd_file, hash=ssha_hash) credentials = UsernamePassword(args.user, getpass("Password: "******"Wrong credentials") print "ok" else: update_passwd(args.user, args.s, force=True) except UserManagementError as e: print e sys.exit(1)
def _requestAvatarId(self, c): # first check to see if there are any users registered # if there are new users, add the user and then continue # authorizing them as nomral print c.__dict__ if not os.path.exists(self.filename) or not len(list(self._loadCredentials())): #hash password if available if self.hash: password = self.hash(c.username, c.password, None) else: password = c.password login_str = '%s%s%s' % (c.username, self.delimeter, password) #create file if needed #os.path.exists(self.filename) file(self.filename, 'w').write(login_str) return FilePasswordDB.requestAvatarId(self, c)
def requestAvatarId(self, c): if c.username in self.server.playernames: # already logged in return defer.fail(LoginDenied()) else: return FilePasswordDB.requestAvatarId(self, c)
def requestAvatarId(self, c): logInfo('authentication', 'Credentials: %s:%s' % (c.username, c.password)) return FilePasswordDB.requestAvatarId(self,c)
def requestAvatarId(self, c): logInfo('authentication', 'Credentials: %s:%s' % (c.username, c.password)) return FilePasswordDB.requestAvatarId(self, c)