set the cookie jar domain handler to the root domain

This commit is contained in:
Cam 2023-09-12 16:16:49 -05:00
parent 0c2e83fb9d
commit 67a981980b
No known key found for this signature in database
GPG Key ID: 367B7C7EBD84A8BD
2 changed files with 20 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"io"
"net/http"
"net/url"
"strings"
"time"
"github.com/golang-jwt/jwt/v5"
@ -43,7 +44,15 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
key := []byte(cfg.HashKeyRaw)
cookieHandler := zhttp.NewCookieHandler(key, key, zhttp.WithUnsecure(), zhttp.WithDomain(cfg.RedirectUrl))
u, err := url.Parse(redirectUrl)
if err != nil {
logrus.Errorf("unable to parse redirect url: %v", err)
return err
}
parts := strings.Split(u.Hostname(), ".")
domain := parts[len(parts)-2] + "." + parts[len(parts)-1]
cookieHandler := zhttp.NewCookieHandler(key, key, zhttp.WithUnsecure(), zhttp.WithDomain(domain))
options := []rp.Option{
rp.WithCookieHandler(cookieHandler),

View File

@ -6,6 +6,7 @@ import (
"io"
"net/http"
"net/url"
"strings"
"time"
"github.com/golang-jwt/jwt/v5"
@ -44,7 +45,15 @@ func configureGoogleOauth(cfg *OauthConfig, tls bool) error {
key := []byte(cfg.HashKeyRaw)
cookieHandler := zhttp.NewCookieHandler(key, key, zhttp.WithUnsecure(), zhttp.WithDomain(cfg.RedirectUrl))
u, err := url.Parse(redirectUrl)
if err != nil {
logrus.Errorf("unable to parse redirect url: %v", err)
return err
}
parts := strings.Split(u.Hostname(), ".")
domain := parts[len(parts)-2] + "." + parts[len(parts)-1]
cookieHandler := zhttp.NewCookieHandler(key, key, zhttp.WithUnsecure(), zhttp.WithDomain(domain))
options := []rp.Option{
rp.WithCookieHandler(cookieHandler),