feat: implement Regional Access Boundary#569
Open
quartzmo wants to merge 38 commits into
Open
Conversation
c7efe2a to
ce88163
Compare
Restrict credential usage to specific regions by attaching the `x-allowed-locations` header to requests to global endpoints. * Add internal RAB data structure and cache. * Add lookup client (Fetcher) with retry and cooldown logic. * Integrate into BaseClient and gate unsupported usages. * Add URL lookup/construction for Service Account, GCE, Workload, and Workforce Identity. * Add samples in `samples/regional_access_boundary` for demos and manual testing.
0eca008 to
31ed48d
Compare
…load identity samples locally
…universe.rb token_type crash
31ed48d to
ec4dc2e
Compare
aandreassa
reviewed
Jun 17, 2026
If the default service account email retrieved from GCE metadata does not contain an "@" (e.g. on GKE workload federation), the identity is permanently unsupported by the allowedLocations endpoint. This commit: 1. Returns `:unsupported` from `ComputeEngine#regional_access_boundary_url` when email lacks "@". 2. Adds `mark_unsupported!` to `RegionalAccessBoundary::Cache` to set a permanent `@unsupported = true` state. 3. Updates `Cache#get` and `Cache#should_fetch?` to return `nil`/`false` immediately when `@unsupported` is true. 4. Logs a single warning and sets the unsupported bypass state in `BaseClient#trigger_async_rab_fetch`. refs: googleapis/google-cloud-go#19920
…ential pollution Refactor `RegionalAccessBoundary::Cache` to store entries in a thread-safe Hash keyed by the allowedLocations lookup URL (or `:unsupported` sentinel). This ensures that multiple credentials running concurrently in the same application do not pollute each other's allowed locations, preventing security policy bypasses and data-isolation violations.
Wrap the regional access boundary background thread logic in an `ensure` block using a `success` tracking flag. If the thread crashes (e.g. on a non-StandardError) or is killed, the ensure block resets the fetching flag and initiates a cooldown, preventing permanent hangs.
aandreassa
reviewed
Jun 18, 2026
aandreassa
left a comment
Contributor
There was a problem hiding this comment.
LG @quartzmo! I will take another good look tomorrow, but a few nits for now
…to standard lib json
Refactor the conditional logic in should_apply_rab? to use a simpler `if` expression instead of a double negative `unless` check. Test coverage: Verified that all conditional branches (ID token, supports RAB, regional URLs, and excluded service URLs) are fully covered by existing integration specs.
…ng to DEBUG Aligns with the Go reference implementation by disabling Regional Access Boundary checks entirely when a non-default universe domain (not googleapis.com) is used. Also downgrades background thread warnings to DEBUG level to eliminate the risk of nuisance console logging in production.
aandreassa
approved these changes
Jun 18, 2026
Simplifies the universe domain validation in base_credentials.rb to check that only the parsed audience domain is in the default googleapis.com universe. Refactors the error message to be clear about GDU restriction and updates unit test expectations. Also removes the stale samples exclusion reference from .rubocop.yml and aligns concatenated string indent.
9202889 to
47bb362
Compare
Member
Author
|
Adding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restrict credential usage to specific regions by attaching the
x-allowed-locationsheader to requests to global endpoints.samples/regional_access_boundaryfor demos and manual testing.