Index: component/univention-office365/modules/univention/office365/azure_auth.py =================================================================== --- component/univention-office365/modules/univention/office365/azure_auth.py (Revision 80300) +++ component/univention-office365/modules/univention/office365/azure_auth.py (Arbeitskopie) @@ -53,6 +53,7 @@ from univention.lib.i18n import Translation from univention.office365.logging2udebug import get_logger from univention.config_registry.frontend import ucr_update +from univention.config_registry import ConfigRegistry _ = Translation('univention-office365').translate @@ -78,6 +79,8 @@ federation_metadata_url = "https://login.microsoftonline.com/{tenant_id}/federationmetadata/2007-06/federationmetadata.xml" resource_url = "https://graph.windows.net" +ucr = ConfigRegistry() +ucr.load() logger = get_logger("office365", "o365") @@ -219,6 +222,15 @@ json.dump(data, fd) +def get_http_proxies(): + res = dict() + if ucr['proxy/http']: + res['http'] = ucr['proxy/http'] + if ucr['proxy/https']: + res['https'] = ucr['proxy/https'] + return res + + class AzureAuth(object): def __init__(self, name): @@ -368,7 +380,7 @@ # the certificates with which the tokens were signed can be downloaded from the federation metadata document # https://msdn.microsoft.com/en-us/library/azure/dn195592.aspx try: - fed = requests.get(federation_metadata_url.format(tenant_id=tenant_id)) + fed = requests.get(federation_metadata_url.format(tenant_id=tenant_id), proxies=get_http_proxies()) except RequestException as exc: logger.exception("Error downloading federation metadata.") raise TokenValidationError, TokenValidationError(_("Error downloading certificates from Azure. Please run the wizard again."), chained_exc=exc), sys.exc_info()[2] @@ -459,7 +471,7 @@ url = oauth2_token_url.format(tenant_id=self.tenant_id) logger.debug("POST to URL=%r with data=%r", url, post_form) - response = requests.post(url, data=post_form, verify=True) + response = requests.post(url, data=post_form, verify=True, proxies=get_http_proxies()) if response.status_code != 200: logger.exception("Error retrieving token (status %r), response: %r", response.status_code, response.__dict__)