Closed Bug 1679724 Opened 5 years ago Closed 1 year ago

Invalid OAuth2 settings in config for Office 365 when using Exchange Autodiscover service

Categories

(Thunderbird :: Account Manager, defect)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: david.ward, Assigned: BenB)

References

Details

(Whiteboard: [patchlove])

Attachments

(2 files, 2 obsolete files)

When support for the Exchange Autodiscover service was implemented in Thunderbird, it produced a config with OAuth2 settings, using the URI for either OWA or EWS as the OAuth2 scope.

This is not valid for Office 365, where the required scopes are specifically defined. For any other Exchange server, OAuth 2.0 cannot be used since the registration details (client ID, client secret, authorization endpoint, and token endpoint) are not known to Thunderbird; in this case, OAuth 2.0 settings should not be added here at all.

This allows common code for applying certain settings to each protocol,
such as auth method and username. This also ensures that if an exception
occurs, only complete protocol settings are returned in the config.

Each Exchange-specific protocol ("WEB", "EXHTTP", or "EXCH") is returned
as a separate alternative server in the config.

This uses the correct provider settings for Office 365. Otherwise OAuth2
is disabled since these settings are unknown.

Depends on D98131

Hey David,

thanks for the patches. I'll have to wrap my head around the fixes.

Bug 1679724 - Part 2: Apply known OAuth2 settings when using Exchange Autodiscover.

I understand that you're now correctly populating the scope and issuer fields. That's great, thanks for that.

However, please keep the original code logic. It added both authentication methods as alternatives, and that was intentional. If password auth is available, we want to know that, and we actually prefer that. As it is, the patch is risking to break quite a lot downstream.

So, please keep the code logic exactly as it is, but simply set the scope and issuer as from the OAuth module, as you do.

Comment on attachment 9190206 [details]
Bug 1679724 - Part 1: Refactor code iterating over Exchange Autodiscover response.

Bug 1679724 - Part 1: Refactor code iterating over Exchange Autodiscover response.

Sorry, I fail to understand the need for this patch.

Also, if I'm reading the patch correctly, it creates an invalid AccountConfig object, because the config.incoming properties are not populated, and everything are alternatives. The AccountConfig object has one config.incoming primary config, and 0 or more alternatives.

Each Exchange-specific protocol ("WEB", "EXHTTP", or "EXCH") is returned as a separate alternative server in the config.

Have you actually tested this, for all cases? I don't think this is going to work properly.

r- on part 1

Attachment #9190206 - Flags: review-

Comment on attachment 9190207 [details]
Bug 1679724 - Part 2: Apply known OAuth2 settings when using Exchange Autodiscover.

r- for the logic changes

The scope change is good. Please make a new patch with only that.

Attachment #9190207 - Flags: review-
Attached patch Fix scope, v3 (obsolete) — Splinter Review

Hey David, this is the actual fix from your patches.
Could you please test whether that fixes the issue for you? I haven't tested them yet.

Assignee: nobody → ben.bucksch
Attachment #9190206 - Attachment is obsolete: true
Attachment #9190207 - Attachment is obsolete: true
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9190300 - Flags: review?(neil)
Attachment #9190300 - Flags: feedback?(david.ward)
Attachment #9190300 - Flags: review?(neil)

Fix the on-premise Exchange case where there is no OAuth2 config.

Attachment #9190300 - Attachment is obsolete: true
Attachment #9190300 - Flags: feedback?(david.ward)
Attachment #9190302 - Flags: feedback?(david.ward)

Hi Ben,

Thanks for the comments. The changes are marked in Phabricator as draft and are not submitted for review yet.

It added both authentication methods as alternatives, and that was intentional. If password auth is available, we want to know that, and we actually prefer that.

  • In the existing code, SPA is not an alternative auth method to cleartext — or vice versa. If SPA is enabled, it simply overwrites the current auth method.
  • In Thunderbird, OAuth2 should only be set as an auth method (or alternative auth method) if the specific OAuth2 provider details are found here. So this change is necessary.

Also, if I'm reading the patch correctly, it creates an invalid AccountConfig object, because the config.incoming properties are not populated, and everything are alternatives.

config.incoming is populated unless it already exists; otherwise it adds the protocol to config.incomingAlternatives:

        if (!config.incoming.hostname) {
          config.incoming = server;
        } else {
          config.incomingAlternatives.push(server);
        }

See next comment:

Sorry, I fail to understand the need for this patch.

What happens if IMAP or POP3 setting appear before the others in the XML file, rather than after? Wouldn't those protocol settings be clobbered by the EWS or OWA settings, or is something enforcing an order when iterating over the protocols that I am missing? With that and the comment below in mind, it would be helpful to make the behavior of this code a bit more explicit.

Have you actually tested this, for all cases? I don't think this is going to work properly.

This part is unclear to me, and I don't have the ability to test directly (part of why this remains a draft). I can see where a single Exchange protocol in the configuration might be needed instead. But what is the preference order among protocols? Should settings for EXHTTP taken first, followed by EXCH, etc.? Right now the settings are simply overwritten each time it iterates over another protocol.

Ultimately, we need a way to consistently apply both the OAuth2 method, and the issuer/scope, for each protocol — if we have server support for it. This is a starting point. If you could help provide an understanding of what needs to be handled differently when obtaining the EWS/OWA-specific protocol configuration, that would be helpful.

Comment on attachment 9190302 [details] [diff] [review] Fix OAuth2 scope, v4 Review of attachment 9190302 [details] [diff] [review]: ----------------------------------------------------------------- No, the OAuth2 method and issuer/scope should not be set unless we know them. See previous comment.
Attachment #9190207 - Attachment is obsolete: false
Attachment #9190302 - Flags: feedback?(david.ward)
Whiteboard: [patchlove]
See Also: → 1859654
See Also: → 1679711
Summary: Invalid OAuth2 settings in config when using Exchange Autodiscover service → Invalid OAuth2 settings in config for Office 365 when using Exchange Autodiscover service
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: