Skip to content

Read the forwarded client credential only when an edge announced it - #34

Open
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/forwarded-authorization-needs-capability
Open

Read the forwarded client credential only when an edge announced it#34
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/forwarded-authorization-needs-capability

Conversation

@0bserver07

Copy link
Copy Markdown

client_authorization in crates/walgit-server/src/auth.rs read X-Walgit-Authorization before checking whether an edge had announced client-authorization in X-Walgit-Capabilities. So a client talking to walgit directly could put a credential in the forwarded header and have it taken as its own. AGENTS.md D39 (2) and section 1.3 say the forwarded copy only counts behind an edge that announced it, and that nothing is assumed when walgit is hit directly.

Now the capability is checked first. Without it, Authorization is the client's and the forwarded header isn't read at all; with it, the forwarded copy is used and a missing copy still means no client credential, as before. Nobody gets in without a valid credential either way, since whatever comes back still goes through the same verification; this only makes which header is read match D39.

The unit test edge_owned_authorization_is_not_the_client now covers the missing direction: Bearer a in Authorization plus Bearer b forwarded yields a without the capability and b with it. Checked with cargo test -p walgit-server --lib auth:: (14 pass). Not exercised behind a real nginx.

Same pass as #25, #26, #27, #28, #29.

client_authorization in crates/walgit-server/src/auth.rs:897 read
X-Walgit-Authorization before it checked anything else, so a client talking to
walgit directly could put a credential in that header and have it taken as the
client credential. AGENTS.md D39 (2) and section 1.3 say the forwarded copy
counts only when an edge announced client-authorization in
X-Walgit-Capabilities on that request, and that nothing is assumed when walgit
is hit with nothing in front of it. The function now consults
edge_owns_authorization first and returns the plain Authorization header value
when no capability was announced, reaching for the forwarded copy only behind
an announcing edge. Behaviour behind an edge is unchanged, a missing forwarded
copy there still meaning the client sent no credential. The unit test
edge_owned_authorization_is_not_the_client now covers the direction that was
missing: Authorization Bearer a with X-Walgit-Authorization Bearer b and no
capability header yields a, and the same two headers with the capability
yield b.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant