Skip to content

Commit 62b48c4

Browse files
authored
feat: better support for PSC and VPC-SC (#8453)
When using [PSC] (Private Service Connect) or [VPC-SC] (Virtual Private Cloud - Service Controls) we need to specify the `authority` in each gRPC request. This is the HTTP/2 analog of a `Host` header, and allows applications to access a service while using a custom endpoint. For example, the target endpoint could be `pubsub-custom.p.googleapis.com`, but the authority field remains `pubsub.googleapis.com`. [PSC]: https://cloud.google.com/vpc/docs/private-service-connect [VPC-SC]: https://cloud.google.com/vpc-service-controls
1 parent 70a0de1 commit 62b48c4

File tree

152 files changed

+479
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+479
-5
lines changed

generator/integration_tests/golden/internal/golden_kitchen_sink_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ void GoldenKitchenSinkMetadata::SetMetadata(grpc::ClientContext& context) {
121121
context.AddMetadata(
122122
"x-goog-user-project", options.get<UserProjectOption>());
123123
}
124+
if (options.has<AuthorityOption>()) {
125+
context.set_authority(options.get<AuthorityOption>());
126+
}
124127
}
125128

126129
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

generator/integration_tests/golden/internal/golden_thing_admin_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ void GoldenThingAdminMetadata::SetMetadata(grpc::ClientContext& context) {
230230
context.AddMetadata(
231231
"x-goog-user-project", options.get<UserProjectOption>());
232232
}
233+
if (options.has<AuthorityOption>()) {
234+
context.set_authority(options.get<AuthorityOption>());
235+
}
233236
}
234237

235238
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

generator/internal/metadata_decorator_generator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ void $metadata_class_name$::SetMetadata(grpc::ClientContext& context) {
348348
context.AddMetadata(
349349
"x-goog-user-project", options.get<UserProjectOption>());
350350
}
351+
if (options.has<AuthorityOption>()) {
352+
context.set_authority(options.get<AuthorityOption>());
353+
}
351354
}
352355
)""");
353356

google/cloud/accessapproval/internal/access_approval_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ void AccessApprovalMetadata::SetMetadata(grpc::ClientContext& context) {
109109
context.AddMetadata("x-goog-user-project",
110110
options.get<UserProjectOption>());
111111
}
112+
if (options.has<AuthorityOption>()) {
113+
context.set_authority(options.get<AuthorityOption>());
114+
}
112115
}
113116

114117
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/accesscontextmanager/internal/access_context_manager_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ void AccessContextManagerMetadata::SetMetadata(grpc::ClientContext& context) {
292292
context.AddMetadata("x-goog-user-project",
293293
options.get<UserProjectOption>());
294294
}
295+
if (options.has<AuthorityOption>()) {
296+
context.set_authority(options.get<AuthorityOption>());
297+
}
295298
}
296299

297300
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/apigateway/internal/api_gateway_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ void ApiGatewayServiceMetadata::SetMetadata(grpc::ClientContext& context) {
192192
context.AddMetadata("x-goog-user-project",
193193
options.get<UserProjectOption>());
194194
}
195+
if (options.has<AuthorityOption>()) {
196+
context.set_authority(options.get<AuthorityOption>());
197+
}
195198
}
196199

197200
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/apigeeconnect/internal/connection_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ void ConnectionServiceMetadata::SetMetadata(grpc::ClientContext& context) {
5555
context.AddMetadata("x-goog-user-project",
5656
options.get<UserProjectOption>());
5757
}
58+
if (options.has<AuthorityOption>()) {
59+
context.set_authority(options.get<AuthorityOption>());
60+
}
5861
}
5962

6063
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/appengine/internal/applications_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ void ApplicationsMetadata::SetMetadata(grpc::ClientContext& context) {
9999
context.AddMetadata("x-goog-user-project",
100100
options.get<UserProjectOption>());
101101
}
102+
if (options.has<AuthorityOption>()) {
103+
context.set_authority(options.get<AuthorityOption>());
104+
}
102105
}
103106

104107
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/appengine/internal/authorized_certificates_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ void AuthorizedCertificatesMetadata::SetMetadata(grpc::ClientContext& context) {
8686
context.AddMetadata("x-goog-user-project",
8787
options.get<UserProjectOption>());
8888
}
89+
if (options.has<AuthorityOption>()) {
90+
context.set_authority(options.get<AuthorityOption>());
91+
}
8992
}
9093

9194
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/appengine/internal/authorized_domains_metadata_decorator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ void AuthorizedDomainsMetadata::SetMetadata(grpc::ClientContext& context) {
5555
context.AddMetadata("x-goog-user-project",
5656
options.get<UserProjectOption>());
5757
}
58+
if (options.has<AuthorityOption>()) {
59+
context.set_authority(options.get<AuthorityOption>());
60+
}
5861
}
5962

6063
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

0 commit comments

Comments
 (0)