Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Microsoft xoauth2 support #7722

Merged
merged 1 commit into from Jan 25, 2023
Merged

Conversation

ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented Dec 2, 2022

Fixes #6591

Todo

@ChristophWurst
Copy link
Member Author

User UI

I'm facing a little challenge here.

Generally speaking, IMAP accounts with password auth require us to ask the user for a password. XOAUTH2 accounts do not need a password but use a popup screen for the vendor.

With the Gmail XOAUTH2 integration I chose to hide the password input as soon as someone enters an email address that ends with @gmail.com. This works. But it only works for Gmail accounts with the default Gmail domain. Any custom domain hosted by Google falls short. This was acceptable for a first version.

Now, with Microsoft, it seems even more likely that someone uses a domain that doesn't easily allow us to detect it's hosted by Microsoft. Some accounts seem to end with @onmicrosoft.com but there are many more.

A more sophisticated approach for detecting Gmail and Microsoft accounts is to use the IMAP and SMTP hosts found by auto config detection. But auto config detection only happens after the user clicks on Connect. At that point we should already have hidden the password, or not.

So there are at least two approaches we can take here.

  1. Always show the password input, but no longer make it required for auto mode. Manual mode stays as is.
    If we detect that the account uses password auth then we abort the setup right after auto detection
    If we detect that it's a Gmail or Microsoft account we just discard the password.
  2. Change the setup into a multi step dialogue
    1. Ask for the name and email address
    2. Perform auto detection in the background
    3. If XOAUTH2, open the vendor popup
    4. If config for a password account could be detected, ask for the password
    5. If no config could be detected, show the manual setup

For simplicity I'll probably go with the first one.

@julianfairfax
Copy link

User UI

I'm facing a little challenge here.

Generally speaking, IMAP accounts with password auth require us to ask the user for a password. XOAUTH2 accounts do not need a password but use a popup screen for the vendor.

With the Gmail XOAUTH2 integration I chose to hide the password input as soon as someone enters an email address that ends with @gmail.com. This works. But it only works for Gmail accounts with the default Gmail domain. Any custom domain hosted by Google falls short. This was acceptable for a first version.

Now, with Microsoft, it seems even more likely that someone uses a domain that doesn't easily allow us to detect it's hosted by Microsoft. Some accounts seem to end with @onmicrosoft.com but there are many more.

A more sophisticated approach for detecting Gmail and Microsoft accounts is to use the IMAP and SMTP hosts found by auto config detection. But auto config detection only happens after the user clicks on Connect. At that point we should already have hidden the password, or not.

So there are at least two approaches we can take here.

1. Always show the password input, but no longer make it required for auto mode. Manual mode stays as is.
   If we detect that the account uses password auth then we abort the setup right after auto detection
   If we detect that it's a Gmail or Microsoft account we just discard the password.

2. Change the setup into a multi step dialogue
   
   1. Ask for the name and email address
   2. Perform auto detection in the background
   3. If XOAUTH2, open the vendor popup
   4. If config for a password account could be detected, ask for the password
   5. If no config could be detected, show the manual setup

For simplicity I'll probably go with the first one.

I'm looking forward to seeing this support in Nextcloud Mail!

@ChristophWurst
Copy link
Member Author

Tada

Bildschirmfoto vom 2023-01-19 11-39-35

@julianfairfax
Copy link

When this is merged, how long will it take to receive it as an update?

@ChristophWurst
Copy link
Member Author

Please be patient and refrain from commenting on PRs unless the comment adds value to the code changes or discussion. We are struggling too many notifications already. The comments just slow us down. Thank you.

appinfo/routes.php Outdated Show resolved Hide resolved
Copy link
Contributor

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works with my personal account.

@ChristophWurst ChristophWurst force-pushed the feature/microsoft-oauth2 branch 3 times, most recently from 6faf6ef to c6f540a Compare January 20, 2023 16:29
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst merged commit 8abe02a into main Jan 25, 2023
27 of 28 checks passed
@ChristophWurst ChristophWurst deleted the feature/microsoft-oauth2 branch January 25, 2023 17:08
@ChristophWurst ChristophWurst added this to the v2.3.0 milestone Jan 26, 2023
@flowlee

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Microsoft 365 changes Oct 1 2022 and the effect on this app
5 participants