Skip to content

Added expanding environment variables for allow* methods #48

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

Open
wants to merge 1 commit into
base: 49-fr-added-expanding-environment-variables-for-allow-methods
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ It is also possible to configure the allowlist via environment variables. The va

If both commandline parameter and environment variable is configured for a particular HTTP method, the environment variable is ignored.

Use Go's regexp syntax to create the patterns for these parameters. To avoid insecure configurations, the characters ^ at the beginning and $ at the end of the string are automatically added. Note: invalid regexp results in program termination.
Use Go's regexp syntax to create the patterns for these parameters. To avoid insecure configurations, the characters ^ at the beginning and $ at the end of the string are automatically added. Note: invalid regexp results in program termination. It also will be expanded with environment variables.

Examples (command line):
+ `'-allowGET=/v1\..{1,2}/(version|containers/.*|events.*)'` could be used for allowing access to the docker socket for Traefik v2.
Expand Down
5 changes: 5 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ func InitConfig() (*Config, error) {
}
flag.Parse()

for i := range mr {
mr[i].regexStringFromParam = os.ExpandEnv(mr[i].regexStringFromParam)
mr[i].regexStringFromEnv = os.ExpandEnv(mr[i].regexStringFromEnv)
}

// check listenIP and proxyPort
if net.ParseIP(listenIP) == nil {
return nil, fmt.Errorf("invalid IP \"%s\" for listenip", listenIP)
Expand Down