def _getMemberByUsernameOrEmail(self, username, email, must=False): logging.info("Trying to find the user by username or email ...") member = None try: if username: member = Member.selectBy(username=username)[0] if email: member = Member.selectBy(email=email)[0] except IndexError: if must and not member: raise AdminException("The user can not be found (username: `%s', email: `%s')" % (username, email)) if not must and member: raise AdminException("The user `%s' with email `%s' already exists." % (member.username, member.email)) return member
def serve(self): logging.disable(logging.INFO) key = Key.get(self.args.key_id) member = key.getMember() if not os.environ.get("SSH_ORIGINAL_COMMAND"): print "Hi %s!" % member.username print "You've successfully authenticated, but %s does not provide shell access." % Config.get("phoenix", "app_name", "Phoenix") print "Use the following command to clone a repository:" print " > git clone git@%s:%s/repository.git" % (gethostname(), member.username) return False else: (command, fullpath) = os.environ.get("SSH_ORIGINAL_COMMAND").replace("'", "").split() if not Validate.gitcommand(command): raise Exception(command) print "Hi %s!" % member.username print "You've successfully authenticated, but %s does not provide shell access." % Config.get("phoenix", "app_name", "Phoenix") print "Use the following command to clone a repository:" print " > git clone git@%s:%s/repository.git" % (gethostname(), member.username) return False (username, repopath) = fullpath.split("/") try: owner = Member.selectBy(username=username)[0] repo = Repository.selectBy(member=owner, path=repopath)[0] except IndexError: logging.error("Repository `%s' not found but requested ..." % fullpath) raise ClientException("You are not allowed in this repository!") if repo.hasAccess(member, "master", "", "U" if command == "git-receive-pack" else "R"): __import__("os").execvp("git", ["git", "shell", "-c", "%s '%s'" % (command, repo.getFullpath())]) else: logging.error("User `%s' tried to access repository `%s' ..." % (member.id, repo.id)) raise ClientException("You are not allowed in this repository!")
def _getMemberByUsernameOrEmail(self, username, email, must=False): logging.info("Trying to find the user by username or email ...") member = None try: if username: member = Member.selectBy(username=username)[0] if email: member = Member.selectBy(email=email)[0] except IndexError: if must and not member: raise AdminException( "The user can not be found (username: `%s', email: `%s')" % (username, email)) if not must and member: raise AdminException( "The user `%s' with email `%s' already exists." % (member.username, member.email)) return member
def serve(self): logging.disable(logging.INFO) key = Key.get(self.args.key_id) member = key.getMember() if not os.environ.get("SSH_ORIGINAL_COMMAND"): print "Hi %s!" % member.username print "You've successfully authenticated, but %s does not provide shell access." % Config.get( "phoenix", "app_name", "Phoenix") print "Use the following command to clone a repository:" print " > git clone git@%s:%s/repository.git" % ( gethostname(), member.username) return False else: (command, fullpath) = os.environ.get("SSH_ORIGINAL_COMMAND").replace( "'", "").split() if not Validate.gitcommand(command): raise Exception(command) print "Hi %s!" % member.username print "You've successfully authenticated, but %s does not provide shell access." % Config.get( "phoenix", "app_name", "Phoenix") print "Use the following command to clone a repository:" print " > git clone git@%s:%s/repository.git" % ( gethostname(), member.username) return False (username, repopath) = fullpath.split("/") try: owner = Member.selectBy(username=username)[0] repo = Repository.selectBy(member=owner, path=repopath)[0] except IndexError: logging.error("Repository `%s' not found but requested ..." % fullpath) raise ClientException("You are not allowed in this repository!") if repo.hasAccess(member, "master", "", "U" if command == "git-receive-pack" else "R"): __import__("os").execvp("git", [ "git", "shell", "-c", "%s '%s'" % (command, repo.getFullpath()) ]) else: logging.error("User `%s' tried to access repository `%s' ..." % (member.id, repo.id)) raise ClientException("You are not allowed in this repository!")