Skip to content

Commit

Permalink
gapic: support EnableJwtWithScope for gRPC GAPIC clients (#674)
Browse files Browse the repository at this point in the history
- Update the GAPIC clients to allow scope for self-signed JWT
- The self-signed JWT is now the default authentication method for service account instead of OAuth 2.0
- Self-signed JWT AIP: https://google.aip.dev/auth/4111
- Related PRs:
  -  googleapis/google-api-go-client#1075
  -  golang/oauth2#504
  - aip-dev/google.aip.dev#764
  • Loading branch information
shinfan committed Jun 23, 2021
1 parent 9224977 commit f6bebb1
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/gengapic/gengrpc.go
Expand Up @@ -198,6 +198,7 @@ func (g *generator) grpcClientOptions(serv *descriptor.ServiceDescriptorProto, s
p(" internaloption.WithDefaultMTLSEndpoint(%q),", generateDefaultMTLSEndpoint(host))
p(" internaloption.WithDefaultAudience(%q),", generateDefaultAudience(host))
p(" internaloption.WithDefaultScopes(DefaultAuthScopes()...),")
p(" internaloption.EnableJwtWithScope(),")
p(" option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),")
p(" option.WithGRPCDialOption(grpc.WithDefaultCallOptions(")
p(" grpc.MaxCallRecvMsgSize(math.MaxInt32))),")
Expand Down
1 change: 1 addition & 0 deletions internal/gengapic/testdata/empty_opt.want
Expand Up @@ -21,6 +21,7 @@ func defaultGRPCClientOptions() []option.ClientOption {
internaloption.WithDefaultMTLSEndpoint("foo.mtls.googleapis.com:443"),
internaloption.WithDefaultAudience("https://foo.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
Expand Down
1 change: 1 addition & 0 deletions internal/gengapic/testdata/foo_opt.want
Expand Up @@ -21,6 +21,7 @@ func defaultFooGRPCClientOptions() []option.ClientOption {
internaloption.WithDefaultMTLSEndpoint("foo.mtls.googleapis.com:443"),
internaloption.WithDefaultAudience("https://foo.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
Expand Down
1 change: 1 addition & 0 deletions internal/gengapic/testdata/host_port_opt.want
Expand Up @@ -19,6 +19,7 @@ func defaultBarGRPCClientOptions() []option.ClientOption {
internaloption.WithDefaultMTLSEndpoint("foo.mtls.googleapis.com:1234"),
internaloption.WithDefaultAudience("https://foo.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
Expand Down
1 change: 1 addition & 0 deletions internal/gengapic/testdata/iam_override_opt.want
Expand Up @@ -18,6 +18,7 @@ func defaultBazGRPCClientOptions() []option.ClientOption {
internaloption.WithDefaultMTLSEndpoint("foo.mtls.googleapis.com:1234"),
internaloption.WithDefaultAudience("https://foo.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
Expand Down
2 changes: 1 addition & 1 deletion showcase/go.mod
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/go-cmp v0.5.5
github.com/googleapis/gapic-showcase v0.15.0
github.com/googleapis/gax-go/v2 v2.0.5
google.golang.org/api v0.46.0
google.golang.org/api v0.49.0
google.golang.org/genproto v0.0.0-20210506142907-4a47615972c2
google.golang.org/grpc v1.37.0
google.golang.org/protobuf v1.26.0
Expand Down

0 comments on commit f6bebb1

Please sign in to comment.