Пример #1
0
 def _sqlChanges(self):
     from Phoenix.Models import Privilege, Repository, Role
     Member.createTable(ifNotExists=True)
     Role.createTable(ifNotExists=True)
     Repository.createTable(ifNotExists=True)
     Privilege.createTable(ifNotExists=True)
     Hook.createTable(ifNotExists=True)
     Key.createTable(ifNotExists=True)
Пример #2
0
 def _sqlChanges(self):
     from Phoenix.Models import Privilege, Repository, Role
     Member.createTable(ifNotExists=True)
     Role.createTable(ifNotExists=True)
     Repository.createTable(ifNotExists=True)
     Privilege.createTable(ifNotExists=True)
     Hook.createTable(ifNotExists=True)
     Key.createTable(ifNotExists=True)
Пример #3
0
 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!")
Пример #4
0
 def removekey(self):
     logging.info("Defining key id ...")
     id = self.args.key_id
     
     logging.info("Checking if the key exists ...")
     key = Key.get(id)
     
     if not key:
         raise Exception("The key with the id `%s' does not exits." % id)
             
     logging.info("Removing the key from the database ...")
     key.destroySelf()
     
     print "Done."
Пример #5
0
    def removekey(self):
        logging.info("Defining key id ...")
        id = self.args.key_id

        logging.info("Checking if the key exists ...")
        key = Key.get(id)

        if not key:
            raise Exception("The key with the id `%s' does not exits." % id)

        logging.info("Removing the key from the database ...")
        key.destroySelf()

        print "Done."
Пример #6
0
    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!")
Пример #7
0
 def key(cls, id):
     from Phoenix.Models import Key
     if Key.get(id):
         return True
     return False
Пример #8
0
 def addKey(self, key):
     from Phoenix.Models import Key
     key = Key(member=self, pubkey=key)
     return key
Пример #9
0
 def key(cls, id):
     from Phoenix.Models import Key
     if Key.get(id):
         return True
     return False