-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Breaking Changes - Permission models #7517
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
Changes from all commits
59f0342
24b777a
ba0e662
01093ec
bdb8e45
11c7041
228a79f
51c4db4
1710da0
42e8d6b
89c7282
53a799a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,7 +277,7 @@ def __str__(self): | |
| ResourceTypes.OBJECT = ResourceTypes(object=True) | ||
|
|
||
|
|
||
| class AccountPermissions(object): | ||
| class AccountSasPermissions(object): | ||
| """ | ||
| :class:`~ResourceTypes` class to be used with generate_shared_access_signature | ||
| method and for the AccessPolicies used with set_*_acl. There are two types of | ||
|
|
@@ -286,25 +286,6 @@ class AccountPermissions(object): | |
| entire service for a specific account and allow certain operations based on | ||
| perms found here. | ||
|
|
||
| :cvar AccountPermissions AccountPermissions.ADD: | ||
| Valid for the following Object resource types only: queue messages and append blobs. | ||
| :cvar AccountPermissions AccountPermissions.CREATE: | ||
| Valid for the following Object resource types only: blobs and files. Users | ||
| can create new blobs or files, but may not overwrite existing blobs or files. | ||
| :cvar AccountPermissions AccountPermissions.DELETE: | ||
| Valid for Container and Object resource types, except for queue messages. | ||
| :cvar AccountPermissions AccountPermissions.LIST: | ||
| Valid for Service and Container resource types only. | ||
| :cvar AccountPermissions AccountPermissions.PROCESS: | ||
| Valid for the following Object resource type only: queue messages. | ||
| :cvar AccountPermissions AccountPermissions.READ: | ||
| Valid for all signed resources types (Service, Container, and Object). | ||
| Permits read permissions to the specified resource type. | ||
| :cvar AccountPermissions AccountPermissions.UPDATE: | ||
| Valid for the following Object resource types only: queue messages. | ||
| :cvar AccountPermissions AccountPermissions.WRITE: | ||
| Valid for all signed resources types (Service, Container, and Object). | ||
| Permits write permissions to the specified resource type. | ||
| :param bool read: | ||
| Valid for all signed resources types (Service, Container, and Object). | ||
| Permits read permissions to the specified resource type. | ||
|
|
@@ -325,57 +306,43 @@ class AccountPermissions(object): | |
| Valid for the following Object resource types only: queue messages. | ||
| :param bool process: | ||
| Valid for the following Object resource type only: queue messages. | ||
| :param str _str: | ||
| A string representing the permissions. | ||
| """ | ||
|
|
||
| READ = None # type: AccountPermissions | ||
| WRITE = None # type: AccountPermissions | ||
| DELETE = None # type: AccountPermissions | ||
| LIST = None # type: AccountPermissions | ||
| ADD = None # type: AccountPermissions | ||
| CREATE = None # type: AccountPermissions | ||
| UPDATE = None # type: AccountPermissions | ||
| PROCESS = None # type: AccountPermissions | ||
|
|
||
| def __init__(self, read=False, write=False, delete=False, list=False, # pylint: disable=redefined-builtin | ||
| add=False, create=False, update=False, process=False, _str=None): | ||
| if not _str: | ||
| _str = '' | ||
| self.read = read or ('r' in _str) | ||
| self.write = write or ('w' in _str) | ||
| self.delete = delete or ('d' in _str) | ||
| self.list = list or ('l' in _str) | ||
| self.add = add or ('a' in _str) | ||
| self.create = create or ('c' in _str) | ||
| self.update = update or ('u' in _str) | ||
| self.process = process or ('p' in _str) | ||
|
|
||
| def __or__(self, other): | ||
| return AccountPermissions(_str=str(self) + str(other)) | ||
|
|
||
| def __add__(self, other): | ||
| return AccountPermissions(_str=str(self) + str(other)) | ||
| add=False, create=False, update=False, process=False): | ||
| self.read = read | ||
| self.write = write | ||
| self.delete = delete | ||
| self.list = list | ||
| self.add = add | ||
| self.create = create | ||
| self.update = update | ||
| self.process = process | ||
| self._str = (('r' if self.read else '') + | ||
| ('w' if self.write else '') + | ||
| ('d' if self.delete else '') + | ||
| ('l' if self.list else '') + | ||
| ('a' if self.add else '') + | ||
| ('c' if self.create else '') + | ||
| ('u' if self.update else '') + | ||
| ('p' if self.process else '')) | ||
|
|
||
| def __str__(self): | ||
| return (('r' if self.read else '') + | ||
| ('w' if self.write else '') + | ||
| ('d' if self.delete else '') + | ||
| ('l' if self.list else '') + | ||
| ('a' if self.add else '') + | ||
| ('c' if self.create else '') + | ||
| ('u' if self.update else '') + | ||
| ('p' if self.process else '')) | ||
|
|
||
|
|
||
| AccountPermissions.READ = AccountPermissions(read=True) | ||
| AccountPermissions.WRITE = AccountPermissions(write=True) | ||
| AccountPermissions.DELETE = AccountPermissions(delete=True) | ||
| AccountPermissions.LIST = AccountPermissions(list=True) | ||
| AccountPermissions.ADD = AccountPermissions(add=True) | ||
| AccountPermissions.CREATE = AccountPermissions(create=True) | ||
| AccountPermissions.UPDATE = AccountPermissions(update=True) | ||
| AccountPermissions.PROCESS = AccountPermissions(process=True) | ||
| return self._str | ||
|
|
||
| @classmethod | ||
| def from_string(cls, permission): | ||
| p_read = 'r' in permission | ||
| p_write = 'w' in permission | ||
| p_delete = 'd' in permission | ||
| p_list = 'l' in permission | ||
| p_add = 'a' in permission | ||
| p_create = 'c' in permission | ||
| p_update = 'u' in permission | ||
| p_process = 'p' in permission | ||
|
|
||
| parsed = cls(p_read, p_write, p_delete, p_list, p_add, p_create, p_update, p_process) | ||
| parsed._str = permission # pylint: disable = protected-access | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little bit confused about this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, the parsed._str will be 'abcd' for non-lossy behavior. (We want to keep the original string.) |
||
| return parsed | ||
|
|
||
|
|
||
| class Services(object): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zezha-msft @xiafu-msft @annatisch
Do you think there should be a limit on the length of the string that should be passed?
Something like
This would prevent someone to pass a really long string and slow down things. But on the other hand, adding the check might make it less forward-compatible, since if there are any new accepted letters that are added later, the length check might potentially break things.
One option as a middle ground is to limit the length to a larger number (like say, 100). Do you have any thoughts/ opinions?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel maybe it's not necessary. We only check if an letter is in the passed str using if 'r' in permission, so the returned permission will never be longer than 8(for now)?