Exemple #1
0
    def check_basic_auth(self, header, project):
        """Parse basic authorization header

        :param header: authorization header value
        """
        header = extract_if_startswith(header, "Basic")

        if not header:
            return False

        public_key, private_key = b64decode(header.strip()).split(":")
        return self.check_key(private_key, public_key, project)
Exemple #2
0
    def check_basic_auth(self, header, project):
        """Parse basic authorization header

        :param header: authorization header value
        """
        header = extract_if_startswith(header, "Basic")

        if not header:
            return False

        public_key, private_key = b64decode(header.strip()).split(":")
        return self.check_key(private_key, public_key, project)
Exemple #3
0
    def check_gottwall_auth(self, header, project):
        """Check X-GottWall-Auth

        :param header: header string value
        :param project: project name
        """

        header = extract_if_startswith(header, "GottWallS1")
        if not header:
            return False

        ts, sign, base = header.split()
        return self.check_sign(project, sign, ts, base)
Exemple #4
0
    def check_gottwall_auth(self, header, project):
        """Check X-GottWall-Auth

        :param header: header string value
        :param project: project name
        """

        header = extract_if_startswith(header, "GottWallS1")
        if not header:
            return False

        ts, sign, base = header.split()
        return self.check_sign(project, sign, ts, base)
Exemple #5
0
    def check_gottwall_auth(self, header, project):
        """Check X-GottWall-Auth

        :param header: header string value
        GoottWallS1 1391854203 09944becfa73f5a2b433468b20cf417c 1000
        :param project: project name
        """
        header = extract_if_startswith(header, "GottWallS1")
        if not header:
            return False

        ts, sign, base = header.split()
        return self.check_sign(project, sign, ts, base)
Exemple #6
0
    def check_gottwall_auth_s2(self, header):
        """Check client authentication

        :param header: authentication header string
        GoottWallS2 1391854203 09944becfa73f5a2b433468b20cf417c 1000 test_project
        """
        header = extract_if_startswith(header, "GottWallS2")

        if not header:
            return False

        try:
            ts, sign, base, project = header.split()
            if self.check_sign(project, sign, ts, base):
                self.project = project
                return True
        except Exception as e:
            return True
Exemple #7
0
def test_extract_if_startswith():
    assert extract_if_startswith("Basic ejfknwejklfnwejfnl", "Basic ") == "ejfknwejklfnwejfnl"