Support username/password GRPC auth#4406
Merged
demmer merged 3 commits intovitessio:masterfrom Dec 3, 2018
Merged
Conversation
Fixes vitessio#4366 - Modified GrpcClientFactory to allow setting a custom CallCredentials to GrpcClient. - Added StaticAuthCredentials class that implements CallCredentials to support plain username/password. Signed-off-by: Yuichi Sasaki <ysasaki@astro.ai>
Member
|
Looks like this needs to be rebased onto the latest master now that I merged #4405 as the build failed with: |
… Without this change, the project doesn't even compile in IntelliJ. Signed-off-by: Yuichi Sasaki <ysasaki@astro-inc.com>
demmer
approved these changes
Nov 30, 2018
Member
demmer
left a comment
There was a problem hiding this comment.
Changes look good to me overall. One naming and one test suggestion but neither are show stoppers.
java/grpc-client/src/main/java/io/vitess/client/grpc/GrpcClientFactory.java
Outdated
Show resolved
Hide resolved
java/grpc-client/src/test/java/io/client/grpc/GrpcClientStaticAuthTest.java
Show resolved
Hide resolved
- renamed "credentials" to "callCredentials" - added a failure case to unit test Signed-off-by: Yuichi Sasaki <ysasaki@astro.ai>
| return channel instanceof WithLogId ? | ||
| ((WithLogId) channel).getLogId().toString() : channel.toString(); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
You can call one constructor from another so that only one constructor contains the logic for initialization.
Contributor
Author
There was a problem hiding this comment.
I tried it first. It didn't look too clean to me. Do you prefer that way? (In fact, having CallCredentials parameter as Nullabe in this case, an extra constructor is technically no longer needed besides the constructor can be more confusing from caller's point of view.)
public GrpcClient(ManagedChannel channel, @Nullable CallCredentials credentials) {
this.channel = channel;
channelId = toChannelId(channel);
asyncStub = credentials != null ? VitessGrpc.newStub(channel).withCallCredentials(credentials) ? VitessGrpc.newStub(channel);
futureStub = credentials != null ? VitessGrpc.newFutureStub(channel).withCallCredentials(credentials) ? VitessGrpc.newFutureStub(channel);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4366
Signed-off-by: Yuichi Sasaki ysasaki@astro.ai