fix domain field in setAccessKeyCookies
This commit is contained in:
parent
b63274ad01
commit
4361c44128
17
access.go
17
access.go
|
@ -3,7 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -70,19 +73,25 @@ func checkAccessKey(r *http.Request, metadata *backends.Metadata) (accessKeySour
|
||||||
return accessKeySourceNone, errInvalidAccessKey
|
return accessKeySourceNone, errInvalidAccessKey
|
||||||
}
|
}
|
||||||
|
|
||||||
func setAccessKeyCookies(w http.ResponseWriter, domain, fileName, value string, expires time.Time) {
|
func setAccessKeyCookies(w http.ResponseWriter, siteURL, fileName, value string, expires time.Time) {
|
||||||
|
u, err := url.Parse(siteURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("cant parse siteURL (%v): %v", siteURL, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cookie := http.Cookie{
|
cookie := http.Cookie{
|
||||||
Name: accessKeyHeaderName,
|
Name: accessKeyHeaderName,
|
||||||
Value: value,
|
Value: value,
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Domain: domain,
|
Domain: u.Hostname(),
|
||||||
Expires: expires,
|
Expires: expires,
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie.Path = Config.sitePath + fileName
|
cookie.Path = path.Join(u.Path, fileName)
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
|
|
||||||
cookie.Path = Config.sitePath + Config.selifPath + fileName
|
cookie.Path = path.Join(u.Path, Config.selifPath, fileName)
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue