Sign-ins finish only in the browser that started them
A Core sign-in, and a posting account's or Search Console's OAuth sign-in, now sets a short-lived cookie whose hash the flow keeps on the server. The callback refuses one without it (constant-time compare), clears the cookie either way, and the flow is used up regardless. This stops login CSRF: a callback URL brought to another browser signs nobody in. The cookie uses the __Host- prefix over https, so its Path is "/". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,7 +80,7 @@ func TestSearchConsole(t *testing.T) {
|
||||
if !strings.HasPrefix(loc.String(), srv.URL+"/auth") || q.Get("access_type") != "offline" || !strings.Contains(q.Get("scope"), "webmasters.readonly") || q.Get("code_challenge") == "" {
|
||||
t.Fatalf("start: %s", loc)
|
||||
}
|
||||
rec = do(h, http.MethodGet, "/auth/google/callback?state="+url.QueryEscape(q.Get("state"))+"&code=c0de", nil, nil)
|
||||
rec = getWith(h, "/auth/google/callback?state="+url.QueryEscape(q.Get("state"))+"&code=c0de", cookieOf(rec, oauthFlowCookie))
|
||||
if rec.Code != http.StatusSeeOther || !strings.HasPrefix(rec.Header().Get("Location"), "/settings/search?msg=google-connected") {
|
||||
t.Fatalf("callback: %d %s %s", rec.Code, rec.Header().Get("Location"), rec.Body)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user