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

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