Browse Source

address comments

pull/7403/head
chrislu 1 month ago
parent
commit
21f0d959f0
  1. 2
      weed/s3api/auth_signature_v4.go
  2. 16
      weed/s3api/auto_signature_v4_test.go

2
weed/s3api/auth_signature_v4.go

@ -597,7 +597,7 @@ func extractHostHeader(r *http.Request) string {
// If X-Forwarded-Host is set, use that as the host. // If X-Forwarded-Host is set, use that as the host.
// If X-Forwarded-Port is set, use that too to form the host. // If X-Forwarded-Port is set, use that too to form the host.
// If X-Forwarded-Proto is set, check if is it default to omit the port.
// If X-Forwarded-Proto is set, check if it is default to omit the port.
if forwardedHost != "" { if forwardedHost != "" {
extractedHost := forwardedHost extractedHost := forwardedHost
host, port, err := net.SplitHostPort(extractedHost) host, port, err := net.SplitHostPort(extractedHost)

16
weed/s3api/auto_signature_v4_test.go

@ -419,7 +419,7 @@ func TestSignatureV4WithoutProxy(t *testing.T) {
}, },
{ {
name: "HTTPS with standard port", name: "HTTPS with standard port",
host: "backend:433",
host: "backend:443",
proto: "https", proto: "https",
expectedHost: "backend", expectedHost: "backend",
}, },
@ -455,7 +455,7 @@ func TestSignatureV4WithoutProxy(t *testing.T) {
}, },
{ {
name: "IPv6 HTTPS with standard port", name: "IPv6 HTTPS with standard port",
host: "[::1]:433",
host: "[::1]:443",
proto: "https", proto: "https",
expectedHost: "::1", expectedHost: "::1",
}, },
@ -582,9 +582,9 @@ func TestSignatureV4WithForwardedPort(t *testing.T) {
}, },
{ {
name: "X-Forwarded-Host with standard https port already included (Traefik/HAProxy style)", name: "X-Forwarded-Host with standard https port already included (Traefik/HAProxy style)",
host: "backend:433",
forwardedHost: "127.0.0.1:433",
forwardedPort: "433",
host: "backend:443",
forwardedHost: "127.0.0.1:443",
forwardedPort: "443",
forwardedProto: "https", forwardedProto: "https",
expectedHost: "127.0.0.1", expectedHost: "127.0.0.1",
}, },
@ -598,9 +598,9 @@ func TestSignatureV4WithForwardedPort(t *testing.T) {
}, },
{ {
name: "IPv6 X-Forwarded-Host with standard https port already included (Traefik/HAProxy style)", name: "IPv6 X-Forwarded-Host with standard https port already included (Traefik/HAProxy style)",
host: "backend:433",
forwardedHost: "[::1]:433",
forwardedPort: "433",
host: "backend:443",
forwardedHost: "[::1]:443",
forwardedPort: "443",
forwardedProto: "https", forwardedProto: "https",
expectedHost: "::1", expectedHost: "::1",
}, },

Loading…
Cancel
Save