Skip to content

Support username/password GRPC auth#4406

Merged
demmer merged 3 commits intovitessio:masterfrom
tinyspeck:grpc-static-auth
Dec 3, 2018
Merged

Support username/password GRPC auth#4406
demmer merged 3 commits intovitessio:masterfrom
tinyspeck:grpc-static-auth

Conversation

@ys8
Copy link
Copy Markdown
Contributor

@ys8 ys8 commented Nov 30, 2018

Fixes #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

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>
@ys8 ys8 requested a review from sougou as a code owner November 30, 2018 01:39
@demmer
Copy link
Copy Markdown
Member

demmer commented Nov 30, 2018

Looks like this needs to be rebased onto the latest master now that I merged #4405 as the build failed with:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project vitess-grpc-client: Compilation failure
[ERROR] /vt/src/vitess.io/vitess/java/grpc-client/src/main/java/io/vitess/client/grpc/StaticAuthCredentials.java:[32,25] lambda expressions are not supported in -source 1.7```

… Without this change, the project doesn't even compile in IntelliJ.

Signed-off-by: Yuichi Sasaki <ysasaki@astro-inc.com>
Copy link
Copy Markdown
Member

@demmer demmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me overall. One naming and one test suggestion but neither are show stoppers.

- 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();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call one constructor from another so that only one constructor contains the logic for initialization.

Copy link
Copy Markdown
Contributor Author

@ys8 ys8 Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

@demmer demmer merged commit 30a1ebc into vitessio:master Dec 3, 2018
@ys8 ys8 deleted the grpc-static-auth branch December 4, 2018 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants