Log OAuth sign-ins and failures; show providers' error text unescaped
Sign-in starts (with the redirect URI sent) and failures are logged, so a failed connection can be diagnosed from `supermarket logs`. LinkedIn sends error_description HTML-escaped, which showed as " on the error page; it's unescaped before display. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -319,6 +319,18 @@ func TestCallbackURLs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOAuthErrorIsShownOnce(t *testing.T) {
|
||||
s, h := newTestServer(t, nil)
|
||||
_ = s.Secrets.Set(map[string]string{secrets.LinkedInClientID: "cid", secrets.LinkedInClientSecret: "cs"})
|
||||
loc, _ := url.Parse(postForm(h, "/auth/linkedin/start", nil).Header().Get("Location"))
|
||||
state := loc.Query().Get("state")
|
||||
body := do(h, http.MethodGet, "/auth/linkedin/callback?state="+state+"&error=unauthorized_scope_error&error_description="+
|
||||
url.QueryEscape("Scope "openid" is not authorized"), nil, nil).Body.String()
|
||||
if !strings.Contains(body, "Scope "openid" is not authorized") || strings.Contains(body, "&quot;") {
|
||||
t.Errorf("error page:\n%s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOAuthCallbackRejectsUnknownState(t *testing.T) {
|
||||
_, h := newTestServer(t, nil)
|
||||
rec := do(h, http.MethodGet, "/auth/x/callback?state=nope&code=c", nil, nil)
|
||||
|
||||
Reference in New Issue
Block a user