예제 #1
0
파일: auth.py 프로젝트: 1979139113/poc_exp
    def authenticateKey(self, app, credentials):
        assert isinstance(app, Factory)
        assert ISSHPrivateKey.providedBy(credentials)

        key = Key.fromString(credentials.blob)
        fingerprint = key.fingerprint().replace(':', '')

        service = None
        data = {}

        if credentials.username == "git":
            service = Service(
                self.protocol(app.getConfig(), 'drupalorg-sshkey-check'))

            data = {"fingerprint": fingerprint}

            service.request_bool(data)
        else:
            service = Service(
                self.protocol(app.getConfig(), 'drupalorg-ssh-user-key'))

            data = {
                "username": credentials.username,
                "fingerprint": fingerprint
            }

            service.request_bool(data)

        service.addCallback(self._handleProtocolCallback, app, data)

        return service.deferred
예제 #2
0
    def authenticatePassword(self, app, credentials):
        assert isinstance(app, Factory)
        assert IUsernamePassword.providedBy(credentials)

        service = Service(self.protocol(app.getConfig(), "drupalorg-vcs-auth-fetch-user-hash"))
        service.request_json({"username": credentials.username})

        def _authCallback(result):
            if result:
                service = Service(self.protocol(app.getConfig(), "drupalorg-vcs-auth-check-user-pass"))

                data = {
                    "username": credentials.username,
                    "password": DrupalHash(result, credentials.password).get_hash(),
                }

                service.request_bool(data)

                service.addCallback(self._handleProtocolCallback, app, data)

                return service.deferred
            else:
                return None

        service.addCallback(_authCallback)

        return service.deferred
예제 #3
0
파일: auth.py 프로젝트: 1979139113/poc_exp
    def _handleProtocolCallback(self, result, app, data):
        assert isinstance(app, Factory)
        assert isinstance(data, dict)

        if result:
            authService = Service(
                self.protocol(app.getConfig(), 'vcs-auth-data'))
            pushctlService = Service(
                self.protocol(app.getConfig(), 'pushctl-state'))

            return Session(app, authService, pushctlService, data)
        else:
            return None
예제 #4
0
    def authenticateKey(self, app, credentials):
        assert isinstance(app, Factory)
        assert ISSHPrivateKey.providedBy(credentials)

        key = Key.fromString(credentials.blob)
        fingerprint = key.fingerprint().replace(":", "")

        service = None
        data = {}

        if credentials.username == "git":
            service = Service(self.protocol(app.getConfig(), "drupalorg-sshkey-check"))

            data = {"fingerprint": fingerprint}

            service.request_bool(data)
        else:
            service = Service(self.protocol(app.getConfig(), "drupalorg-ssh-user-key"))

            data = {"username": credentials.username, "fingerprint": fingerprint}

            service.request_bool(data)

        service.addCallback(self._handleProtocolCallback, app, data)

        return service.deferred
예제 #5
0
        def _authCallback(result):
            if result:
                service = Service(self.protocol(app.getConfig(), "drupalorg-vcs-auth-check-user-pass"))

                data = {
                    "username": credentials.username,
                    "password": DrupalHash(result, credentials.password).get_hash(),
                }

                service.request_bool(data)

                service.addCallback(self._handleProtocolCallback, app, data)

                return service.deferred
            else:
                return None
예제 #6
0
파일: auth.py 프로젝트: 1979139113/poc_exp
    def allowAnonymousAccess(self, app):
        assert isinstance(app, Factory)

        if app.getConfig().get("DEFAULT", "allowAnonymous", True):
            service = Service(self.protocol(app.getConfig(), 'vcs-auth-data'))

            return defer.succeed(AnonymousSession(app, service))
        else:
            return defer.succeed(None)
예제 #7
0
파일: auth.py 프로젝트: 1979139113/poc_exp
    def authenticatePassword(self, app, credentials):
        assert isinstance(app, Factory)
        assert IUsernamePassword.providedBy(credentials)

        service = Service(
            self.protocol(app.getConfig(),
                          'drupalorg-vcs-auth-fetch-user-hash'))
        service.request_json({"username": credentials.username})

        def _authCallback(result):
            if result:
                service = Service(
                    self.protocol(app.getConfig(),
                                  'drupalorg-vcs-auth-check-user-pass'))

                data = {
                    "username": credentials.username,
                    "password": DrupalHash(result,
                                           credentials.password).get_hash()
                }

                service.request_bool(data)

                service.addCallback(self._handleProtocolCallback, app, data)

                return service.deferred
            else:
                return None

        service.addCallback(_authCallback)

        return service.deferred
예제 #8
0
파일: auth.py 프로젝트: 1979139113/poc_exp
        def _authCallback(result):
            if result:
                service = Service(
                    self.protocol(app.getConfig(),
                                  'drupalorg-vcs-auth-check-user-pass'))

                data = {
                    "username": credentials.username,
                    "password": DrupalHash(result,
                                           credentials.password).get_hash()
                }

                service.request_bool(data)

                service.addCallback(self._handleProtocolCallback, app, data)

                return service.deferred
            else:
                return None