Skip to content

Commit

Permalink
Add BaseAuthClient to separate methods
Browse files Browse the repository at this point in the history
Introduce a new base class for the Auth client hierarchy in order to
split the developer API methods from the previously existing "base"
methods. The important exception is `get_identities`, which supports
client credentials authorization and therefore needs to stay on the
base.

The changelog explains this change without drawing undue attention to
the ways in which it could, in theory, be compatibility breaking for
users relying on the inheritance relationship (e.g. via `isinstance`
or type annotations).

No new tests are added and no tests are broken by this change.
  • Loading branch information
sirosen committed Jul 18, 2023
1 parent 226edec commit b65d361
Show file tree
Hide file tree
Showing 11 changed files with 681 additions and 617 deletions.
14 changes: 14 additions & 0 deletions changelog.d/20230718_140424_sirosen_separate_auth_base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Changed
~~~~~~~

- The inheritance hierarchy for Globus Auth client classes has changed. (:pr:`NUMBER`)

- A new class, ``BaseAuthClient`` is used as the base for the other three
existing Globus Auth clients

- ``NativeAppAuthClient`` and ``ConfidentialAppAuthClient`` inherit from
``BaseAuthClient``, not ``AuthClient``

- ``NativeAppAuthClient`` and ``ConfidentialAppAuthClient`` have lost methods
which would never work in practice for these client types, e.g.
``create_project``
21 changes: 17 additions & 4 deletions docs/services/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@ Globus Auth
.. currentmodule:: globus_sdk

There are several types of client object for communicating with the Globus Auth
service. A client object may represent your application (as the driver of
authentication and authorization flows), in which case the
:class:`NativeAppAuthClient` or :class:`ConfidentialAppAuthClient` classes should
generally be used.
service.

A client object may represent an application (as the driver of authentication and
authorization flows), in which case the :class:`NativeAppAuthClient` or
:class:`ConfidentialAppAuthClient` classes should generally be used.

For authentication using token auth, generally the appropriate choice is
:class:`AuthClient`.

:class:`BaseAuthClient` defines shared interfaces for the other three but is
generally not recommended for direct instantiation.

.. autoclass:: BaseAuthClient
:members:
:member-order: bysource
:show-inheritance:
:exclude-members: error_class

.. autoclass:: AuthClient
:members:
Expand Down
3 changes: 3 additions & 0 deletions src/globus_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _force_eager_imports() -> None:
},
"services.auth": {
"AuthAPIError",
"BaseAuthClient",
"AuthClient",
"ConfidentialAppAuthClient",
"IdentityMap",
Expand Down Expand Up @@ -150,6 +151,7 @@ def _force_eager_imports() -> None:
from .response import IterableResponse
from .response import ArrayResponse
from .services.auth import AuthAPIError
from .services.auth import BaseAuthClient
from .services.auth import AuthClient
from .services.auth import ConfidentialAppAuthClient
from .services.auth import IdentityMap
Expand Down Expand Up @@ -248,6 +250,7 @@ def __getattr__(name: str) -> t.Any:
"AuthAPIError",
"AuthClient",
"AzureBlobStoragePolicies",
"BaseAuthClient",
"BaseClient",
"BasicAuthorizer",
"BatchMembershipActions",
Expand Down
1 change: 1 addition & 0 deletions src/globus_sdk/_generate_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def __getattr__(name: str) -> t.Any:
"services.auth",
(
"AuthAPIError",
"BaseAuthClient",
"AuthClient",
"ConfidentialAppAuthClient",
"IdentityMap",
Expand Down
8 changes: 7 additions & 1 deletion src/globus_sdk/services/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from .client import AuthClient, ConfidentialAppAuthClient, NativeAppAuthClient
from .client import (
AuthClient,
BaseAuthClient,
ConfidentialAppAuthClient,
NativeAppAuthClient,
)
from .errors import AuthAPIError
from .flow_managers import (
GlobusAuthorizationCodeFlowManager,
Expand All @@ -12,6 +17,7 @@
)

__all__ = [
"BaseAuthClient",
"AuthClient",
"AuthAPIError",
"NativeAppAuthClient",
Expand Down
9 changes: 7 additions & 2 deletions src/globus_sdk/services/auth/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from .base import AuthClient
from .base import AuthClient, BaseAuthClient
from .confidential_client import ConfidentialAppAuthClient
from .native_client import NativeAppAuthClient

__all__ = ["AuthClient", "NativeAppAuthClient", "ConfidentialAppAuthClient"]
__all__ = [
"BaseAuthClient",
"AuthClient",
"NativeAppAuthClient",
"ConfidentialAppAuthClient",
]
Loading

0 comments on commit b65d361

Please sign in to comment.