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

Forward Authentication: add X-Forwarded-Uri #2398

Merged
merged 1 commit into from Dec 9, 2017
Merged

Forward Authentication: add X-Forwarded-Uri #2398

merged 1 commit into from Dec 9, 2017

Conversation

ghost
Copy link

@ghost ghost commented Nov 12, 2017

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.

@juliens juliens changed the title Forard Authentication: Add requested URI to auth server Forward Authentication: Add requested URI to auth server Nov 12, 2017
@juliens juliens added kind/enhancement a new or improved feature. size/S and removed area/middleware size/S labels Nov 12, 2017
@ldez ldez changed the title Forward Authentication: Add requested URI to auth server Forward Authentication: add X-Forwarded-Uri Nov 13, 2017
Copy link
Contributor

@ldez ldez left a 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"
Copy link
Contributor

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

@@ -122,4 +122,8 @@ func writeHeader(req *http.Request, forwardReq *http.Request, trustForwardHeader
} else {
forwardReq.Header.Del(forward.XForwardedHost)
}

if forwardURI {
Copy link
Contributor

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"`
Copy link
Contributor

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.

@@ -162,6 +162,7 @@ func Test_writeHeader(t *testing.T) {
name string
headers map[string]string
trustForwardHeader bool
forwardUri bool
Copy link
Contributor

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.

# Optional
# Default: false
#
forwardUri = true
Copy link
Contributor

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.

Copy link
Contributor

@ldez ldez left a 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


writeHeader(req, forwardReq, test.trustForwardHeader)

Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

@ldez ldez Nov 14, 2017

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.

Copy link
Author

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.

@@ -12,6 +12,10 @@ import (
"github.com/vulcand/oxy/utils"
)

const (
XForwardedURI = "X-Forwarded-Uri"
Copy link
Contributor

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?

Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

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

LGTM

@mmatur mmatur added this to the 1.6 milestone Dec 6, 2017
Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

@mmatur
Copy link
Member

mmatur commented Dec 8, 2017

@SebastianBauer Could you please rebase your PR on master ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants