Blame SOURCES/evolution-ews-3.28.5-oauth2-simplify.patch

068f62
From bf0f75de095dc7ecb7171ab61009fab2631b4bee Mon Sep 17 00:00:00 2001
068f62
From: Luca Boccassi <luca.boccassi@microsoft.com>
068f62
Date: Tue, 2 Apr 2019 16:06:35 +0200
068f62
Subject: [PATCH] M!1 - Simplify OAuth2 for outlook.office365.com server
068f62
068f62
Two changes:
068f62
1) preset default tenant to "common"
068f62
2) do not pass 'scope' parameter in the requests, which is optional
068f62
   and can cause errors like:
068f62
   error:invalid_request description:AADSTS65002:
068f62
   Consent between first party applications and resources must be
068f62
   configured via preauthorization.
068f62
068f62
Closes https://gitlab.gnome.org/GNOME/evolution-ews/merge_requests/1
068f62
---
068f62
 CMakeLists.txt                                |  2 +-
068f62
 src/configuration/e-mail-config-ews-backend.c | 15 +++------------
068f62
 src/server/e-oauth2-service-office365.c       | 17 -----------------
068f62
 3 files changed, 4 insertions(+), 30 deletions(-)
068f62
068f62
diff --git a/CMakeLists.txt b/CMakeLists.txt
068f62
index e8ea9875..dbc58832 100644
068f62
--- a/CMakeLists.txt
068f62
+++ b/CMakeLists.txt
068f62
@@ -180,7 +180,7 @@ endif(ENABLE_TESTS)
068f62
 add_printable_variable(WITH_OFFICE365_TENANT "Office365.com OAuth 2.0 tenant" "")
068f62
 
068f62
 if(WITH_OFFICE365_TENANT STREQUAL "")
068f62
-	set(WITH_OFFICE365_TENANT "")
068f62
+	set(WITH_OFFICE365_TENANT "common")
068f62
 endif(WITH_OFFICE365_TENANT STREQUAL "")
068f62
 
068f62
 add_printable_variable(WITH_OFFICE365_CLIENT_ID "Office365.com OAuth 2.0 client ID" "")
068f62
diff --git a/src/configuration/e-mail-config-ews-backend.c b/src/configuration/e-mail-config-ews-backend.c
068f62
index fbf341b2..e62d3922 100644
068f62
--- a/src/configuration/e-mail-config-ews-backend.c
068f62
+++ b/src/configuration/e-mail-config-ews-backend.c
068f62
@@ -348,9 +348,9 @@ mail_config_ews_backend_insert_widgets (EMailConfigServiceBackend *backend,
068f62
 		G_BINDING_SYNC_CREATE);
068f62
 
068f62
 	mail_config_ews_backend_set_oauth2_tooltip (widget, OFFICE365_TENANT,
068f62
-		/* Translators: 'Tenant' here means a term used by Microsoft to identify a company or organization in an Office 365 world.
068f62
+		/* Translators: 'Tenant' here means a term used by Microsoft to identify a company or organization in an Office 365 world. Same for 'common', it's a default URL path.
068f62
 		   You probably do not want to translate it. More for example here: https://powerbi.microsoft.com/en-us/blog/what-is-a-tenant/ */
068f62
-		_("There is not set any default tenant"),
068f62
+		_("Default tenant is “common“"),
068f62
 		/* Translators: 'Tenant' here means a term used by Microsoft to identify a company or organization in an Office 365 world.
068f62
 		   You probably do not want to translate it. More for example here: https://powerbi.microsoft.com/en-us/blog/what-is-a-tenant/ */
068f62
 		g_strdup_printf (_("Default tenant is “%s”"), OFFICE365_TENANT));
068f62
@@ -586,23 +586,14 @@ mail_config_ews_backend_check_complete (EMailConfigServiceBackend *backend)
068f62
 	e_util_set_entry_issue_hint (priv->user_entry, correct ? NULL : _("User name cannot be empty"));
068f62
 
