-
Notifications
You must be signed in to change notification settings - Fork 107
feat: add mtls feature to http and grpc transport provider #1249
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1249 +/- ##
============================================
- Coverage 81.46% 79.58% -1.89%
+ Complexity 1347 1275 -72
============================================
Files 211 211
Lines 5730 5588 -142
Branches 525 477 -48
============================================
- Hits 4668 4447 -221
- Misses 850 952 +102
+ Partials 212 189 -23
Continue to review full report at Codecov.
|
ff0e7c9
to
18c26b5
Compare
18c26b5
to
3586d5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned by usage of system tools to read files: is it necessary? if yes, then why? It seems like the same result can be achieved in pure system-independent java-native way. Which will be more efficient and most importantly more portable and reliable.
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
gax/src/test/java/com/google/api/gax/rpc/mtls/MtlsUtilsTest.java
Outdated
Show resolved
Hide resolved
gax/src/test/resources/com/google/api/gax/rpc/mtls/mtls_context_aware_metadata.json
Outdated
Show resolved
Hide resolved
gax/src/test/resources/com/google/api/gax/rpc/mtls/mtls_context_aware_metadata.json
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/ContextAwareMetadataJson.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
gax/src/test/java/com/google/api/gax/rpc/ClientContextTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a first pass.
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grpc team has expressed strong misgivings about the use of the shaded class. I'm not sure I fully grok everything in this PR, but I think their concerns need to be given serious weight. At this time, I am unwilling to proceed further without their signoff.
This work is complex because it crosses multiple repos and teams. I suggest adding someone from GRPC to the reviewers on go/java-gapic-client-mtls and make sure they're OK with the approach. The ultimate solution might need to be implemented in a different way, or in a different order. It's possible we should roll back some of the changes that have already been made. I'm not sure.
FYI, you don't require my approval, but I do think you should get the gRPC team's approval.
As I mentioned in grpc/grpc-java#7667, even non-shaded Netty is a no-no for gax, as it is unstable API. Gax should really be using https://github.com/grpc/grpc-java-api-checker, to make that sort of bug a compile error. Discussion about which API to use (there isn't one currently) will continue on grpc/grpc-java#7667 |
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
3586d5a
to
210ed08
Compare
Because we need to run a system-dependent native helper binary to get the certificate. This is mentioned in
|
I will revisit this PR and re-implement the grpc part after a new stable api is available in grpc-java. Currently putting this PR on hold. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
This PR is ready now. Please take another look, thanks! @elharo @miraleung @vam-google @ejona86 |
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/ContextAwareMetadataJson.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a first pass.
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please wait for approval by one other reviewer.
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
...httpjson/src/main/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProvider.java
Outdated
Show resolved
Hide resolved
gax/src/main/java/com/google/api/gax/rpc/mtls/MtlsProvider.java
Outdated
Show resolved
Hide resolved
gax/src/test/java/com/google/api/gax/rpc/ClientContextTest.java
Outdated
Show resolved
Hide resolved
gax/src/test/java/com/google/api/gax/rpc/mtls/AbstractMtlsTransportChannelTest.java
Outdated
Show resolved
Hide resolved
...httpjson/src/main/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProvider.java
Outdated
Show resolved
Hide resolved
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
...json/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTest.java
Outdated
Show resolved
Hide resolved
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Show resolved
Hide resolved
🤖 I have created a release \*beep\* \*boop\* --- ## [1.65.0](https://www.github.com/googleapis/gax-java/compare/v1.64.0...v1.65.0) (2021-06-02) ### Features * add mtls feature to http and grpc transport provider ([#1249](https://www.github.com/googleapis/gax-java/issues/1249)) ([b863041](https://www.github.com/googleapis/gax-java/commit/b863041bc4c03c8766e0feca8cb10f531373dc44)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Internal doc: go/java-gapic-client-mtls.
AIP: https://google.aip.dev/auth/4114
Short summary:
Background
mtls has two parts: client certificate, endpoint
(1) client certificate is loaded from device by running the command specified in
~/.secureConnect/context_aware_metadata.json
(2) whether to load/use client certificate is controlled by
GOOGLE_API_USE_CLIENT_CERTIFICATE
env variable. To load/use it, set the env var to "true".(3) if client cert exists and used, it will be used to create a
HttpTransport
for http, andChannelCredentials
for grpc(1) there are regular endpoint and mtls endpoint. Regular endpoint is used by default.
(2) if user provides endpoint, it should always be used as it is
(3) if endpoint is not provided by the user (i.e. it is set by client lib), then endpoint behavior can be controlled by
GOOGLE_API_USE_MTLS_ENDPOINT
env vari) if client cert exists and is used, auto switch to use mtls endpoint
ii) if env var is "never", always use regular endpoint
iii) if env var is "always", always use mtls endpoint
This PR
This PR is organized as follows:
MtlsProvider
class.MtlsProvider
, and used to createHttpTransport
for http, andChannelCredentials
for grpc (key store is converted to key manager for grpc)allowSwitchToMtlsEndpoint
property. This is used to tell who sets the endpoint. Client lib needs to set it totrue
. If the value isfalse
, we just use the provided endpoint and cannot switch to mtls endpoint.Testing
This PR has been tested with kms (for grpc) and compute (for http).
arithmetic1728/java-kms#1
https://github.com/arithmetic1728/java-compute/pull/4