Must run oauth from same subdomain but no longer use query params

This commit is contained in:
bel
2019-12-31 11:20:37 -07:00
parent f7c111bd2f
commit 168c230771
4 changed files with 61 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ import (
"local/storage"
"net/http"
"net/url"
"strings"
"github.com/google/uuid"
)
@@ -39,9 +40,13 @@ func (s *Server) authorize(w http.ResponseWriter, r *http.Request) {
if url.Scheme == "" {
url.Scheme = "http"
}
values := url.Query()
values.Set(oauth2.COOKIE, access)
url.RawQuery = values.Encode()
cookie := &http.Cookie{
Name: oauth2.NEWCOOKIE,
Value: access,
Path: "/",
Domain: "." + strings.Join(strings.Split(strings.Split(url.Host, ":")[0], ".")[1:], "."),
}
http.SetCookie(w, cookie)
http.Redirect(w, r, url.String(), http.StatusSeeOther)
} else {
fmt.Fprintln(w, "OK")