-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Forward Authentication: add X-Forwarded-Uri #2398
Conversation
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.
Thanks for the contribution 👍
XForwardedHost = "X-Forwarded-Host" | ||
XForwardedPort = "X-Forwarded-Port" | ||
XForwardedServer = "X-Forwarded-Server" | ||
XForwardedURI = "X-Forwarded-Uri" |
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.
It's not authorized to manually change files in /vendor
.
Please move this change into middlewares/auth/forward.go
middlewares/auth/forward.go
Outdated
@@ -122,4 +122,8 @@ func writeHeader(req *http.Request, forwardReq *http.Request, trustForwardHeader | |||
} else { | |||
forwardReq.Header.Del(forward.XForwardedHost) | |||
} | |||
|
|||
if forwardURI { |
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.
Could you use the same process as others header?
And remove the forwardURI
option
if xfURI := req.Header.Get(XForwardedURI); xfURI != "" && trustForwardHeader {
forwardReq.Header.Set(XForwardedURI, xfURI)
} else if req.URL.RequestURI() != "" {
forwardReq.Header.Set(XForwardedURI, req.URL.RequestURI())
} else {
forwardReq.Header.Del(XForwardedURI)
}
types/types.go
Outdated
@@ -353,6 +353,7 @@ type Forward struct { | |||
Address string `description:"Authentication server address"` | |||
TLS *ClientTLS `description:"Enable TLS support" export:"true"` | |||
TrustForwardHeader bool `description:"Trust X-Forwarded-* headers" export:"true"` | |||
ForwardURI bool `description:"Forward requested URI to authenticator"` |
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.
Could you remove this option? see my previous comment.
middlewares/auth/forward_test.go
Outdated
@@ -162,6 +162,7 @@ func Test_writeHeader(t *testing.T) { | |||
name string | |||
headers map[string]string | |||
trustForwardHeader bool | |||
forwardUri bool |
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.
Could you remove this? see my previous comment.
docs/configuration/entrypoints.md
Outdated
# Optional | ||
# Default: false | ||
# | ||
forwardUri = true |
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.
Could you remove this option? see my next comment.
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.
Could you fix this?
These files are not properly gofmt'd:
- middlewares/auth/forward_test.go
middlewares/auth/forward_test.go
Outdated
|
||
writeHeader(req, forwardReq, test.trustForwardHeader) | ||
|
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.
Could you restore this line?
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.
Of course. Sorry for this.
Can you tell me which tool will handle such formatting? go fmt
does not. Or was it just manual checking? Thanks.
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.
It's gofmt
on our CI: https://semaphoreci.com/containous/traefik/branches/pull-request-2398/builds/3
In local you can do make validate
.
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.
Thank you. I see and will check all those validation tests you integrated. Sadly validate-gofmt
doesn't producde the error when the blank line is missing (Go 1.9.2).
I will check those validation results on GitHub next time.
middlewares/auth/forward.go
Outdated
@@ -12,6 +12,10 @@ import ( | |||
"github.com/vulcand/oxy/utils" | |||
) | |||
|
|||
const ( | |||
XForwardedURI = "X-Forwarded-Uri" |
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.
Could you rename to xForwardedURI
?
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.
LGTM
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.
LGTM
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.
LGTM
@SebastianBauer Could you please rebase your PR on master ? |
What does this PR do?
Added requested URI to auth server for Forward Authentication.
Motivation
Missing feature for authentication decision based on the URI (frontend).
More
Added implementation, docs and test.
Additional Notes
Could be good enough for #2162 as well.