Skip to content

Do not redirect or retry POST requests - #213

Merged
zachmann merged 2 commits into
go-oidfed:mainfrom
topperge:fix/no-redirect-retry-authenticated-post
Nov 12, 2026
Merged

zachmann merged 2 commits into
go-oidfed:mainfrom
topperge:fix/no-redirect-retry-authenticated-post

Conversation

@topperge

Copy link
Copy Markdown
Contributor

Fixes #211.

An authenticated federation request (§8.8) is a POST with the client assertion in its form body. In internal/http:

  • Redirects: the client's redirect policy refuses every redirect of a POST, so the request fails with an error instead of resending the assertion to the redirect target. Other methods keep FlexibleRedirectPolicy(10).
  • Retries: retryCondition returns false for a POST, so a dropped connection doesn't resend the same assertion jti. GETs are retried as before.

One detail: Resty retries when any client or request retry condition returns true, so a per-request "no retry" condition can't override the client's retryCondition. That's why the check sits in retryCondition itself. This covers every POST made through the shared client: the authenticated fetch, list, trust mark and resolve requests, Post/PostCtx, and the key rotation HTTP hook.

Tests (internal/http/http_test.go):

  • a POST answered with a 302, 307 or 308 fails, and the redirect target is never reached, both through Post and through Do().R().Post as clientauth.go uses it;
  • a GET still follows a redirect;
  • a POST to a server that drops the connection is sent once.

The new POST tests fail on main and pass with this change; go test ./... passes.

I added the changelog entry under a new "Unreleased" heading; please move it wherever you prefer.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QYDqsx3UGxpCKvCiUxShZq

An authenticated federation request (OpenID Federation 1.1 §8.8) is a
POST with the client assertion in its form body. The shared client
followed up to ten redirects for every method, so a 307 or 308 answer
resent the assertion to whatever host the redirect named. It also
retried POSTs after a network error, resending the same assertion jti,
which a compliant endpoint must refuse as a replay.

The redirect policy now refuses every redirect of a POST and keeps the
flexible policy for other methods. retryCondition never retries a POST;
this has to be decided in the client's condition, because Resty retries
when any client or request condition returns true.

Fixes go-oidfed#211

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QYDqsx3UGxpCKvCiUxShZq
@deepsource-io

deepsource-io Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in b721fbb...c3e77f3 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Nov 12, 2026 8:59a.m. Review ↗
Code coverage Nov 12, 2026 9:29a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@zachmann
zachmann merged commit a375aa6 into go-oidfed:main Nov 12, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authenticated federation POSTs follow redirects and are retried, resending the client assertion

2 participants