diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-05 18:27:14 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-05 18:27:14 -0500 |
commit | 03590a6711d601ef3ddb48787e9f3f556705b5db (patch) | |
tree | b5985c23741cd03fd0ed32537773e07db2d7d21d /mailnews/base/prefs | |
parent | 714afc76f690ba11e77330e067e5bce486292831 (diff) | |
download | UXP-03590a6711d601ef3ddb48787e9f3f556705b5db.tar UXP-03590a6711d601ef3ddb48787e9f3f556705b5db.tar.gz UXP-03590a6711d601ef3ddb48787e9f3f556705b5db.tar.lz UXP-03590a6711d601ef3ddb48787e9f3f556705b5db.tar.xz UXP-03590a6711d601ef3ddb48787e9f3f556705b5db.zip |
Issue #1258 - Part 8: Ifdef MailNews OAuth2 Support
Use --disable-mailnews-oauth2 to exclude it. Confvars won't be respected.
Diffstat (limited to 'mailnews/base/prefs')
12 files changed, 50 insertions, 1 deletions
diff --git a/mailnews/base/prefs/content/accountcreation/accountConfig.js b/mailnews/base/prefs/content/accountcreation/accountConfig.js index 3a757d8ee..752c72624 100644 --- a/mailnews/base/prefs/content/accountcreation/accountConfig.js +++ b/mailnews/base/prefs/content/accountcreation/accountConfig.js @@ -50,8 +50,10 @@ AccountConfig.prototype = */ incomingAlternatives : null, outgoingAlternatives : null, +#ifdef MOZ_MAILNEWS_OAUTH2 // OAuth2 configuration, if needed. oauthSettings : null, +#endif // just an internal string to refer to this. Do not show to user. id : null, // who created the config. diff --git a/mailnews/base/prefs/content/accountcreation/createInBackend.js b/mailnews/base/prefs/content/accountcreation/createInBackend.js index d959c3ae9..cd984fd3c 100644 --- a/mailnews/base/prefs/content/accountcreation/createInBackend.js +++ b/mailnews/base/prefs/content/accountcreation/createInBackend.js @@ -28,10 +28,12 @@ function createAccountInBackend(config) if (config.rememberPassword && config.incoming.password.length) rememberPassword(inServer, config.incoming.password); +#ifdef MOZ_MAILNEWS_OAUTH2 if (inServer.authMethod == Ci.nsMsgAuthMethod.OAuth2) { inServer.setCharValue("oauth2.scope", config.oauthSettings.scope); inServer.setCharValue("oauth2.issuer", config.oauthSettings.issuer); } +#endif // SSL if (config.incoming.socketType == 1) // plain @@ -107,6 +109,7 @@ function createAccountInBackend(config) rememberPassword(outServer, config.incoming.password); } +#ifdef MOZ_MAILNEWS_OAUTH2 if (outServer.authMethod == Ci.nsMsgAuthMethod.OAuth2) { let pref = "mail.smtpserver." + outServer.key + "."; Services.prefs.setCharPref(pref + "oauth2.scope", @@ -114,6 +117,7 @@ function createAccountInBackend(config) Services.prefs.setCharPref(pref + "oauth2.issuer", config.oauthSettings.issuer); } +#endif if (config.outgoing.socketType == 1) // no SSL outServer.socketType = Ci.nsMsgSocketType.plain; diff --git a/mailnews/base/prefs/content/accountcreation/emailWizard.js b/mailnews/base/prefs/content/accountcreation/emailWizard.js index b4e6854da..389feab6c 100644 --- a/mailnews/base/prefs/content/accountcreation/emailWizard.js +++ b/mailnews/base/prefs/content/accountcreation/emailWizard.js @@ -6,7 +6,9 @@ Components.utils.import("resource:///modules/mailServices.js"); Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource:///modules/hostnameUtils.jsm"); +#ifdef MOZ_MAILNEWS_OAUTH2 Components.utils.import("resource://gre/modules/OAuth2Providers.jsm"); +#endif /** * This is the dialog opened by menu File | New account | Mail... . @@ -184,7 +186,9 @@ EmailConfigWizard.prototype = "authPasswordEncrypted"); setLabelFromStringBundle("in-authMethod-kerberos", "authKerberos"); setLabelFromStringBundle("in-authMethod-ntlm", "authNTLM"); +#ifdef MOZ_MAILNEWS_OAUTH2 setLabelFromStringBundle("in-authMethod-oauth2", "authOAuth2"); +#endif setLabelFromStringBundle("out-authMethod-no", "authNo"); setLabelFromStringBundle("out-authMethod-password-cleartext", "authPasswordCleartextViaSSL"); // will warn about insecure later @@ -1014,7 +1018,11 @@ EmailConfigWizard.prototype = e("incoming_ssl").value = sanitize.enum(config.incoming.socketType, [ 0, 1, 2, 3 ], 0); e("incoming_authMethod").value = sanitize.enum(config.incoming.auth, +#ifdef MOZ_MAILNEWS_OAUTH2 [ 0, 3, 4, 5, 6, 10 ], 0); +#else + [ 0, 3, 4, 5, 6 ], 0); +#endif e("incoming_username").value = config.incoming.username; if (config.incoming.port) { e("incoming_port").value = config.incoming.port; @@ -1023,6 +1031,7 @@ EmailConfigWizard.prototype = } this.fillPortDropdown(config.incoming.type); +#ifdef MOZ_MAILNEWS_OAUTH2 // If the hostname supports OAuth2 and imap is enabled, enable OAuth2. let iDetails = OAuth2Providers.getHostnameDetails(config.incoming.hostname); gEmailWizardLogger.info("OAuth2 details for incoming hostname " + @@ -1035,6 +1044,7 @@ EmailConfigWizard.prototype = // store them in the base configuration. this._currentConfig.oauthSettings = config.oauthSettings; } +#endif // outgoing server e("outgoing_hostname").value = config.outgoing.hostname; @@ -1052,6 +1062,7 @@ EmailConfigWizard.prototype = this.adjustOutgoingPortToSSLAndProtocol(config); } +#ifdef MOZ_MAILNEWS_OAUTH2 // If the hostname supports OAuth2 and imap is enabled, enable OAuth2. let oDetails = OAuth2Providers.getHostnameDetails(config.outgoing.hostname); gEmailWizardLogger.info("OAuth2 details for outgoing hostname " + @@ -1064,6 +1075,7 @@ EmailConfigWizard.prototype = // store them in the base configuration. this._currentConfig.oauthSettings = config.oauthSettings; } +#endif // populate fields even if existingServerKey, in case user changes back if (config.outgoing.existingServerKey) { @@ -1614,10 +1626,12 @@ EmailConfigWizard.prototype = self._currentConfig.incoming.username = successfulConfig.incoming.username; self._currentConfig.outgoing.username = successfulConfig.outgoing.username; +#ifdef MOZ_MAILNEWS_OAUTH2 // We loaded dynamic client registration, fill this data back in to the // config set. if (successfulConfig.oauthSettings) self._currentConfig.oauthSettings = successfulConfig.oauthSettings; +#endif self.finish(); }, diff --git a/mailnews/base/prefs/content/accountcreation/emailWizard.xul b/mailnews/base/prefs/content/accountcreation/emailWizard.xul index 0777d1651..261545671 100644 --- a/mailnews/base/prefs/content/accountcreation/emailWizard.xul +++ b/mailnews/base/prefs/content/accountcreation/emailWizard.xul @@ -309,7 +309,9 @@ <menuitem id="in-authMethod-password-encrypted" value="4"/> <menuitem id="in-authMethod-kerberos" value="5"/> <menuitem id="in-authMethod-ntlm" value="6"/> +#ifdef MOZ_MAILNEWS_OAUTH2 <menuitem id="in-authMethod-oauth2" value="10" hidden="true"/> +#endif </menupopup> </menulist> </row> @@ -359,7 +361,9 @@ <menuitem id="out-authMethod-password-encrypted" value="4"/> <menuitem id="out-authMethod-kerberos" value="5"/> <menuitem id="out-authMethod-ntlm" value="6"/> +#ifdef MOZ_MAILNEWS_OAUTH2 <menuitem id="out-authMethod-oauth2" value="10" hidden="true"/> +#endif </menupopup> </menulist> </row> diff --git a/mailnews/base/prefs/content/accountcreation/guessConfig.js b/mailnews/base/prefs/content/accountcreation/guessConfig.js index 755c499cd..9a44f7904 100644 --- a/mailnews/base/prefs/content/accountcreation/guessConfig.js +++ b/mailnews/base/prefs/content/accountcreation/guessConfig.js @@ -60,11 +60,13 @@ function guessConfig(domain, progressCallback, successCallback, errorCallback, assert(typeof(successCallback) == "function", "need successCallback"); assert(typeof(errorCallback) == "function", "need errorCallback"); +#ifdef MOZ_MAILNEWS_OAUTH2 // Servers that we know enough that they support OAuth2 do not need guessing. if (resultConfig.incoming.auth == Ci.nsMsgAuthMethod.OAuth2) { successCallback(resultConfig); return null; } +#endif if (!resultConfig) resultConfig = new AccountConfig(); diff --git a/mailnews/base/prefs/content/accountcreation/readFromXML.js b/mailnews/base/prefs/content/accountcreation/readFromXML.js index c7e796f5f..4ef13ec1d 100644 --- a/mailnews/base/prefs/content/accountcreation/readFromXML.js +++ b/mailnews/base/prefs/content/accountcreation/readFromXML.js @@ -95,7 +95,10 @@ function readFromXML(clientConfigXML) "secure" : Ci.nsMsgAuthMethod.passwordEncrypted, "GSSAPI" : Ci.nsMsgAuthMethod.GSSAPI, "NTLM" : Ci.nsMsgAuthMethod.NTLM, - "OAuth2" : Ci.nsMsgAuthMethod.OAuth2 }); +#ifdef MOZ_MAILNEWS_OAUTH2 + "OAuth2" : Ci.nsMsgAuthMethod.OAuth2 +#endif + }); break; // take first that we support } catch (e) { exception = e; } } @@ -176,7 +179,9 @@ function readFromXML(clientConfigXML) "secure" : Ci.nsMsgAuthMethod.passwordEncrypted, "GSSAPI" : Ci.nsMsgAuthMethod.GSSAPI, "NTLM" : Ci.nsMsgAuthMethod.NTLM, +#ifdef MOZ_MAILNEWS_OAUTH2 "OAuth2" : Ci.nsMsgAuthMethod.OAuth2, +#endif }); break; // take first that we support diff --git a/mailnews/base/prefs/content/accountcreation/verifyConfig.js b/mailnews/base/prefs/content/accountcreation/verifyConfig.js index a2afbdad8..26fa7967e 100644 --- a/mailnews/base/prefs/content/accountcreation/verifyConfig.js +++ b/mailnews/base/prefs/content/accountcreation/verifyConfig.js @@ -30,7 +30,9 @@ */ Components.utils.import("resource:///modules/mailServices.js"); +#ifdef MOZ_MAILNEWS_OAUTH2 Components.utils.import("resource://gre/modules/OAuth2Providers.jsm"); +#endif if (typeof gEmailWizardLogger == "undefined") { Cu.import("resource:///modules/gloda/log4moz.js"); @@ -74,6 +76,7 @@ function verifyConfig(config, alter, msgWindow, successCallback, errorCallback) config.incoming.auth); inServer.authMethod = config.incoming.auth; +#ifdef MOZ_MAILNEWS_OAUTH2 try { // Lookup issuer if needed. if (config.incoming.auth == Ci.nsMsgAuthMethod.OAuth2 || @@ -100,6 +103,9 @@ function verifyConfig(config, alter, msgWindow, successCallback, errorCallback) if (inServer.password || inServer.authMethod == Ci.nsMsgAuthMethod.OAuth2) +#else + if (inServer.password) +#endif verifyLogon(config, inServer, alter, msgWindow, successCallback, errorCallback); else { diff --git a/mailnews/base/prefs/content/am-server.js b/mailnews/base/prefs/content/am-server.js index e3c2d2b09..01b22e4ae 100644 --- a/mailnews/base/prefs/content/am-server.js +++ b/mailnews/base/prefs/content/am-server.js @@ -31,7 +31,9 @@ function onInit(aPageId, aServerId) setupImapDeleteUI(aServerId); // TLS Cert (External) and OAuth2 are only supported on IMAP. +#ifdef MOZ_MAILNEWS_OAUTH2 document.getElementById("authMethod-oauth2").hidden = (serverType != "imap"); +#endif document.getElementById("authMethod-external").hidden = (serverType != "imap"); // "STARTTLS, if available" is vulnerable to MITM attacks so we shouldn't @@ -83,7 +85,9 @@ function initServerType() setLabelFromStringBundle("authMethod-kerberos", "authKerberos"); setLabelFromStringBundle("authMethod-external", "authExternal"); setLabelFromStringBundle("authMethod-ntlm", "authNTLM"); +#ifdef MOZ_MAILNEWS_OAUTH2 setLabelFromStringBundle("authMethod-oauth2", "authOAuth2"); +#endif setLabelFromStringBundle("authMethod-anysecure", "authAnySecure"); setLabelFromStringBundle("authMethod-any", "authAny"); setLabelFromStringBundle("authMethod-password-encrypted", diff --git a/mailnews/base/prefs/content/am-server.xul b/mailnews/base/prefs/content/am-server.xul index f52aef1cc..7828e4cf4 100644 --- a/mailnews/base/prefs/content/am-server.xul +++ b/mailnews/base/prefs/content/am-server.xul @@ -139,7 +139,9 @@ <menuitem id="authMethod-kerberos" value="5"/> <menuitem id="authMethod-ntlm" value="6"/> <menuitem id="authMethod-external" value="7"/> +#ifdef MOZ_MAILNEWS_OAUTH2 <menuitem id="authMethod-oauth2" value="10"/> +#endif <menuitem id="authMethod-anysecure" value="8"/> <menuitem id="authMethod-any" value="9"/> </menupopup> diff --git a/mailnews/base/prefs/content/am-smtp.js b/mailnews/base/prefs/content/am-smtp.js index f5e9ab38c..f107a32ae 100644 --- a/mailnews/base/prefs/content/am-smtp.js +++ b/mailnews/base/prefs/content/am-smtp.js @@ -140,9 +140,11 @@ var gSmtpServerListWindow = ? "authPasswordCleartextViaSSL" : "authPasswordCleartextInsecurely"; break; +#ifdef MOZ_MAILNEWS_OAUTH2 case AuthMethod.OAuth2: authStr = "authOAuth2"; break; +#endif default: // leave empty Components.utils.reportError("Warning: unknown value for smtpserver... authMethod: " + diff --git a/mailnews/base/prefs/content/smtpEditOverlay.js b/mailnews/base/prefs/content/smtpEditOverlay.js index 54590e1b2..d8d216065 100644 --- a/mailnews/base/prefs/content/smtpEditOverlay.js +++ b/mailnews/base/prefs/content/smtpEditOverlay.js @@ -53,7 +53,9 @@ function initSmtpSettings(server) { "authPasswordCleartextInsecurely"); setLabelFromStringBundle("authMethod-kerberos", "authKerberos"); setLabelFromStringBundle("authMethod-ntlm", "authNTLM"); +#ifdef MOZ_MAILNEWS_OAUTH2 setLabelFromStringBundle("authMethod-oauth2", "authOAuth2"); +#endif setLabelFromStringBundle("authMethod-anysecure", "authAnySecure"); setLabelFromStringBundle("authMethod-any", "authAny"); diff --git a/mailnews/base/prefs/content/smtpEditOverlay.xul b/mailnews/base/prefs/content/smtpEditOverlay.xul index f78916d2a..0bc900a3d 100644 --- a/mailnews/base/prefs/content/smtpEditOverlay.xul +++ b/mailnews/base/prefs/content/smtpEditOverlay.xul @@ -103,7 +103,9 @@ <menuitem id="authMethod-password-encrypted" value="4"/> <menuitem id="authMethod-kerberos" value="5"/> <menuitem id="authMethod-ntlm" value="6"/> +#ifdef MOZ_MAILNEWS_OAUTH2 <menuitem id="authMethod-oauth2" value="10"/> +#endif <menuitem id="authMethod-anysecure" value="8"/> <menuitem id="authMethod-any" value="9"/> </menupopup> |