Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public boolean check(Channel channel) {
}
}

/** Checks if the exception is due to a VPC Service Controls policy violation. */
private boolean isAllowed(StatusRuntimeException 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.

add isAllowedFromVPCServiceControls

String description = e.getStatus().getDescription();
String message = e.getMessage();
return (description != null
&& description.contains("Request is prohibited by organization's policy"))

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.

can you see if this is the authorative string?

I see "request is prohibited by " as well.

|| (message != null && message.contains("Request is prohibited by organization's policy"));
}

/** Executes the underlying RPC and evaluates the eligibility. */
private boolean evaluateEligibility(Channel channel) {
MetadataExtractorInterceptor interceptor = createInterceptor();
Expand All @@ -91,8 +100,13 @@ private boolean evaluateEligibility(Channel channel) {
if (e.getStatus().getCode() != Code.PERMISSION_DENIED) {
throw e;
}
// Failed with permission error, resorting to ALTS check.
isEligible = sidebandData.isAlts();

if (isAllowed(e)) {
LOG.log(Level.WARNING, "DirectPath is blocked by a perimeter policy violation.");
} else {
// Failed with standard permission error, resorting to ALTS check.
isEligible = sidebandData.isAlts();
}
}

if (isEligible) {
Expand Down
Loading