Skip to content
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
4 changes: 4 additions & 0 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,7 @@ func getConsoleAnimatedLogin() bool {
func getConsoleBrowserRedirectURL() string {
return env.Get(ConsoleBrowserRedirectURL, "")
}

func getConsoleUseProxyForSharedURL() bool {
return strings.ToLower(env.Get(ConsoleUseProxyForSharedURL, "on")) == "on"
}
1 change: 1 addition & 0 deletions api/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
ConsoleDevMode = "CONSOLE_DEV_MODE"
ConsoleAnimatedLogin = "CONSOLE_ANIMATED_LOGIN"
ConsoleBrowserRedirectURL = "CONSOLE_BROWSER_REDIRECT_URL"
ConsoleUseProxyForSharedURL = "CONSOLE_USE_PROXY_FOR_SHARED_URL"
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
SlashSeparator = "/"
LocalAddress = "127.0.0.1"
Expand Down
4 changes: 4 additions & 0 deletions api/user_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,10 @@ func getShareObjectURL(ctx context.Context, client MCClient, r *http.Request, ve
return nil, pErr.Cause
}

if !getConsoleUseProxyForSharedURL() {
return &minioURL, nil
}

requestURL := getRequestURLWithScheme(r)
encodedURL := base64.RawURLEncoding.EncodeToString([]byte(minioURL))

Expand Down
19 changes: 19 additions & 0 deletions api/user_objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,25 @@ func Test_shareObject(t *testing.T) {
wantError: nil,
expected: "http://proxy-url.com:9012/console/subpath/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw",
},
{
test: "returns directly url with share link if use proxy for shared url env variable is off",
setEnvVars: func() {
t.Setenv(ConsoleUseProxyForSharedURL, "off")
},
args: args{
r: &http.Request{
TLS: nil,
Host: "localhost:9090",
},
versionID: "2121434",
expires: "30s",
shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) {
return "http://someurl", nil
},
},
wantError: nil,
expected: "http://someurl",
},
}

for _, tt := range tests {
Expand Down