-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(auth): implement in-place Regional Access Boundary configuration and add public RAB getters #16987
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(auth): implement in-place Regional Access Boundary configuration and add public RAB getters #16987
Changes from all commits
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 |
|---|---|---|
|
|
@@ -309,6 +309,16 @@ def __init__(self): | |
| _regional_access_boundary_utils._RegionalAccessBoundaryManager() | ||
| ) | ||
|
|
||
| @property | ||
| def regional_access_boundary(self): | ||
| """Optional[str]: The encoded Regional Access Boundary locations.""" | ||
| return self._rab_manager._data.encoded_locations | ||
|
|
||
| @property | ||
| def regional_access_boundary_expiry(self): | ||
| """Optional[datetime.datetime]: The expiration time of the Regional Access Boundary.""" | ||
| return self._rab_manager._data.expiry | ||
|
|
||
| @abc.abstractmethod | ||
| def _perform_refresh_token(self, request): | ||
| """Refreshes the access token. | ||
|
|
@@ -361,39 +371,37 @@ def _copy_regional_access_boundary_manager(self, target): | |
| new_manager._data = self._rab_manager._data | ||
| target._rab_manager = new_manager | ||
|
|
||
| def _with_regional_access_boundary(self, seed): | ||
| """Returns a copy of these credentials with the the regional_access_boundary | ||
| set to the provided seed. This is intended for internal use only as invalid | ||
| def _set_regional_access_boundary(self, seed): | ||
| """Applies the regional_access_boundary provided via the seed on these | ||
| credentials. This is intended for internal use only as invalid | ||
| seeds would produce unexpected results until automatic recovery is supported. | ||
| Currently this is used by the gcloud CLI and therefore changes to the | ||
| contract MUST be backwards compatible (e.g. the method signature must be | ||
| unchanged and a copy of the credenials with the RAB set must be returned). | ||
| unchanged and the credentials with the RAB set must be returned). | ||
|
|
||
|
|
||
| Returns: | ||
| google.auth.credentials.Credentials: A new credentials instance. | ||
| google.auth.credentials.Credentials: The credentials instance. | ||
| """ | ||
| creds = self._make_copy() | ||
| creds._rab_manager.set_initial_regional_access_boundary( | ||
| self._rab_manager.set_initial_regional_access_boundary( | ||
| encoded_locations=seed.get("encodedLocations", None), | ||
| expiry=seed.get("expiry", None), | ||
| ) | ||
| return creds | ||
| return self | ||
|
|
||
| def _with_blocking_regional_access_boundary_lookup(self): | ||
| """Returns a copy of these credentials with the blocking lookup mode enabled. | ||
| def _set_blocking_regional_access_boundary_lookup(self): | ||
| """Enables the blocking lookup mode on these credentials. | ||
| This is intended for internal use only as blocking lookup requires additional | ||
| care and consideration. Currently this is used by the gcloud CLI and | ||
| therefore changes to the contract MUST be backwards compatible (e.g. the | ||
| method signature must be unchanged and a copy of the credentials with the | ||
| method signature must be unchanged and the credentials with the | ||
| blocking lookup flag set to true must be returned). | ||
|
|
||
| Returns: | ||
| google.auth.credentials.Credentials: A new credentials instance. | ||
| google.auth.credentials.Credentials: The credentials instance. | ||
| """ | ||
|
Comment on lines
+392
to
402
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. Renaming References
|
||
| creds = self._make_copy() | ||
| creds._rab_manager.enable_blocking_lookup() | ||
| return creds | ||
| self._rab_manager.enable_blocking_lookup() | ||
| return self | ||
|
|
||
| def _maybe_start_regional_access_boundary_refresh(self, request, url): | ||
| """ | ||
|
|
||
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.
The method
_with_regional_access_boundaryhas been renamed to_set_regional_access_boundaryand changed to mutate in-place. This is a breaking change that will impact consumers like the gcloud CLI. Per repository guidelines, breaking changes require a minor version bump rather than a patch. Furthermore, if you choose to revert to the previous cloning behavior to maintain compatibility, ensure that a new_RegionalAccessBoundaryManageris created for the clone to isolate background refresh logic.References