Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #172, Enable HTTP Proxy Support for iControlRESTTokenAuth Object #173

Merged
merged 2 commits into from
Feb 7, 2020

Conversation

lykinsbd
Copy link
Contributor

@jasonrahm

What issues does this address?

Fixes #172

What's this change do?

Enable HTTP Proxy support in the iControlRESTTokenAuth object by passing the proxies from iControlRESTSession object down into it, and applying it to the request.<verb> calls that take place in that module.

Where should the reviewer start?

icontrol/authtoken.py, line 58, then follow it through the self.proxies value in that object.

icontrol/session.py, line 432, then follow where self.proxies was passed as an argument to the underlying token/auth object.

Any background context?

This change is required for full HTTP Proxy functionality.

Otherwise, while the outer requests.Session object in iControlRESTSession does attempt to utilize the proxies provided to it, the inner token acquisition and validation methods in iControlRESTTokenAuth fail as they do not know about the proxy.

Issues:
Fixes F5Networks#172

Problem:

The `proxies` attribute is available on the `iControlRESTSession` object,
 however it does not get passed to the `iControlRESTTokenAuth` object.
As a result, if all communication with a BigIP device needs to take place
 via a Proxy, authentication will fail and timeout.
Analysis:

I added `proxies` as a Kwarg on the `iControlRESTTokenAuth` object.
I then passed that argument in from the `iControlRESTSession` object
 instantiations of the `iControlRESTTokenAuth` object.
I then added `proxies=self.proxies` to the two instances of
 `requests.<verb>` in the `iControlRESTTokenAuth` object.
Tests:

I am unable to run the tests as listed in the documentation as even in 1.0 branch,
 `py.test --cov ./ --cov-report=html` returns:
 `argparse.ArgumentError: argument --bigip: conflicting option string: --bigip`

I did successfully test with and without proxies, by installing my fork/branch
 and testing against a live BigIP

With Proxies:

    In [1]: paste
    from f5.bigip import ManagementRoot
    from getpass import getpass
    password = getpass()
    user = "test_user"
    host = "test_f5.local"
    mah_f5 = ManagementRoot(hostname=host, username=user, password=password, proxies={"https": "socks5://127.0.0.1:8000"}, auth_provider="tmos")
    mah_f5.tmos_version

    ## -- End pasted text --
    Password:
    Out[1]: '14.1.2.3'

Without Proxies:

    In [1]: paste
    from f5.bigip import ManagementRoot
    from getpass import getpass
    password = getpass()
    user = "test_user"
    host = "localhost"
    port = 30002
    mah_f5 = ManagementRoot(hostname=host, port=port, username=user, password=password, auth_provider="tmos")
    mah_f5.tmos_version

    ## -- End pasted text --
    Password:
    Out[1]: '14.1.2.3'
Copy link

@jasonrahm jasonrahm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jasonrahm jasonrahm merged commit a43909a into F5Networks:1.0 Feb 7, 2020
@lykinsbd
Copy link
Contributor Author

lykinsbd commented Feb 7, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable Proxies for Token Acquisition in iControlRESTTokenAuth
2 participants