-
Notifications
You must be signed in to change notification settings - Fork 94
Add verify and proxies to context #142
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ class AuthenticationContext(object): | |
|
||
def __init__( | ||
self, authority, validate_authority=None, cache=None, | ||
api_version='1.0', timeout=None, enable_pii=False): | ||
api_version='1.0', timeout=None, enable_pii=False, verify_ssl=None, proxies=None): | ||
'''Creates a new AuthenticationContext object. | ||
|
||
By default the authority will be checked against a list of known Azure | ||
|
@@ -75,11 +75,17 @@ def __init__( | |
read timeout) <timeouts>` tuple. | ||
:param enable_pii: (optional) Unless this is set to True, | ||
there will be no Personally Identifiable Information (PII) written in log. | ||
:param verify_ssl: (optional) requests verify. Either a boolean, in which case it | ||
controls whether we verify the server's TLS certificate, or a string, in which | ||
case it must be a path to a CA bundle to use. This value is ignored if env | ||
variable ADAL_PYTHON_SSL_NO_VERIFY is used. | ||
:param proxies: (optional) requests proxies. Dictionary mapping protocol to the URL | ||
of the proxy. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is true that this is the same concise docstring used by
Or simply add a link to its official documentation in requests (since we are exposing this requests behavior anyway). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer external link, scale better in the long term IMHO :) |
||
''' | ||
self.authority = Authority(authority, validate_authority is None or validate_authority) | ||
self._oauth2client = None | ||
self.correlation_id = None | ||
env_value = os.environ.get('ADAL_PYTHON_SSL_NO_VERIFY') | ||
env_value = os.environ.get('ADAL_PYTHON_SSL_NO_VERIFY', verify_ssl) | ||
if api_version is not None: | ||
warnings.warn( | ||
"""The default behavior of including api-version=1.0 on the wire | ||
|
@@ -95,6 +101,7 @@ def __init__( | |
'options': GLOBAL_ADAL_OPTIONS, | ||
'api_version': api_version, | ||
'verify_ssl': None if env_value is None else not env_value, # mainly for tracing through proxy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this line will need to be updated; otherwise the argument value will not be propagated particularly when it is a string to a bundle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the argument value was passed as default parameter in the |
||
'proxies':proxies, | ||
'timeout':timeout, | ||
"enable_pii": enable_pii, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more natural that we do the other way around, i.e. env var will be ignored if function argument is explicitly provided? I know there might not be an industry standard on this behavior but, it happens that the Python standard lib
urllib
uses the same approach as what I suggested here:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @rayluo on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, in progress