068f62
 	if (correct && camel_ews_settings_get_auth_mechanism (ews_settings) == EWS_AUTH_TYPE_OAUTH2) {
068f62
-		const gchar *tenant, *client_id;
068f62
+		const gchar *client_id;
068f62
 
068f62
 		if (camel_ews_settings_get_override_oauth2 (ews_settings)) {
068f62
-			tenant = camel_ews_settings_get_oauth2_tenant (ews_settings);
068f62
 			client_id = camel_ews_settings_get_oauth2_client_id (ews_settings);
068f62
 		} else {
068f62
-			tenant = OFFICE365_TENANT;
068f62
 			client_id = OFFICE365_CLIENT_ID;
068f62
 		}
068f62
 
068f62
-		correct = tenant && *tenant;
068f62
-		complete = complete && correct;
068f62
-
068f62
-		/* Translators: 'Tenant' here means a term used by Microsoft to identify a company or organization in an Office 365 world.
068f62
-		   You probably do not want to translate it. More for example here: https://powerbi.microsoft.com/en-us/blog/what-is-a-tenant/ */
068f62
-		e_util_set_entry_issue_hint (priv->oauth2_tenant_entry, correct ? NULL : _("Tenant cannot be empty"));
068f62
-
068f62
 		correct = client_id && *client_id;
068f62
 		complete = complete && correct;
068f62
 
068f62
diff --git a/src/server/e-oauth2-service-office365.c b/src/server/e-oauth2-service-office365.c
068f62
index 4be84f6f..d660458c 100644
068f62
--- a/src/server/e-oauth2-service-office365.c
068f62
+++ b/src/server/e-oauth2-service-office365.c
068f62
@@ -30,21 +30,6 @@
068f62
 
068f62
 #define OFFICE365_RESOURCE "https://outlook.office.com"
068f62
 
068f62
-#define OFFICE365_SCOPE "openid offline_access profile " \
068f62
-	"Mail.ReadWrite " \
068f62
-	"Mail.ReadWrite.Shared " \
068f62
-	"Mail.Send " \
068f62
-	"Mail.Send.Shared " \
068f62
-	"Calendars.ReadWrite " \
068f62
-	"Calendars.ReadWrite.Shared " \
068f62
-	"Contacts.ReadWrite " \
068f62
-	"Contacts.ReadWrite.Shared " \
068f62
-	"Tasks.ReadWrite " \
068f62
-	"Tasks.ReadWrite.Shared " \
068f62
-	"MailboxSettings.ReadWrite " \
068f62
-	"People.Read " \
068f62
-	"User.ReadBasic.All"
068f62
-
068f62
 struct _EOAuth2ServiceOffice365Private
068f62
 {
068f62
 	GMutex string_cache_lock;
068f62
@@ -253,7 +238,6 @@ eos_office365_prepare_authentication_uri_query (EOAuth2Service *service,
068f62
 
068f62
 	e_oauth2_service_util_set_to_form (uri_query, "response_mode", "query");
068f62
 	e_oauth2_service_util_set_to_form (uri_query, "prompt", "login");
068f62
-	e_oauth2_service_util_set_to_form (uri_query, "scope", OFFICE365_SCOPE);
068f62
 	e_oauth2_service_util_set_to_form (uri_query, "resource", OFFICE365_RESOURCE);
068f62
 }
068f62
 
068f62
@@ -321,7 +305,6 @@ eos_office365_prepare_refresh_token_form (EOAuth2Service *service,
068f62
 {
068f62
 	g_return_if_fail (form != NULL);
068f62
 
068f62
-	e_oauth2_service_util_set_to_form (form, "scope", OFFICE365_SCOPE);
068f62
 	e_oauth2_service_util_set_to_form (form, "resource", OFFICE365_RESOURCE);
068f62
 	e_oauth2_service_util_set_to_form (form, "redirect_uri", e_oauth2_service_get_redirect_uri (service, source));
068f62
 }
068f62
-- 
068f62
GitLab
068f62