Auto-detect scheme for AUTHGUARD_URL instead of always assuming https
A bare host:port (e.g. a LAN AuthGuard reachable only over plain HTTP) was always defaulting to https, so a TLS handshake against a plain-HTTP AuthGuard failed at the transport level. Now a loopback, RFC1918/RFC4193 private, or link-local host (or a .local name) defaults to http instead; an explicit http:// or https:// is still always honored as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
730bf0463f
commit
449bb6fd6a
8 files changed
+241
-27
No files matched your search
@@ -14,10 +14,20 @@ func TestNewNormalizesBaseURL(t *testing.T) {
|
||||
input string
|
||||
want string
|
||||
}{
|
||||
{name: "bare host gets https", input: "auth.example.com", want: "https://auth.example.com"},
|
||||
{name: "bare host:port gets https", input: "192.168.1.50:8080", want: "https://192.168.1.50:8080"},
|
||||
{name: "explicit http is left alone", input: "http://auth.example.com", want: "http://auth.example.com"},
|
||||
{name: "explicit https is left alone", input: "https://auth.example.com", want: "https://auth.example.com"},
|
||||
{name: "bare public host gets https", input: "auth.example.com", want: "https://auth.example.com"},
|
||||
{name: "bare private host:port gets http", input: "192.168.1.50:8080", want: "http://192.168.1.50:8080"},
|
||||
{name: "bare public host:port gets https", input: "auth.example.com:8080", want: "https://auth.example.com:8080"},
|
||||
{name: "loopback IPv4 gets http", input: "127.0.0.1:8080", want: "http://127.0.0.1:8080"},
|
||||
{name: "10/8 private range gets http", input: "10.1.2.3:8080", want: "http://10.1.2.3:8080"},
|
||||
{name: "172.16/12 private range gets http", input: "172.20.0.5:8080", want: "http://172.20.0.5:8080"},
|
||||
{name: "172.x outside the 16-31 private range gets https", input: "172.32.0.5:8080", want: "https://172.32.0.5:8080"},
|
||||
{name: "link-local IPv4 gets http", input: "169.254.1.1:8080", want: "http://169.254.1.1:8080"},
|
||||
{name: "localhost name gets http", input: "localhost:8080", want: "http://localhost:8080"},
|
||||
{name: ".local mDNS name gets http", input: "authguard.local:8080", want: "http://authguard.local:8080"},
|
||||
{name: "loopback IPv6 gets http", input: "[::1]:8080", want: "http://[::1]:8080"},
|
||||
{name: "unique-local IPv6 gets http", input: "[fd00::1]:8080", want: "http://[fd00::1]:8080"},
|
||||
{name: "explicit http is left alone even for a public host", input: "http://auth.example.com", want: "http://auth.example.com"},
|
||||
{name: "explicit https is left alone even for a private host", input: "https://192.168.1.50:8080", want: "https://192.168.1.50:8080"},
|
||||
{name: "scheme match is case-insensitive", input: "HTTP://auth.example.com", want: "HTTP://auth.example.com"},
|
||||
{name: "trailing slash stripped before scheme check", input: "auth.example.com/", want: "https://auth.example.com"},
|
||||
{name: "surrounding whitespace trimmed", input: " auth.example.com ", want: "https://auth.example.com"},
|
||||
|
||||
Reference in new issue
Block a user