Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Breaking Changes
~~~~~~~~~~~~~~~~

- The legacy ``MutableScope`` type has been removed. (:pr:`1198`)

- The ``make_mutable`` method on ``ScopeBuilder`` objects has also been
removed as a consequence of this change.
1 change: 0 additions & 1 deletion docs/authorization/scopes_and_consents/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ which make learning about and manipulating these data easier.
:maxdepth: 1

scopes
mutable_scopes
consents
95 changes: 0 additions & 95 deletions docs/authorization/scopes_and_consents/mutable_scopes.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/examples/guest_collection_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ policy documents passed to create the user credential.

# The scope the client will need, note that primary scope is for the endpoint,
# but it has a dependency on the mapped collection's data_access scope
scope = scopes.GCSEndpointScopeBuilder(endpoint_id).make_mutable("manage_collections")
scope = scopes.Scope(scopes.GCSEndpointScopeBuilder(endpoint_id).manage_collections)
scope.add_dependency(scopes.GCSCollectionScopeBuilder(mapped_collection_id).data_access)

# Build a GCSClient to act as the client by using a ClientCredentialsAuthorizor
Expand Down
3 changes: 1 addition & 2 deletions src/globus_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import uuid

if t.TYPE_CHECKING:
from globus_sdk.scopes import MutableScope, Scope
from globus_sdk.scopes import Scope


# these types are aliases meant for internal use
Expand All @@ -15,7 +15,6 @@

ScopeCollectionType = t.Union[
str,
"MutableScope",
"Scope",
t.Iterable["ScopeCollectionType"],
]
Expand Down
2 changes: 0 additions & 2 deletions src/globus_sdk/scopes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
)
from .errors import ScopeCycleError, ScopeParseError
from .representation import Scope
from .scope_definition import MutableScope

__all__ = (
"ScopeBuilder",
"MutableScope",
"Scope",
"ScopeParseError",
"ScopeCycleError",
Expand Down
11 changes: 4 additions & 7 deletions src/globus_sdk/scopes/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import typing as t

from .representation import Scope
from .scope_definition import MutableScope

if t.TYPE_CHECKING:
from globus_sdk._types import ScopeCollectionType
Expand All @@ -22,7 +21,7 @@ def scopes_to_str(scopes: ScopeCollectionType) -> str:

>>> scopes_to_str(Scope("foo"))
'foo'
>>> scopes_to_str(Scope("foo"), "bar", MutableScope("qux"))
>>> scopes_to_str(Scope("foo"), "bar", Scope("qux"))
'foo bar qux'
"""
scope_iter = _iter_scope_collection(scopes, split_root_scopes=False)
Expand All @@ -42,15 +41,13 @@ def scopes_to_scope_list(scopes: ScopeCollectionType) -> list[Scope]:

>>> scopes_to_scope_list(Scope("foo"))
[Scope('foo')]
>>> scopes_to_scope_list(Scope("foo"), "bar baz", MutableScope("qux"))
>>> scopes_to_scope_list(Scope("foo"), "bar baz", Scope("qux"))
[Scope('foo'), Scope('bar'), Scope('baz'), Scope('qux')]
"""
scope_list: list[Scope] = []
for scope in _iter_scope_collection(scopes):
if isinstance(scope, str):
scope_list.extend(Scope.parse(scope))
elif isinstance(scope, MutableScope):
scope_list.extend(Scope.parse(str(scope)))
else:
scope_list.append(scope)
return scope_list
Expand All @@ -60,7 +57,7 @@ def _iter_scope_collection(
obj: ScopeCollectionType,
*,
split_root_scopes: bool = True,
) -> t.Iterator[str | MutableScope | Scope]:
) -> t.Iterator[str | Scope]:
"""
Provide an iterator over a scope collection type, flattening nested scope
collections as encountered.
Expand Down Expand Up @@ -88,7 +85,7 @@ def _iter_scope_collection(
"""
if isinstance(obj, str):
yield from _iter_scope_string(obj, split_root_scopes)
elif isinstance(obj, MutableScope) or isinstance(obj, Scope):
elif isinstance(obj, Scope):
yield obj
else:
for item in obj:
Expand Down
30 changes: 0 additions & 30 deletions src/globus_sdk/scopes/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import typing as t

from .scope_definition import MutableScope

ScopeBuilderScopes = t.Union[
None,
str,
Expand Down Expand Up @@ -126,34 +124,6 @@ def url_scope_string(self, scope_name: str) -> str:
"""
return f"https://auth.globus.org/scopes/{self.resource_server}/{scope_name}"

def make_mutable(self, scope: str, *, optional: bool = False) -> MutableScope:
"""
For a given scope, create a MutableScope object.

The ``scope`` name given refers to the name of a scope attached to the
ScopeBuilder. It is given by attribute name, not by the full scope string.

**Examples**

Using the ``TransferScopes`` object, one could reference ``all`` as follows:

>>> TransferScopes.all
'urn:globus:auth:scope:transfer.api.globus.org:all'
>>> TransferScopes.make_mutable("all")
Scope('urn:globus:auth:scope:transfer.api.globus.org:all')

This is equivalent to constructing a Scope object from the resolved
scope string, as in

>>> Scope(TransferScopes.all)
Scope('urn:globus:auth:scope:transfer.api.globus.org:all')

:param scope: The name of the scope to convert to a MutableScope
:param optional: If true, the created MutableScope object will be marked
optional
"""
return MutableScope(getattr(self, scope), optional=optional)

def __str__(self) -> str:
return f"{self.__class__.__name__}[{self.resource_server}]\n" + "\n".join(
f" {name}:\n {getattr(self, name)}" for name in self.scope_names
Expand Down
119 changes: 0 additions & 119 deletions src/globus_sdk/scopes/scope_definition.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import urllib.parse

from globus_sdk._testing import get_last_request, load_response
from globus_sdk.scopes import MutableScope
from globus_sdk.scopes import Scope


def test_oauth2_client_credentials_tokens(auth_client):
Expand All @@ -14,10 +14,10 @@ def test_oauth2_client_credentials_tokens(auth_client):
)


def test_oauth2_client_credentials_tokens_can_accept_mutable_scope_object(auth_client):
def test_oauth2_client_credentials_tokens_can_accept_scope_object(auth_client):
meta = load_response(auth_client.oauth2_client_credentials_tokens).metadata

response = auth_client.oauth2_client_credentials_tokens(MutableScope(meta["scope"]))
response = auth_client.oauth2_client_credentials_tokens(Scope(meta["scope"]))
assert (
response.by_resource_server[meta["resource_server"]]["access_token"]
== meta["access_token"]
Expand Down
Loading