Repository navigation
fix(web): extend S3 endpoint policy and frame headers to remaining routes - #3037
Merged
Merged
Conversation
Member
Author
|
@greptileai review |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1932 and #2997.
S3 endpoint policy
#1932 added
apps/web/lib/s3-endpoint-policy.tsand applied it to the desktop S3 config save and/testroutes. The same server-side request path existed in two more places, so this applies the same policy there:apps/web/actions/organization/storage.ts:saveOrganizationS3ConfigandtestOrganizationS3Configapps/web/app/api/v1/[...route]/route.ts:PUT /organizations/:id/storage/s3andPOST /organizations/:id/storage/s3/test(both go throughresolveAgentS3ConfigandtestAgentS3Config)Behaviour matches #1932:
NEXT_PUBLIC_IS_CAP=trueandNODE_ENV=production. Self-hosted and dev keep localhost and LAN MinIO.localhost,*.localhost,*.internal, contain credentials, use a non-http(s) scheme, or resolve to any private address are rejected with the same message as the desktop route, before any S3 request is made.publicOnlyLookupagents, so a hostname that changes its DNS answer between the check and the connection is still refused.To avoid a third copy of the gate,
isDisallowedS3Endpoint,publicOnlyS3AgentsandblockedS3EndpointMessagenow live in the policy module, and the desktop route uses them too. The desktop route's behaviour is unchanged.publicOnlyS3Agents()returnsundefinedoutside Cap Cloud, so self-hosted S3 clients keep the SDK default request handler exactly as before.Frame headers
/admin,/signupand/verify-otpare added toFRAME_PROTECTED_PATHSinapps/web/proxy.ts, so they getX-Frame-Options: SAMEORIGINandframe-ancestors https://cap.solike/dashboardand/login./embed,/sand/care unchanged and stay frameable.Tests
__tests__/unit/organization-storage-s3-endpoint.test.ts(new): save and test server actions reject private endpoints on Cap Cloud without writing or connecting, accept public and empty endpoints, use public-only agents for the test connection, and allow local endpoints on self-hosted and dev.__tests__/unit/agent-s3-endpoint-policy.test.ts(new): drives the real v1 handler for PUT and POST/storage/s3, checks a 400INVALID_REQUESTwith no S3 client created for private endpoints (including a padded[::1]endpoint), public-only agents for public endpoints, and no change on self-hosted.__tests__/unit/s3-endpoint-policy.test.ts: covers the new helpers.__tests__/unit/proxy-frame-headers.test.ts: adds/admin,/admin/*,/signupand/verify-otpto the protected list, and/administrator,/signupsand/verify-otp-helpto the unprotected list to check prefix matching.The new storage and v1 tests fail on main and pass on this branch.


Confidence Score: 5/5
The PR appears safe to merge; no actionable new issues were found.Summary
Extends the existing S3 endpoint policy to organization storage actions and the v1 API.
No actionable new issues were found. Tests were reviewed but not run.
Reviews (2) · Last reviewed commit: "fix(web): set frame headers on admin, si..." · Reviewed by Greptile