Skip to content

fix(surf-cli): route credentialed requests past response cache to isolate credentials - #40

Open
mertcano wants to merge 1 commit into
asksurf-ai:mainfrom
mertcano:mertcano-patch-1
Open

mertcano wants to merge 1 commit into
asksurf-ai:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Motivation

This PR ensures that credentialed HTTP requests in surf-cli correctly bypass the local disk response cache, preventing private responses from being improperly shared or leaked across distinct user credentials or local profiles[cite: 44, 45, 46].

Modifications

  • Credential-Aware Transport Routing (cli/transport.go):
    • Implemented credentialAwareTransport to check outbound requests for Authorization, Proxy-Authorization, or Cookie headers[cite: 45].
    • Automatically routes requests carrying session/auth credentials directly through the uncached default transport while maintaining standard caching behavior for anonymous requests[cite: 45].
  • Regression Testing (cli/transport_test.go):
    • Added TestCachedTransportDoesNotShareCredentialedResponses to verify that consecutive requests with differing bearer tokens hit the origin server independently rather than returning a cached response[cite: 46].

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

…late credentials

## Motivation

This PR ensures that credentialed HTTP requests in `surf-cli` correctly bypass the local disk response cache, preventing private responses from being improperly shared or leaked across distinct user credentials or local profiles[cite: 44, 45, 46].

## Modifications

* **Credential-Aware Transport Routing (`cli/transport.go`)**:
  * Implemented `credentialAwareTransport` to check outbound requests for `Authorization`, `Proxy-Authorization`, or `Cookie` headers[cite: 45].
  * Automatically routes requests carrying session/auth credentials directly through the uncached default transport while maintaining standard caching behavior for anonymous requests[cite: 45].
* **Regression Testing (`cli/transport_test.go`)**:
  * Added `TestCachedTransportDoesNotShareCredentialedResponses` to verify that consecutive requests with differing bearer tokens hit the origin server independently rather than returning a cached response[cite: 46].

## Checklist

- [x] Format your code according to the Contributor Guide.
- [x] Add unit tests as outlined in the Contributor Guide.
- [x] Update documentation as needed, including docstrings or example tutorials.
```[cite: 44, 45, 46]

This branch has not been deployed

No deployments
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