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

Allow token propagation if token type is not specified #1685

Merged

Conversation

rubenvp8510
Copy link
Contributor

@rubenvp8510 rubenvp8510 commented Jul 24, 2019

Which problem is this PR solving?

  • openshift oauth-proxy (and is possible that other proxies) does not put the authorization header in the form Authorization: <type> <token> , they put the token in the form Authorization: <token> and assumed that the token there is a bearer token.

Short description of the changes

  • Allow those kind of tokens to be propagated.

@codecov
Copy link

codecov bot commented Jul 24, 2019

Codecov Report

Merging #1685 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1685      +/-   ##
==========================================
+ Coverage   98.49%   98.49%   +<.01%     
==========================================
  Files         193      193              
  Lines        9284     9286       +2     
==========================================
+ Hits         9144     9146       +2     
  Misses        111      111              
  Partials       29       29
Impacted Files Coverage Δ
cmd/query/app/token_propagation_handler.go 100% <100%> (ø) ⬆️

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 966dd7e...3852889. Read the comment docs.

@yurishkuro
Copy link
Member

lgtm but I don't think we want all those log statements

@rubenvp8510
Copy link
Contributor Author

@yurishkuro ok I can remove it

@rubenvp8510
Copy link
Contributor Author

I remove one, and change to debug others. Is that ok? or do you prefer to get rid of it?

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

I think all log statements except for warning on unparseable header should be removed. They provide little value in production.

if authHeaderValue != "" {
headerValue := strings.Split(authHeaderValue, " ")
token := ""
if len(headerValue) == 2 {
// Make sure we only capture bearer token , not other types like Basic auth.
if headerValue[0] == "Bearer" {
token = headerValue[1]
} else {
logger.Debug("Unsupported type of token " + headerValue[0] + " skipping token propagation")
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to log this?

@@ -26,21 +27,30 @@ import (
func bearerTokenPropagationHandler(logger *zap.Logger, h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
logger.Info("Propagating bearer token")
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to log this?

@@ -26,21 +27,30 @@ import (
func bearerTokenPropagationHandler(logger *zap.Logger, h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
logger.Info("Propagating bearer token")
log.Print(r)
Copy link
Member

Choose a reason for hiding this comment

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

We don't use log package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ups it was not my intend to have this here.

if authHeaderValue == "" {
authHeaderValue = r.Header.Get("X-Forwarded-Access-Token")
}
logger.Info("Token: " + authHeaderValue)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to log this?

@rubenvp8510
Copy link
Contributor Author

Done, logs removed, except warning log for unparseable header.

@yurishkuro yurishkuro merged commit 7f1daf2 into jaegertracing:master Jul 25, 2019
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.

2 participants