Skip to content

do not store responses to authenticated requests in the shared cache - #941

Open
Hsnmohd wants to merge 1 commit into
apache:masterfrom
Hsnmohd:cache-authenticated-response
Open

Hsnmohd wants to merge 1 commit into
apache:masterfrom
Hsnmohd:cache-authenticated-response

Conversation

@Hsnmohd

@Hsnmohd Hsnmohd commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

CachingExec and AsyncCachingExec run above ProtocolExec, so the RFC 9111 3.5 shared-cache check never sees the Authorization header generated from the CredentialsProvider or AuthCache (the classic exec always sends a copy down the chain, and both protocol execs copy the request on a non-tunnelled proxy route), which let a 200 with Cache-Control: max-age=60 returned to alice's authenticated request be stored in the default shared cache and served to a context with no credentials; the fix treats the response as authenticated when the route target's AuthExchange is in SUCCESS state.

* A shared cache must not store a response to a request that the protocol layer
* authenticated with credentials from the credentials provider.
*/
class TestCachingExecAuthenticatedResponse {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hsnmohd Please move this test case to TestClientAuthentication

@ok2c

ok2c commented Nov 14, 2026

Copy link
Copy Markdown
Member

@Hsnmohd Better yet, consider starting new test suites for caching clients (classic and async). There are TestAsyncServerResources, TestServerResources, CachingHttpAsyncClientResource, CachingHttpClientResource tests extensions that one can use to set up test resources required for such tests suites.

@arturobernalg arturobernalg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced a case not covered by this fix: preemptive authentication sends Authorization while AuthExchange remains UNCHALLENGED, so isTargetAuthenticated() returns false.

Both classic and async caching clients serve Alice's cached private response to an anonymous request instead of returning 401.

We should cover this case before merging.

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.

3 participants