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

auth: fix panic using WithRoot and improve JWT coverage #9698

Merged
merged 1 commit into from
May 22, 2018

Conversation

hexfusion
Copy link
Contributor

ref: #9695

@hexfusion
Copy link
Contributor Author

@gyuho FYI

https://jenkins-etcd-public.prod.coreos.systems/job/etcd-ci-ppc64/4075/console
fatal: write error: No space left on device

@gyuho
Copy link
Contributor

gyuho commented May 4, 2018

@hexfusion

@mkumatag Can you clean up the disk :)

@hexfusion
Copy link
Contributor Author

@gyuho PTAL, thanks.

@hexfusion hexfusion removed the WIP label May 15, 2018
@gyuho
Copy link
Contributor

gyuho commented May 15, 2018

@hexfusion Can we add a simple unit test? Thanks!

@codecov-io
Copy link

codecov-io commented May 15, 2018

Codecov Report

Merging #9698 into master will increase coverage by 0.26%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9698      +/-   ##
==========================================
+ Coverage   69.49%   69.76%   +0.26%     
==========================================
  Files         375      375              
  Lines       35179    35179              
==========================================
+ Hits        24449    24541      +92     
+ Misses       8981     8887      -94     
- Partials     1749     1751       +2
Impacted Files Coverage Δ
auth/store.go 73.53% <100%> (+0.26%) ⬆️
clientv3/namespace/watch.go 72.72% <0%> (-6.07%) ⬇️
lease/leasehttp/http.go 58.08% <0%> (-1.48%) ⬇️
etcdserver/cluster_util.go 58.74% <0%> (-0.9%) ⬇️
clientv3/watch.go 95.97% <0%> (-0.48%) ⬇️
clientv3/op.go 73.04% <0%> (-0.44%) ⬇️
rafthttp/stream.go 79.39% <0%> (-0.43%) ⬇️
rafthttp/peer.go 78.77% <0%> (ø) ⬆️
etcdserver/server.go 73.99% <0%> (+0.14%) ⬆️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 346589e...b30a116. Read the comment docs.

@hexfusion
Copy link
Contributor Author

@hexfusion Can we add a simple unit test? Thanks!

@gyuho yes sir will address

@hexfusion
Copy link
Contributor Author

@gyuho test added, thanks.

@gyuho
Copy link
Contributor

gyuho commented May 16, 2018

I took a second look, and this seems wrong. Request with JWT token should also be passing contexts with auth information. See

https://github.com/coreos/etcd/blob/4a4be9275c033505555f75c61890498099a895c6/auth/store.go#L1292-L1309

We just need to check as

if ts, ok := as.tokenProvider.(*tokenSimple); ok && ts != nil { 

Also we need unit tests to cover this line, not on the util function.

auth/store.go Outdated
@@ -1284,7 +1284,7 @@ func NewTokenProvider(
}

func (as *authStore) WithRoot(ctx context.Context) context.Context {
if !as.IsAuthEnabled() {
if tt := tokenProviderType(as); tt != "simple" || !as.IsAuthEnabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably should define "simple" as a const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xiang90 good idea, done.

@hexfusion hexfusion force-pushed the fx_auth branch 2 times, most recently from 01dde0c to dd7d4e4 Compare May 22, 2018 13:21
@hexfusion hexfusion changed the title auth: add type checking of tokenProvider auth: fix panic using WithRoot and improve e2e JWT coverage May 22, 2018
@hexfusion
Copy link
Contributor Author

Updated the check and added some testing. In general, it is very awkward how NewTokenProvider accepts opts as a string, that is fine for simple but not for jwt. I didn't address this here but this should be looked at further. I also removed the util function and tests as they were not necessary.

/cc @gyuho @joelegasse

@hexfusion hexfusion changed the title auth: fix panic using WithRoot and improve e2e JWT coverage auth: fix panic using WithRoot and improve JWT coverage May 22, 2018
Copy link
Contributor

@joelegasse joelegasse left a comment

Choose a reason for hiding this comment

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

@gyuho The only times those context values are used is by the simple token during assign (token creation). This means that we don't need a type-switch to handle other token types (for now).

@hexfusion hexfusion merged commit 3de0405 into etcd-io:master May 22, 2018
@hexfusion
Copy link
Contributor Author

@gyuho @joelegasse @xiang90 thank you!

@hexfusion hexfusion deleted the fx_auth branch May 22, 2018 19:48
gyuho added a commit to gyuho/etcd that referenced this pull request May 24, 2018
etcd-io#9698 wasn't really testing
the panic code path when leases are expiry.

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
gyuho added a commit to gyuho/etcd that referenced this pull request May 24, 2018
etcd-io#9698 wasn't really testing
the panic code path when leases are expiry.

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
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.

5 participants