mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
fix(oidc): use XFH header from backend for cookie domain
This commit is contained in:
parent
5a984f5c0c
commit
0a8aa2b215
1 changed files with 13 additions and 3 deletions
|
@ -25,10 +25,20 @@ var (
|
||||||
// "abc.example.com" -> "example.com"
|
// "abc.example.com" -> "example.com"
|
||||||
// "example.com" -> ""
|
// "example.com" -> ""
|
||||||
func cookieFQDN(r *http.Request) string {
|
func cookieFQDN(r *http.Request) string {
|
||||||
host, _, err := net.SplitHostPort(r.Host)
|
var host string
|
||||||
|
// check if it's from backend
|
||||||
|
switch r.Host {
|
||||||
|
case common.APIHTTPAddr:
|
||||||
|
// use XFH
|
||||||
|
host = r.Header.Get("X-Forwarded-Host")
|
||||||
|
default:
|
||||||
|
var err error
|
||||||
|
host, _, err = net.SplitHostPort(r.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
host = r.Host
|
host = r.Host
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parts := strutils.SplitRune(host, '.')
|
parts := strutils.SplitRune(host, '.')
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Add table
Reference in a new issue