feat(forge,core): fetch and decode authenticated images #69
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/65-authenticated-images"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Lets the app fetch and decode images the forge serves behind a login (attachments in PR and issue bodies). Groundwork for inline images (#60); nothing user-visible changes yet.
Changes
forge.AssetReader(optional capability,forge.ActAssets) and aSameOrigincheck. The gitea adapter sendsAuthorization: tokenonly to the session's origin and strips it on any redirect that leaves that origin. Only 2xx succeeds; a redirect loop past 10 hops errors; errors never carry a query string.forgetest.Fakeimplements it with an embedded demo PNG, and the contract suite exercises it for both the Fake and gitea.core.Service.ImageandPeekImage(returns(image.Image, bool, error)): resolve against<host>/<owner>/<repo>/, refuse off-host and userinfo URLs with no I/O, 20 s timeout, 10 MiB read cap, 40 MP cap, PNG/JPEG/GIF decode, downscale to 1600 px, 16-entry LRU that also caches failures and is cleared byr.docs/architecture.mdForge listing, ADR 0014 Consequences.Decisions
CheckRedirect, because Go forwards it to the same hostname on any port.PeekImagereturns(image.Image, bool, error)to satisfy revive's error-return rule.Test plan
make build,make test(race),go vet,gofumpt,golangci-lintv2.14.0 (built locally with the repo's toolchain; 0 issues). shellcheck is not installed locally; CI covers it./attachments/could not be tested against a live host (none available); the httptest fixture covers header, foreign origin and redirect.Follow-ups
Refs #65
🤖 Generated with Claude Code
https://claude.ai/code/session_01APHERaPcnmg6YuAkRuoDYq