How to use the pypsrp.negotiate.HTTPNegotiateAuth function in pypsrp

To help you get started, we’ve selected a few pypsrp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jborean93 / pypsrp / tests / test_wsman.py View on Github external
def test_build_negotiate_with_kwargs(self):
        transport = _TransportHTTP("", auth="negotiate", username="user",
                                   ssl=False, password="pass",
                                   negotiate_delegate=True,
                                   negotiate_hostname_override="host",
                                   negotiate_send_cbt=False,
                                   negotiate_service="HTTP")
        session = transport._build_session()
        assert isinstance(transport.encryption, WinRMEncryption)
        assert transport.encryption.protocol == WinRMEncryption.SPNEGO
        assert isinstance(session.auth, HTTPNegotiateAuth)
        assert session.auth.auth_provider == "auto"
        assert session.auth.delegate is True
        assert session.auth.hostname_override == "host"
        assert session.auth.password == "pass"
        assert session.auth.send_cbt is False
        assert session.auth.service == 'HTTP'
        assert session.auth.username == "user"
        assert session.auth.wrap_required is True
github jborean93 / pypsrp / tests / test_wsman.py View on Github external
def test_build_kerberos(self):
        transport = _TransportHTTP("", auth="kerberos")
        session = transport._build_session()
        assert isinstance(transport.encryption, WinRMEncryption)
        assert transport.encryption.protocol == WinRMEncryption.SPNEGO
        assert isinstance(session.auth, HTTPNegotiateAuth)
        assert session.auth.auth_provider == "kerberos"
        assert session.auth.delegate is False
        assert session.auth.hostname_override is None
        assert session.auth.password is None
        assert session.auth.send_cbt is True
        assert session.auth.service == 'WSMAN'
        assert session.auth.username is None
        assert session.auth.wrap_required is False
github jborean93 / pypsrp / tests / test_negotiate.py View on Github external
def test_get_auth_token_present(self):
        auth = HTTPNegotiateAuth()
        response = requests.Response()
        response.headers['www-authenticate'] = "Negotiate YWJj"
        expected = b"abc"
        actual = HTTPNegotiateAuth._get_auth_token(response, auth._regex)
        assert actual == expected
github jborean93 / pypsrp / tests / test_negotiate.py View on Github external
def test_auth_supported(self):
        response = requests.Response()
        response.headers['www-authenticate'] = "Negotiate"
        HTTPNegotiateAuth._check_auth_supported(response, "Negotiate")
github jborean93 / pypsrp / tests / test_negotiate.py View on Github external
def test_get_auth_token_no_header(self):
        auth = HTTPNegotiateAuth()
        response = requests.Response()
        expected = None
        actual = HTTPNegotiateAuth._get_auth_token(response, auth._regex)
        assert actual == expected
github jborean93 / pypsrp / tests / test_negotiate.py View on Github external
def test_get_auth_token_different_auth(self):
        auth = HTTPNegotiateAuth()
        response = requests.Response()
        response.headers['www-authenticate'] = "Kerberos YWJj"
        expected = None
        actual = HTTPNegotiateAuth._get_auth_token(response, auth._regex)
        assert actual == expected
github jborean93 / pypsrp / tests / test_negotiate.py View on Github external
cert_der = b'MIIBjjCCATSgAwIBAgIQRCJw7nbtvJ5F8wikRmwgizAJBgcqhkjOPQQ' \
                   b'BMBUxEzARBgNVBAMMClNFUlZFUjIwMTYwHhcNMTcwNTMwMDgwMzE3Wh' \
                   b'cNMTgwNTMwMDgyMzE3WjAVMRMwEQYDVQQDDApTRVJWRVIyMDE2MFkwE' \
                   b'wYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEk3fOh178kRglmnPKe9K/mbgi' \
                   b'gf8YgNq62rF2EpfzpyQY0eGw4xnmKDG73aZ+ATSlV2IybxiUVsKyMUn' \
                   b'LhPfvmaNnMGUwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQ' \
                   b'UFBwMCBggrBgEFBQcDATAVBgNVHREEDjAMggpTRVJWRVIyMDE2MB0GA' \
                   b'1UdDgQWBBQSK8qwmiQmyAWWya3FxQDj9wqQAzAJBgcqhkjOPQQBA0kA' \
                   b'MEYCIQCiOsP56Iqo+cHRvCp2toj65Mgxo/PQY1tn+S3WH4RJFQIhAJe' \
                   b'gGQuaPWg6aCWV+2+6pNCNMdg/Nix+mMOJ88qCBNHi'
        cert_der = base64.b64decode(cert_der)

        expected = b'\x1E\xC9\xAD\x46\xDE\xE9\x34\x0E\x45\x03\xCF\xFD' \
                   b'\xB5\xCD\x81\x0C\xB2\x6B\x77\x8F\x46\xBE\x95\xD5' \
                   b'\xEA\xF9\x99\xDC\xB1\xC4\x5E\xDA'
        actual = HTTPNegotiateAuth._get_certificate_hash(cert_der)
        assert actual == expected
github jborean93 / pypsrp / pypsrp / wsman.py View on Github external
def _build_auth_negotiate(self, session, auth_provider="auto"):
        kwargs = self._get_auth_kwargs('negotiate')

        session.auth = HTTPNegotiateAuth(username=self.username,
                                         password=self.password,
                                         auth_provider=auth_provider,
                                         wrap_required=self.wrap_required,
                                         **kwargs)
        self.encryption = WinRMEncryption(
            session.auth, WinRMEncryption.SPNEGO
        )
github jborean93 / pypsrp / pypsrp / transport.py View on Github external
def _build_auth_negotiate(self, session, auth_provider="auto"):
        kwargs = self._get_auth_kwargs('negotiate')

        session.auth = HTTPNegotiateAuth(username=self.username,
                                         password=self.password,
                                         auth_provider=auth_provider,
                                         wrap_required=self.wrap_required,
                                         **kwargs)
        self.encryption = WinRMEncryption(
            session.auth, WinRMEncryption.SPNEGO
        )