Skip to content

Commit

Permalink
vendor requests_kerberos v0.12.0 (#268)
Browse files Browse the repository at this point in the history
Pending upstream changes will cause significant breakage; just embed a working one.

* updated setup.py kerberos extras_require to directly install pykerberos/winkerberos as necessary (and drop requests_kerberos)
* updated .coverargerc to exclude vendor subpackage
  • Loading branch information
nitzmahone committed Jul 11, 2019
1 parent 3eb4005 commit fe59460
Show file tree
Hide file tree
Showing 8 changed files with 579 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[run]
omit =
*/tests*
*/tests*
*/vendor*
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
author_email='alexey.diyan@gmail.com',
url='http://github.com/diyan/pywinrm/',
license='MIT license',
packages=('winrm', 'winrm.tests'),
packages=('winrm', 'winrm.tests', 'winrm.vendor.requests_kerberos'),
package_data={'winrm.tests': ['*.ps1']},
install_requires=['xmltodict', 'requests>=2.9.1', 'requests_ntlm>=0.3.0', 'six'],
extras_require = dict(kerberos=['requests-kerberos>=0.10.0'], credssp=['requests-credssp>=1.0.0']),
extras_require={
'credssp': ['requests-credssp>=1.0.0'],
'kerberos:sys_platform=="win32"': ['winkerberos>=0.5.0'],
'kerberos:sys_platform!="win32"': ['pykerberos>=1.2.1,<2.0.0']
},
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
Expand Down
2 changes: 1 addition & 1 deletion winrm/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

HAVE_KERBEROS = False
try:
from requests_kerberos import HTTPKerberosAuth, REQUIRED
from .vendor.requests_kerberos import HTTPKerberosAuth, REQUIRED

HAVE_KERBEROS = True
except ImportError:
Expand Down
Empty file added winrm/vendor/__init__.py
Empty file.
41 changes: 41 additions & 0 deletions winrm/vendor/requests_kerberos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ISC License
#
# Copyright (c) 2012 Kenneth Reitz
#
# Permission to use, copy, modify and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS-IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

"""
requests Kerberos/GSSAPI authentication library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Requests is an HTTP library, written in Python, for human beings. This library
adds optional Kerberos/GSSAPI authentication support and supports mutual
authentication. Basic GET usage:
>>> import requests
>>> from requests_kerberos import HTTPKerberosAuth
>>> r = requests.get("http://example.org", auth=HTTPKerberosAuth())
The entire `requests.api` should be supported.
"""
import logging

from .kerberos_ import HTTPKerberosAuth, REQUIRED, OPTIONAL, DISABLED
from .exceptions import MutualAuthenticationError
from .compat import NullHandler

logging.getLogger(__name__).addHandler(NullHandler())

__all__ = ('HTTPKerberosAuth', 'MutualAuthenticationError', 'REQUIRED',
'OPTIONAL', 'DISABLED')
__version__ = '0.12.0'
30 changes: 30 additions & 0 deletions winrm/vendor/requests_kerberos/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# ISC License
#
# Copyright (c) 2012 Kenneth Reitz
#
# Permission to use, copy, modify and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS-IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

"""
Compatibility library for older versions of python
"""
import sys

# python 2.7 introduced a NullHandler which we want to use, but to support
# older versions, we implement our own if needed.
if sys.version_info[:2] > (2, 6):
from logging import NullHandler
else:
from logging import Handler
class NullHandler(Handler):
def emit(self, record):
pass
31 changes: 31 additions & 0 deletions winrm/vendor/requests_kerberos/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ISC License
#
# Copyright (c) 2012 Kenneth Reitz
#
# Permission to use, copy, modify and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS-IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

"""
requests_kerberos.exceptions
~~~~~~~~~~~~~~~~~~~
This module contains the set of exceptions.
"""
from requests.exceptions import RequestException


class MutualAuthenticationError(RequestException):
"""Mutual Authentication Error"""

class KerberosExchangeError(RequestException):
"""Kerberos Exchange Failed Error"""
Loading

0 comments on commit fe59460

Please sign in to comment.