Must run oauth from same subdomain but no longer use query params
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -22,6 +23,7 @@ func TestAll(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer oauth2server.Close()
|
||||
oauth2server.URL = strings.ReplaceAll(oauth2server.URL, "127.0.0.1", "echo.belbox.dev")
|
||||
|
||||
s := dummyServer(oauth2server.URL)
|
||||
defer s.Close()
|
||||
@@ -138,7 +140,7 @@ func testAuth(oauth2server, dummy string) error {
|
||||
return err
|
||||
}
|
||||
log.Println("client should not redir...")
|
||||
if err := clientShouldNotRedir(c, dummy+"?"+oauth2.COOKIE+"="+access); err != nil {
|
||||
if err := clientShouldNotRedir(c, dummy+"?"+oauth2.NEWCOOKIE+"="+access); err != nil {
|
||||
return err
|
||||
}
|
||||
if !strings.Contains(fmt.Sprint(c.Jar), oauth2.COOKIE) {
|
||||
@@ -161,7 +163,15 @@ func clientLogin(c *http.Client, oauth2server string) (string, error) {
|
||||
if resp.Request.URL.Path != "/" {
|
||||
return "", fmt.Errorf("login response path wrong: %v", resp.Request.URL.Path)
|
||||
}
|
||||
a := resp.Request.URL.Query().Get(oauth2.COOKIE)
|
||||
a := resp.Request.URL.Query().Get(oauth2.NEWCOOKIE)
|
||||
if a == "" {
|
||||
cookies := c.Jar.Cookies(&url.URL{Scheme: "http", Path: "/", Host: "echo.belbox.dev"})
|
||||
for i := range cookies {
|
||||
if cookies[i].Name == oauth2.NEWCOOKIE {
|
||||
a = cookies[i].Value
|
||||
}
|
||||
}
|
||||
}
|
||||
if a == "" {
|
||||
return "", fmt.Errorf("login and redir didnt set cookie: %v", a)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user