-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add auth token propagation for metrics reader #3341
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a5133cc
Add auth token propagation for metrics reader
albertteoh fa128b3
Consolidate token propagation code
albertteoh d1c96ad
Rename to use PropagationHandler for consistency
albertteoh f0774b2
Split and move common transports
albertteoh 8e5f1b9
Give bearerToken value less meaning
albertteoh 73db361
Fix import grouping
albertteoh 787b07b
Give token value less meaning
albertteoh 9af8681
make fmt
albertteoh bac98cc
Merge branch 'master' into 3340-token-prop
albertteoh 56ac31b
Remove functional options
albertteoh f5e3801
Fix build
albertteoh 65208c2
Merge branch 'master' into 3340-token-prop
albertteoh 696eb45
Merge branch 'master' into 3340-token-prop
albertteoh 4d7e1c5
Merge branch 'master' into 3340-token-prop
albertteoh 696cb5f
Address review comments
albertteoh bf6a818
Merge branch 'master' into 3340-token-prop
albertteoh 2742a11
Fix staticcheck err
albertteoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ import ( | |
"github.com/jaegertracing/jaeger/pkg/prometheus/config" | ||
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics" | ||
"github.com/jaegertracing/jaeger/storage/metricsstore" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
) | ||
|
||
type ( | ||
|
@@ -331,12 +332,33 @@ func TestGetRoundTripper(t *testing.T) { | |
}, | ||
}, logger) | ||
require.NoError(t, err) | ||
assert.IsType(t, &http.Transport{}, rt) | ||
assert.IsType(t, &tokenAuthTransport{}, rt) | ||
if tc.tlsEnabled { | ||
assert.NotNil(t, rt.(*http.Transport).TLSClientConfig) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving the common transport into the Suggestions also welcome. |
||
assert.NotNil(t, rt.(*tokenAuthTransport).wrapped.TLSClientConfig) | ||
} else { | ||
assert.Nil(t, rt.(*http.Transport).TLSClientConfig) | ||
assert.Nil(t, rt.(*tokenAuthTransport).wrapped.TLSClientConfig) | ||
} | ||
|
||
server := httptest.NewServer( | ||
http.HandlerFunc( | ||
func(w http.ResponseWriter, r *http.Request) { | ||
assert.Equal(t, "Bearer foo", r.Header.Get("Authorization")) | ||
}, | ||
), | ||
) | ||
defer server.Close() | ||
|
||
req, err := http.NewRequestWithContext( | ||
spanstore.ContextWithBearerToken(context.Background(), "foo"), | ||
http.MethodGet, | ||
server.URL, | ||
nil, | ||
) | ||
require.NoError(t, err) | ||
|
||
resp, err := rt.RoundTrip(req) | ||
require.NoError(t, err) | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
}) | ||
} | ||
} | ||
|
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.
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.
Nit: could we take this opportunity and refactor/cleanup bearer token functionality into a standalone package? We have
./cmd/query/app/token_propagation_handler.go
and ./storage/spanstore/token_propagation.go, which should really be in a single package like./pkg/bearertoken
.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.
Addressed in d1c96ad.