Skip to content

feat(auth): Add support for Regional Access Boundaries#13559

Draft
vverman wants to merge 5 commits into
googleapis:mainfrom
vverman:regional-access-boundaries-main-merge
Draft

feat(auth): Add support for Regional Access Boundaries#13559
vverman wants to merge 5 commits into
googleapis:mainfrom
vverman:regional-access-boundaries-main-merge

Conversation

@vverman

@vverman vverman commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The Regional Access Boundaries PR to main. Contains all the changes merged to the feature branch "regional-access-boundaries" rebased on top of main.

vverman added 5 commits June 16, 2026 16:19
…gleapis#12867)

1. The RAB refresh uses a direct executor with a fixed thread pool as
opposed to instantiating a new thread each time.

2. The RAB env gate -> GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT has
been removed. This means RAB refresh triggers by default.

3. Added other fixes/suggestions made in the previous Java
[PR](googleapis/google-auth-library-java#1880).
…oogleapis#13331)

In ComputeEngineCredentials when running on GKE platform, the
getAccount() call may return a value which isn't an email.

In this case the right behaviour is to skip RAB lookup which is what
this PR does.

Added tests.
@vverman vverman added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Regional Access Boundaries (RAB) by adding RegionalAccessBoundary, RegionalAccessBoundaryManager, and RegionalAccessBoundaryProvider to manage, cache, and asynchronously refresh allowed locations. This functionality is integrated across various credential classes to attach the x-allowed-locations header to outgoing requests. Feedback on the changes suggests catching IllegalStateException in RegionalAccessBoundaryManager to permanently skip RAB lookups on configuration errors and avoiding a redundant HashMap copy in GoogleCredentials.getAdditionalHeaders().

Comment on lines +207 to +208
} catch (Exception e) {
handleRefreshFailure(e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If getRegionalAccessBoundaryUrl() throws an IllegalStateException due to a permanent configuration error (such as an invalid or null audience), catching it as a general exception and triggering a cooldown retry is inefficient because the configuration will never become valid. Catching IllegalStateException specifically to log a warning and set skipRAB to true prevents futile background retries.

            } catch (IllegalStateException e) {
              log(
                  LOGGER_PROVIDER,
                  Level.WARNING,
                  null,
                  "Permanent configuration error detected. Skipping future Regional Access Boundary refreshes: "
                      + e.getMessage());
              skipRAB.set(true);
            } catch (Exception e) {
              handleRefreshFailure(e);

@Override
protected Map<String, List<String>> getAdditionalHeaders() {
Map<String, List<String>> headers = super.getAdditionalHeaders();
Map<String, List<String>> headers = new HashMap<>(super.getAdditionalHeaders());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Creating a new HashMap copy of super.getAdditionalHeaders() is redundant because addQuotaProjectIdToRequestMetadata does not modify the passed map directly; instead, it returns a new ImmutableMap if modifications are needed. We can pass the original map directly to avoid unnecessary object allocation.

Suggested change
Map<String, List<String>> headers = new HashMap<>(super.getAdditionalHeaders());
Map<String, List<String>> headers = super.getAdditionalHeaders();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant