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

Proxy: use a global switch for Filter Middleware #501

Merged
merged 5 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/proxy/actions/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ func App() (*buffalo.App, error) {
app.Stop(err)
}
app.Use(T.Middleware())
app.Use(newFilterMiddleware(mf))
if !env.FilterOff() {
Copy link
Member

Choose a reason for hiding this comment

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

👍

app.Use(newFilterMiddleware(mf))
}
user, pass, ok := env.BasicAuth()
if ok {
app.Use(basicAuth(user, pass))
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/env/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ const defaultConfigurationFileName = "filter.conf"
func FilterConfigurationFileName() string {
return envy.Get("ATHENS_FILTER_FILENAME", defaultConfigurationFileName)
}

// FilterOff checks PROXY_FILTER_OFF env and returns
// true of it's equal to "true", otherwise false always.
// It defaults to "true" until Olympus is the default
// place to grab modules before the Proxy.
func FilterOff() bool {
return envy.Get("PROXY_FILTER_OFF", "true") == "true"
Copy link

Choose a reason for hiding this comment

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

Should the envy call default to false as the check is whether the filter is off?

like envy.Get("PROXY_FILTER_OFF", "false") == "true"
if PROXY_FILTER_OFF was true, result would be true
if PROXY_FILTER_OFF was 'false' result would be false

the way it is now, with default of true, if the user does not set PROXY_FILTER_OFF the result will be true.

Copy link

Choose a reason for hiding this comment

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

I guess not, re-reading the comment clears that up. :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes by default, it's just the Proxy, no filtering needed. But we will use Olympus by default once Olympus is ready.

}