Skip to content

Commit

Permalink
be more explicit about gdrive roles allowed access revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
felliott committed May 26, 2017
1 parent 3ee47cb commit 9d6810d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion waterbutler/providers/googledrive/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class GoogleDriveProvider(provider.BaseProvider):
BASE_URL = settings.BASE_URL
FOLDER_MIME_TYPE = 'application/vnd.google-apps.folder'

# https://developers.google.com/drive/v2/web/about-permissions#roles
# 'reader' and 'commenter' are not authorized to access the revisions list
ROLES_ALLOWING_REVISIONS = ['owner', 'organizer', 'writer']

def __init__(self, auth, credentials, settings):
super().__init__(auth, credentials, settings)
self.token = self.credentials['token']
Expand Down Expand Up @@ -667,7 +671,7 @@ async def _file_metadata(self, path: GoogleDrivePath, revision: str=None, raw: b

user_role = data['userPermission']['role']
self.metrics.add('_file_metadata.user_role', user_role)
can_access_revisions = user_role in ('owner')
can_access_revisions = user_role in self.ROLES_ALLOWING_REVISIONS
if drive_utils.is_docs_file(data):
if can_access_revisions:
return await self._handle_docs_versioning(path, data, raw=raw)
Expand Down

0 comments on commit 9d6810d

Please sign in to comment.