Repository navigation
do not store responses to authenticated requests in the shared cache - #941
Conversation
| * A shared cache must not store a response to a request that the protocol layer | ||
| * authenticated with credentials from the credentials provider. | ||
| */ | ||
| class TestCachingExecAuthenticatedResponse { |
There was a problem hiding this comment.
@Hsnmohd Please move this test case to TestClientAuthentication
There was a problem hiding this comment.
Went with your follow-up instead: the tests now live in new caching client suites under org.apache.hc.client5.testing.caching, and the class in httpclient5-cache is gone.
|
@Hsnmohd Better yet, consider starting new test suites for caching clients (classic and async). There are |
arturobernalg
left a comment
There was a problem hiding this comment.
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.
Check the request last sent to the backend for an Authorization header in addition to the target AuthExchange state, so responses to requests authenticated preemptively from the AuthCache are not stored either. Move the regression tests to new classic and async caching client test suites in httpclient5-testing.
e7b313e to
117f1d7
Compare
|
@arturobernalg good catch. With preemptive auth the exchange stays @ok2c the tests are now in |
ok2c
left a comment
There was a problem hiding this comment.
@Hsnmohd Looks good to me. It would be nice though to fix the deprecation warning and remove the reference to the deprecated method
@arturobernalg Please review.
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
200withCache-Control: max-age=60returned 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.