Repository navigation
feat(extension-auth): accept Firefox identity redirect hosts for extension auth - #1999
ManthanNimodiya wants to merge 5 commits into
Conversation
| ); | ||
| const configuredExtensionId = serverEnv().CAP_CHROME_EXTENSION_ID; | ||
| const extensionId = url.hostname.slice(0, -identityHost.suffix.length); | ||
| const configuredExtensionId = identityHost.getConfiguredExtensionId(); |
There was a problem hiding this comment.
Mixed-Case Firefox Id Rejection
URL.hostname is normalized to lowercase before extensionId is sliced, but the new Firefox id comes straight from CAP_FIREFOX_EXTENSION_ID. If that env var is copied with uppercase characters, the configured-id check rejects the real Firefox redirect host and the extension auth flow always returns a bad request.
| const configuredExtensionId = identityHost.getConfiguredExtensionId(); | |
| const configuredExtensionId = identityHost | |
| .getConfiguredExtensionId() | |
| ?.toLowerCase(); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/web-backend/src/Extension/Http.ts
Line: 51
Comment:
**Mixed-Case Firefox Id Rejection**
`URL.hostname` is normalized to lowercase before `extensionId` is sliced, but the new Firefox id comes straight from `CAP_FIREFOX_EXTENSION_ID`. If that env var is copied with uppercase characters, the configured-id check rejects the real Firefox redirect host and the extension auth flow always returns a bad request.
```suggestion
const configuredExtensionId = identityHost
.getConfiguredExtensionId()
?.toLowerCase();
```
How can I resolve this? If you propose a fix, please make it concise.| const identityHost = IDENTITY_REDIRECT_HOSTS.find(({ suffix }) => | ||
| url.hostname.endsWith(suffix), | ||
| ); | ||
| if (url.protocol !== "https:" || !identityHost) { |
There was a problem hiding this comment.
Might be worth rejecting non-default ports / credentials here to keep the redirect URI shape tight (and avoid surprises if browser behavior changes).
| if (url.protocol !== "https:" || !identityHost) { | |
| if ( | |
| url.protocol !== "https:" || | |
| url.port !== "" || | |
| url.username || | |
| url.password || | |
| !identityHost | |
| ) { | |
| return yield* new HttpApiError.BadRequest(); | |
| } |
| const extensionId = url.hostname.slice(0, -identityHost.suffix.length); | ||
| const configuredExtensionId = identityHost.getConfiguredExtensionId(); |
There was a problem hiding this comment.
Since the comment says the leading label identifies the extension installation, it could be good to explicitly reject multi-label hosts (e.g. a.b.chromiumapp.org).
| const extensionId = url.hostname.slice(0, -identityHost.suffix.length); | |
| const configuredExtensionId = identityHost.getConfiguredExtensionId(); | |
| const extensionId = url.hostname.slice(0, -identityHost.suffix.length); | |
| if (extensionId.includes(".")) { | |
| return yield* new HttpApiError.BadRequest(); | |
| } | |
| const configuredExtensionId = identityHost.getConfiguredExtensionId(); |
f6d875c to
8c52575
Compare
|
@ManthanNimodiya thanks for this! Two small things before it can go in: the Format (Biome) check fails on packages/web-backend/src/Extension/Http.ts:50 (the |
|
@richiemcilroy I worked on this months ago and didn't got any response so kept it draft. I can fully deliver the Firefox extension along with current chrome extension design or a better one (more optimised), will discuss with you using the drive screen videos for the design and also I consider this as a green flag to work on it. |
…id line Address review: remove the explanatory comment and apply biome formatting.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
@richiemcilroy merged main, dropped the comment above IDENTITY_REDIRECT_HOSTS, and ran the formatter on the configuredExtensionId line, so the Format (Biome) check should be green now. |
|
@greptileai review @richiemcilroy merged main in again, it's up to date. Marking this ready since the Biome and comment fixes were in last time. |
| }, | ||
| { | ||
| suffix: ".extensions.allizom.org", | ||
| getConfiguredExtensionId: () => serverEnv().CAP_FIREFOX_EXTENSION_ID, |
There was a problem hiding this comment.
Firefox sign-in fails in Docker
The supplied Compose files do not forward CAP_FIREFOX_EXTENSION_ID to cap-web. Setting it in the deployment’s .env leaves it unset inside the container, so valid Firefox redirects return a bad request outside localhost development.
Forward the new variable alongside CAP_CHROME_EXTENSION_ID in docker-compose.yml, docker-compose.coolify.yml, and docker-compose.template.yml.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/web-backend/src/Extension/Http.ts
Line: 29
Comment:
**Firefox sign-in fails in Docker**
The supplied Compose files do not forward `CAP_FIREFOX_EXTENSION_ID` to `cap-web`. Setting it in the deployment’s `.env` leaves it unset inside the container, so valid Firefox redirects return a bad request outside localhost development.
Forward the new variable alongside `CAP_CHROME_EXTENSION_ID` in `docker-compose.yml`, `docker-compose.coolify.yml`, and `docker-compose.template.yml`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Firefox's identity.launchWebAuthFlow redirects to https://.extensions.allizom.org/.
Generalizes validateExtensionRedirectUri to a host-suffix table and adds optional CAP_FIREFOX_EXTENSION_ID (packages/env).
Chrome pinning and the localhost-dev escape hatch unchanged. Independent of the other PRs.
(For production later: the hash for gecko id extension@cap.so is 324e9362f26688ae2eb9a75d1beae53ef6b8d0d2.)
Deployment: set CAP_FIREFOX_EXTENSION_ID to the subdomain from the Firefox build’s browser.identity.getRedirectURL(), i.e. the in https://.extensions.allizom.org/. It’s derived from the gecko extension id, not the id itself. Without it, only localhost development accepts Firefox redirects.
Forward the Firefox setting in the supplied Compose files before merging so Docker users can enable Firefox sign-in.
Findings
Fix with agent prompt
Summary
Adds Firefox identity redirect hosts and an optional
CAP_FIREFOX_EXTENSION_IDsetting.Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile