@@ -113,7 +113,7 @@ def _create_jwt_args(self, endpoint):
113113 return jwt_args
114114
115115 def __init__ (self , client_id , client_secret , host ,
116- redirect_uri , duo_certs = DEFAULT_CA_CERT_PATH , use_duo_code_attribute = True ):
116+ redirect_uri , duo_certs = DEFAULT_CA_CERT_PATH , use_duo_code_attribute = True , http_proxy = None ):
117117 """
118118 Initializes instance of Client class
119119
@@ -125,6 +125,7 @@ def __init__(self, client_id, client_secret, host,
125125 redirect_uri -- Uri to redirect to after a successful auth
126126 duo_certs -- (Optional) Provide custom CA certs
127127 use_duo_code_attribute -- (Optional: default true) Flag to use `duo_code` instead of `code` for returned authorization parameter
128+ http_proxy -- (Optional) HTTP proxy to tunnel requests through
128129 """
129130
130131 self ._validate_init_config (client_id ,
@@ -148,6 +149,11 @@ def __init__(self, client_id, client_secret, host,
148149 else :
149150 self ._duo_certs = DEFAULT_CA_CERT_PATH
150151
152+ if http_proxy is not None :
153+ self ._http_proxy = {'https' : http_proxy }
154+ else :
155+ self ._http_proxy = None
156+
151157 def generate_state (self ):
152158 """
153159 Return a random string of 36 characters
@@ -181,7 +187,8 @@ def health_check(self):
181187 try :
182188 response = requests .post (health_check_endpoint ,
183189 data = all_args ,
184- verify = self ._duo_certs )
190+ verify = self ._duo_certs ,
191+ proxies = self ._http_proxy )
185192 res = json .loads (response .content )
186193 if res ['stat' ] != 'OK' :
187194 raise DuoException (res )
@@ -282,7 +289,8 @@ def exchange_authorization_code_for_2fa_result(self, duoCode, username, nonce=No
282289 params = all_args ,
283290 headers = {"user-agent" :
284291 user_agent },
285- verify = self ._duo_certs )
292+ verify = self ._duo_certs ,
293+ proxies = self ._http_proxy )
286294 except Exception as e :
287295 raise DuoException (e )
288296
0 commit comments