mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 22:30:47 +01:00
feat(auth): enhance cookieDomain function to support additional local domains
This commit is contained in:
@@ -3,6 +3,7 @@ package auth
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/common"
|
||||
@@ -44,8 +45,21 @@ func requestHost(r *http.Request) string {
|
||||
//
|
||||
// "abc.example.com" -> ".example.com" (cross subdomain)
|
||||
// "example.com" -> "" (same domain only)
|
||||
// "abc.localhost" -> ".localhost"
|
||||
// "abc.local" -> ".local"
|
||||
// "abc.internal" -> ".internal"
|
||||
func cookieDomain(r *http.Request) string {
|
||||
parts := strutils.SplitRune(requestHost(r), '.')
|
||||
reqHost := requestHost(r)
|
||||
switch {
|
||||
case strings.HasSuffix(reqHost, ".internal"):
|
||||
return ".internal"
|
||||
case strings.HasSuffix(reqHost, ".localhost"):
|
||||
return ".localhost"
|
||||
case strings.HasSuffix(reqHost, ".local"):
|
||||
return ".local"
|
||||
}
|
||||
|
||||
parts := strutils.SplitRune(reqHost, '.')
|
||||
if len(parts) < 2 {
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user