abraunegg / onedrive

OneDrive Client for Linux
https://abraunegg.github.io
GNU General Public License v3.0
10.17k stars 865 forks source link

Configuration azure_tenant_id is ignored for default azure_ad_endpoint #1093

Closed sebastiaopf closed 4 years ago

sebastiaopf commented 4 years ago

Describe the bug Configuration azure_tenant_id is ignored for default azure_ad_endpoint. This prevents the client to authenticate agains a custom single tenant application in Azure.

Application and Operating System Details:

To Reproduce Steps to reproduce the behavior if not causing an application crash:

  1. Configure a new application in Azure and select "single tenant" (accounts in this organizational directory only)
  2. Configure application_id and azure_tenant_id on the config file (note that azure_tenant_id needs to be filled with the tenand name not the GUID.
  3. Try to authenticate by running onedrive.

Additional context I was having problems to configure the permissions needed for the default application created in Azure. Our domain admin has added all the permissions I could find on the source code, but the authentication link kept saying I needed admin approval. In order to add all the permissions needed he had to create a new application in Azure, and for security reasons it needed to be single tenant. The problem is that when you configure the application for single tenant the /common/ part on the OneDrive causes an authentication error. This value must be substituted by the tenant name, which can be configured using azure_tenant_id on the configuration file. But even after configuring this value I was getting the same error. I checked the sources and found that this configuration is not used unless a custom azure_ad_endpoint is used.

I've made a few changes to the source code and got it to work after changing the following lines on onedrive.d, starting at line 153:

                // Authentication
                authUrl = globalAuthEndpoint ~ "/" ~ tenantId ~ "/oauth2/v2.0/authorize";
                redirectUrl = globalAuthEndpoint ~ "/" ~ tenantId ~ "/oauth2/nativeclient";
                tokenUrl = globalAuthEndpoint ~ "/" ~ tenantId ~ "/oauth2/v2.0/token";

I can provide a patch file if needed.

Bug Report Checklist

abraunegg commented 4 years ago

@sebastiaopf As this is something I cannot readily test, please can you submit a PR with your changes for review.

sebastiaopf commented 4 years ago

Thank for reviewing this issue. I've created PR #1094.

abraunegg commented 4 years ago

PR merged into master

sebastiaopf commented 4 years ago

Thank you for this quick resolution and also for your work with such an useful tool.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.