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

onedrive: about the Sites.Read.All permission request #5883

Merged
merged 2 commits into from
Jan 10, 2022

Conversation

cqjjjzr
Copy link
Contributor

@cqjjjzr cqjjjzr commented Dec 25, 2021

What is the purpose of this change?

In fix of #1770 , a new permission request was added in the OneDrive backend support: Sites.Read.All. This is intended to solve the error when using a custom SharePoint site. However, such changes are undocumented.

On a domain with an excessively strict authorization policy (e.g. my university), the domain disallows users to consent permissions on their own and the Sites.Read.All permission is undocumented thus not configured, the extra Sites.Read.All scope when requesting an access token will trigger "Application needs permission to access resources in your organization that only an admin can grant. Please ask an admin to grant permission to this app before you can use it." message.

Therefore, this PR involves a new advanced config entry disable_site_permission (default to false). When turned on, this config will prevent the OAuth client to request Sites.Read.All permission. The "Search for a SharePoint site" may be unusable because of this, but for those under a strict policy who don't need custom site configuration, this should be enough.

For the documentation, since I'm unfamiliar with the documentation structure, I didn't attempt to include all documentation for this. Instructions on writing docs will be much appreciated

Was the change discussed in an issue or in the forum before?

See #1770

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate. (not applicable)
  • I have added documentation for the changes if appropriate. (See above)
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@cqjjjzr
Copy link
Contributor Author

cqjjjzr commented Dec 29, 2021

I added (partial) docs about the Sites.Read.All permission.

Copy link
Member

@Cnly Cnly left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @cqjjjzr! Please see my comments below :)

backend/onedrive/onedrive.go Show resolved Hide resolved
@@ -374,6 +388,12 @@ func Config(ctx context.Context, name string, m configmap.Mapper, config fs.Conf
region, graphURL := getRegionURL(m)

if config.State == "" {
disableSitePermission, ok := m.Get("disable_site_permission")
if disableSitePermission == "true" && ok {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if disableSitePermission == "true" && ok {
if ok && disableSitePermission == "true" {

Usually we put ok before the value predicate. Or we can just remove it here.

Copy link
Member

Choose a reason for hiding this comment

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

After some more thinking I think we should just remove the check on ok to allow possible changes to the default value. If at some later point we decided true will be better as the default, the ok check here will break that as it assumes false should be the default.

backend/onedrive/onedrive.go Show resolved Hide resolved
@@ -132,7 +132,7 @@ Client ID and Key by following the steps below:
2. Enter a name for your app, choose account type `Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)`, select `Web` in `Redirect URI`, then type (do not copy and paste) `http://localhost:53682/` and click Register. Copy and keep the `Application (client) ID` under the app name for later use.
3. Under `manage` select `Certificates & secrets`, click `New client secret`. Enter a description (can be anything) and set `Expires` to 24 months. Copy and keep that secret _Value_ for later use (you _won't_ be able to see this value afterwards).
4. Under `manage` select `API permissions`, click `Add a permission` and select `Microsoft Graph` then select `delegated permissions`.
5. Search and select the following permissions: `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All`, `offline_access`, `User.Read`. Once selected click `Add permissions` at the bottom.
5. Search and select the following permissions: `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All`, `offline_access`, `User.Read`, `Sites.Read.All` (optional). Once selected click `Add permissions` at the bottom.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
5. Search and select the following permissions: `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All`, `offline_access`, `User.Read`, `Sites.Read.All` (optional). Once selected click `Add permissions` at the bottom.
5. Search and select the following permissions: `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All`, `offline_access`, `User.Read`, and optionally `Sites.Read.All` (see below). Once selected click `Add permissions` at the bottom.

Perhaps this and an extra sentence below explaining the option & linking to the issue #1770 would be better.

@cqjjjzr
Copy link
Contributor Author

cqjjjzr commented Jan 10, 2022

Should I push multiple commits or squash them using rebase and do a force push?

@Cnly
Copy link
Member

Cnly commented Jan 10, 2022

You don't need to force push :) Force pushing will probably mess up with the review history. Just push them normally and everything will be squashed before merging into master.

@cqjjjzr cqjjjzr requested a review from Cnly January 10, 2022 09:19
Copy link
Member

@Cnly Cnly left a comment

Choose a reason for hiding this comment

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

Many thanks! I'll merge this now.

@Cnly Cnly merged commit bc23bf1 into rclone:master Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants