-
Notifications
You must be signed in to change notification settings - Fork 310
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
feat: use self-signed jwt for service account #665
Conversation
@@ -277,7 +286,7 @@ class Scoped(ReadOnlyScoped): | |||
""" | |||
|
|||
@abc.abstractmethod | |||
def with_scopes(self, scopes): | |||
def with_scopes(self, scopes, default_scopes=None): |
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.
Is adding an additional optional parameter to an abstract method a breaking change?
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.
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.
LGTM
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.
One nit, otherwise this is great
…ibrary-python into self-signed-jwt
Looks like I accidentally removed the system tests from the presubmit last year 🤦♀️ . I was hoping it would be a small fix but it looks like some issues have piled up. I'll pull those changes into a separate PR and revisit this one later. |
The assertions for credential scope in the `client` unit tests were broken by [a PR in the auth library](googleapis/google-auth-library-python#665). This does raise the question of whether we should be asserting the scopes like this in this library. This PR fixes the assertions. Removal of these assertions can be done in a separate PR if it is decided they don't belong in this library.
See [RFC (internal only)](https://docs.google.com/document/d/1SNCVTmW6Rtr__u-_V7nsT9PhSzjj1z0P9fAD3YUgRoc/edit#) and https://aip.dev/auth/4111. Support the self-signed JWT flow for service accounts by passing `default_scopes` and `default_host` in calls to the auth library and `create_channel`. This depends on features exposed in the following PRs: googleapis/python-api-core#134, googleapis/google-auth-library-python#665. It may be easier to look at https://github.com/googleapis/python-translate/pull/107/files for a diff on a real library. This change is written so that the library is (temporarily) compatible with older `google-api-core` and `google-auth` versions. Because of this it not possible to reach 100% coverage on a single unit test run. `pytest` runs twice in two of the `nox` sessions. Miscellaneous changes: - sprinkled in `__init__.py` files in subdirs of the `test/` directory, as otherwise pytest-cov seems to fail to collect coverage properly in some instances. - new dependency on `packaging` for Version comparison https://pypi.org/project/packaging/ Co-authored-by: Brent Shaffer <betterbrent@google.com>
https://google.aip.dev/auth/4111
Googlers see this doc for detailed design.
Create a self-signed JWT from the service account credentials when the following conditions are met:
default_scopes
that is separate fromscopes
).api_endpoint
has not been set by the user (taken care of in the GAPIC client library).Other Changes:
default_scopes
to allScopedCredentials
. For non-service account credentials, thedefault_scopes
are used whenscopes
is not set. Otherwise thedefault_scopes
are ignored.This change is only being made to synchronous credentials and the gRPC transport. The async credentials and other transports will be handled in follow up PRs.