Skip to content

Commit 03caa98

Browse files
author
Xia Guanghui
committed
make CONSOLE_USE_PROXY_FOR_SHARED_URL tagglable
1 parent 2017f33 commit 03caa98

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

api/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,7 @@ func getConsoleAnimatedLogin() bool {
278278
func getConsoleBrowserRedirectURL() string {
279279
return env.Get(ConsoleBrowserRedirectURL, "")
280280
}
281+
282+
func getConsoleUseProxyForSharedURL() bool {
283+
return strings.ToLower(env.Get(ConsoleUseProxyForSharedURL, "on")) == "on"
284+
}

api/consts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
ConsoleDevMode = "CONSOLE_DEV_MODE"
5050
ConsoleAnimatedLogin = "CONSOLE_ANIMATED_LOGIN"
5151
ConsoleBrowserRedirectURL = "CONSOLE_BROWSER_REDIRECT_URL"
52+
ConsoleUseProxyForSharedURL = "CONSOLE_USE_PROXY_FOR_SHARED_URL"
5253
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
5354
SlashSeparator = "/"
5455
LocalAddress = "127.0.0.1"

api/user_objects.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,10 @@ func getShareObjectURL(ctx context.Context, client MCClient, r *http.Request, ve
10111011
return nil, pErr.Cause
10121012
}
10131013

1014+
if !getConsoleUseProxyForSharedURL() {
1015+
return &minioURL, nil
1016+
}
1017+
10141018
requestURL := getRequestURLWithScheme(r)
10151019
encodedURL := base64.RawURLEncoding.EncodeToString([]byte(minioURL))
10161020

api/user_objects_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,25 @@ func Test_shareObject(t *testing.T) {
10621062
wantError: nil,
10631063
expected: "http://proxy-url.com:9012/console/subpath/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw",
10641064
},
1065+
{
1066+
test: "returns directly url with share link if use proxy for shared url env variable is off",
1067+
setEnvVars: func() {
1068+
t.Setenv(ConsoleUseProxyForSharedURL, "off")
1069+
},
1070+
args: args{
1071+
r: &http.Request{
1072+
TLS: nil,
1073+
Host: "localhost:9090",
1074+
},
1075+
versionID: "2121434",
1076+
expires: "30s",
1077+
shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) {
1078+
return "http://someurl", nil
1079+
},
1080+
},
1081+
wantError: nil,
1082+
expected: "http://someurl",
1083+
},
10651084
}
10661085

10671086
for _, tt := range tests {

0 commit comments

Comments
 (0)