fix(yaiam): check the sign-in cookie and state before discovery

A callback that belongs to no sign-in of this browser is now
ErrSignInState without contacting the provider (before, an unreachable
provider turned it into a discovery error).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-11-20 17:35:15 +01:00
1 parent 376ae3c970
commit 76543b23a0
3 files changed
+19 -5

No files matched your search

+11
View File
@@ -411,3 +411,14 @@ func TestAllowInsecure(t *testing.T) {
t.Error("http redirect URL off loopback taken without AllowInsecure")
}
}
// TestWebCallbackBeforeProvider: a callback without this browser's
// sign-in is refused before the provider is asked (here: unreachable).
func TestWebCallbackBeforeProvider(t *testing.T) {
w := &Web{Client: Client{Issuer: "http://127.0.0.1:9/t/default", ClientID: "web"}, RedirectURL: "http://localhost:8097/callback"}
for _, cookie := range []*http.Cookie{nil, {Name: "yaiam_signin", Value: "!!"}} {
if _, _, err := callback(w, "code=c&state=s", cookie); !errors.Is(err, ErrSignInState) {
t.Errorf("cookie %v: %v", cookie, err)
}
}
}