-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
IPStrategy for selecting IP in whitelist #3778
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.
First review
Nice job 👏
return false | ||
} | ||
err := x.ipChecker.IsAuthorized(ip) | ||
return err == nil |
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.
Shoud be replaced by
return x.ipChecker.IsAuthorized(ip) == nil
if err != nil { | ||
log.Fatalf("Error creating whitelist middleware: %s", err) | ||
} | ||
ipWhitelistMiddleware, err := middlewares.NewIPWhiteLister(globalConfiguration.EntryPoints[entryPointName].WhiteList.SourceRange, strategy) |
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 please add a new line before
if globalConfiguration.EntryPoints[entryPointName].WhiteList.IPStrategy != nil { | ||
ipStrategy = globalConfiguration.EntryPoints[entryPointName].WhiteList.IPStrategy | ||
} | ||
strategy, err := ipStrategy.Get() |
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 please add a new line before
integration/basic_test.go
Outdated
req.Header.Set("X-Forwarded-For", test.xForwardedFor) | ||
req.Host = test.host | ||
req.RequestURI = "" | ||
err = try.Request(req, 1*time.Second, try.StatusCodeIs(test.expectedStatusCode)) |
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 please add a new line before
@@ -17,7 +17,8 @@ checkNewVersion = false | |||
entryPoint = "http" | |||
[entryPoints.httpWhitelistReject] | |||
address = ":8002" | |||
whiteListSourceRange = ["8.8.8.8/32"] | |||
[entryPoints.httpWhitelistReject.whiteList] | |||
SourceRange = ["8.8.8.8/32"] |
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 sourceRange
ip/checker_test.go
Outdated
} | ||
|
||
func TestNew(t *testing.T) { | ||
cases := []struct { |
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 please rename cases
by testCases
ip/checker_test.go
Outdated
test := test | ||
t.Run(test.desc, func(t *testing.T) { | ||
t.Parallel() | ||
ipChecker, err := NewChecker(test.trustedIPs) |
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 please add a new line before
ip/checker_test.go
Outdated
} | ||
|
||
func TestContainsIsAllowed(t *testing.T) { | ||
cases := []struct { |
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 please rename cases
by testCases
return xffs[i] | ||
} | ||
} | ||
return "" |
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 please add a new line before
server/server_middlewares.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
return middlewares.NewIPWhiteLister(whiteList.SourceRange, strategy) |
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 please add a new line before
dab825a
to
e31ce96
Compare
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
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
What does this PR do?
Motivation
More secure way to handle forwarded headers and to handle the whitelist.
Related #3646
More