Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientv3: get AuthToken automatically when clientConn is ready. #12264

Merged
merged 1 commit into from
Sep 25, 2020
Merged

clientv3: get AuthToken automatically when clientConn is ready. #12264

merged 1 commit into from
Sep 25, 2020

Conversation

cfc4n
Copy link
Contributor

@cfc4n cfc4n commented Sep 1, 2020

clientv3: get AuthToken automatically when clientConn is ready.

fixes: #11954

@cfc4n
Copy link
Contributor Author

cfc4n commented Sep 10, 2020

@mitake PTAL
/cc @xiang90 @gyuho @jingyih

Copy link
Contributor

@mitake mitake left a comment

Choose a reason for hiding this comment

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

LGTM other than the logging part, thanks! The failed test seems to be non deterministic.

}
creds = c.authTokenBundle.PerRPCCredentials()
}
if creds != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think logging metadata wouldn't be good, it can expose a credential in client side logs, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, But I think that no other credential info in client side logs in

func (rc *perRPCCredential) GetRequestMetadata(ctx context.Context, s ...string) (map[string]string, error) {
rc.authTokenMu.RLock()
authToken := rc.authToken
rc.authTokenMu.RUnlock()
return map[string]string{rpctypes.TokenFieldNameGRPC: authToken}, nil
}
,just authToken only, there is not other keyword. Logging metadata for debug .

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, but if the token can be leaked and malicious person can get it, it can result security issue. I think it shouldn't be logged. How do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

emmm, you are right.

I fixed it at 0649f91 .
but CI was failed at https://travis-ci.com/github/etcd-io/etcd/jobs/385106741#L2064 .

=== RUN   TestBalancerUnderNetworkPartitionWatchLeader
    TestBalancerUnderNetworkPartitionWatchLeader: network_partition_test.go:266: took too long to detect leader lost
--- FAIL: TestBalancerUnderNetworkPartitionWatchLeader (3.35s)

But ,I test passed on my macbook like this:

$ PASSES=integration TESTCASE=TestBalancerUnderNetworkPartitionWatchLeader ./test                           [015eab45e]

Running with TEST_CPUS: 1,2,4
Starting 'integration' pass at 2020年 9月16日 星期三 12时26分27秒 CST
Running integration tests...
testing: warning: no tests to run
PASS
ok  	go.etcd.io/etcd/v3/integration	0.017s [no tests to run]
testing: warning: no tests to run
PASS
ok  	go.etcd.io/etcd/v3/client/integration	0.026s [no tests to run]
=== RUN   TestBalancerUnderNetworkPartitionWatchLeader
--- PASS: TestBalancerUnderNetworkPartitionWatchLeader (1.65s)
=== RUN   TestBalancerUnderNetworkPartitionWatchLeader
--- PASS: TestBalancerUnderNetworkPartitionWatchLeader (1.40s)
=== RUN   TestBalancerUnderNetworkPartitionWatchLeader
--- PASS: TestBalancerUnderNetworkPartitionWatchLeader (1.23s)
PASS
ok  	go.etcd.io/etcd/v3/clientv3/integration	4.306s
testing: warning: no tests to run
PASS
ok  	go.etcd.io/etcd/v3/contrib/raftexample	0.013s [no tests to run]
Finished 'integration' pass at 2020年 9月16日 星期三 12时26分45秒 CST
Success

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CI works. thank you. @mitake

@cfc4n cfc4n requested a review from mitake September 15, 2020 08:00
Copy link
Contributor

@mitake mitake left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mitake
Copy link
Contributor

mitake commented Sep 17, 2020

defer to @jingyih @gyuho @jpbetz

@xiang90 xiang90 merged commit 8c192d9 into etcd-io:master Sep 25, 2020
@cfc4n cfc4n deleted the gettoken_retry_interceptor branch September 25, 2020 14:55
spzala added a commit that referenced this pull request Oct 5, 2020
gyuho added a commit that referenced this pull request Oct 12, 2020
…upstream-release-3.4

Automated cherry pick of #12264
jingyih added a commit that referenced this pull request Nov 16, 2020
…upstream-release-3.3

Automated cherry pick of #12264
bbiao added a commit to bbiao/etcd that referenced this pull request Dec 14, 2020
Old etcdserver which have not apply pr of etcd-io#12165 will check auth token
even if the request is a Authenticate request.

If the client has a invalid auth token, it will not able to update it's
token, since the Authenticate has a invalid auth token.

This fix clear the auth token when encounter an ErrInvalidAuthToken to
talk with old version etcd servers.

Fix etcd-io#12385 with etcd-io#12165 and etcd-io#12264
bbiao added a commit to bbiao/etcd that referenced this pull request Dec 14, 2020
Old etcdserver which have not apply pr of etcd-io#12165 will check auth token
even if the request is a Authenticate request.

If the client has a invalid auth token, it will not able to update it's
token, since the Authenticate has a invalid auth token.

This fix clear the auth token when encounter an ErrInvalidAuthToken to
talk with old version etcd servers.

Fix etcd-io#12385 with etcd-io#12165 and etcd-io#12264
bbiao added a commit to bbiao/etcd that referenced this pull request Dec 14, 2020
Old etcdserver which have not apply pr of etcd-io#12165 will check auth token
even if the request is an Authenticate request.

If the client has a invalid auth token, it will not able to update it's
token, since the Authenticate has a invalid auth token.

This fix clear the auth token when encounter an ErrInvalidAuthToken to
talk with old version etcd servers.

Fix etcd-io#12385 with etcd-io#12165 and etcd-io#12264
bbiao added a commit to bbiao/etcd that referenced this pull request Dec 27, 2020
Old etcdserver which have not apply pr of etcd-io#12165 will check auth token
even if the request is an Authenticate request.
If the client has a invalid auth token, it will not able to update it's
token, since the Authenticate has a invalid auth token.
This fix clear the auth token when encounter an ErrInvalidAuthToken to
talk with old version etcd servers.

Fix etcd-io#12385 with etcd-io#12165 and etcd-io#12264
agargi pushed a commit to agargi/etcd that referenced this pull request Jan 23, 2021
Old etcdserver which have not apply pr of etcd-io#12165 will check auth token
even if the request is an Authenticate request.
If the client has a invalid auth token, it will not able to update it's
token, since the Authenticate has a invalid auth token.
This fix clear the auth token when encounter an ErrInvalidAuthToken to
talk with old version etcd servers.

Fix etcd-io#12385 with etcd-io#12165 and etcd-io#12264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

auth token invalid after watch reconnects
3 participants