-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manifest v3 problems: ability to update the set-cookie header in response headers and also set dynamic header values #626
Comments
In Chrome it is already possible to modify the {
"id": 1,
"priority": 1,
"action": {
"type": "modifyHeaders",
"responseHeaders": [
{ "header": "set-cookie", "operation": "set", "value": "example=test" }
]
}
} I've put a full example here - note that due to this bug those changes aren't currently visible in the request tab of DevTools. However, visiting https://example.com and then checking the Cookies section in DevTools should show the cookie. Setting dynamic values is a request we've heard in the past, but as you point out isn't currently possible. Is the core feature of your extension providing the different sessions per tab or are you using that to solve another problem? |
@oliverdunk Thanks for the clarification on "set-cookie" header. However, the second issue is critical for my extension to be migrated to V3. And, as you guessed correctly, the main intention of the extension is to provide multi-session support in the same window. For this, I am adding tabId as a prefix for the value of the "set-cookie" response header and request header, I am removing the prefix from the "Cookie" header. Here is the v2 extension: Extension link |
@oliverdunk |
Hi @vish30, we don't have any changes on the roadmap which would make adding the tab ID possible from a static rule. However, you can add session rules with a It would look something like this: chrome.declarativeNetRequest.updateSessionRules({
addRules: [{
"id": 1,
"action": {
"type": chrome.declarativeNetRequest.RuleActionType.MODIFY_HEADERS,
"responseHeaders": [
{
"header": "Set-Cookie",
"operation": chrome.declarativeNetRequest.HeaderOperation.SET,
"regexFilter": ".*",
"regexSubstitution": `${tabId}_\\1`
}
]
},
"condition": { tabIds: [tabId] },
}]
}); You would be able to call this each time a tab is created. This is next up on our roadmap so will hopefully be available soon. |
Hi @oliverdunk, thanks for the update. But, I doubt will this solution also work for removing the same prefix from the cookie header before sending a request from client to server? Here is a sample implementation in v2:
|
Could you share your |
I have been facing quite a similar problem in appending to the CSP header. I have been trying to append the rules statically , to CSP header media-src directive to accept videos from 2 other hosts i.e.,
For MV3 , my
Maybe appending two hosts at the same time might not work , but it doesn't seem to work even if I try to append the other host in a different rule object , with lower prioritization. Also the way I am setting things neither makes videos of my extension work nor the videos of youtube when in youtube. Things dont change even when done dynamically. I am aware of the workarounds but I still want to believe that things can be achieved this way,any help would suffice. |
In Chromium, there is an allowlist for the headers that we allow you to append to: https://source.chromium.org/chromium/chromium/src/+/main:extensions/browser/api/declarative_net_request/constants.h;l=290;drc=4c831d47d206e2998aa54c8200ff5b55d3f39ec3. This is a subset of the headers that support multiple values. It might make sense to add Content-Security-Policy there, although regex substitution definitely feels useful for less-trivial cases where you need to overwrite an existing part of the CSP (e.g overwrite or update an existing media-src). |
I get that appending multiple values is not possible, but I am unable to
append any value to the CSP header ..am I doing something wrong?
…On Tue, 2 Jul 2024, 16:47 Oliver Dunk, ***@***.***> wrote:
"operation": "append",
"value": "media-src https://commons.wikimedia.org https://upload.wikimedia.org;"
In Chromium, there is an allowlist for the headers that we allow you to
append to:
https://source.chromium.org/chromium/chromium/src/+/main:extensions/browser/api/declarative_net_request/constants.h;l=290;drc=4c831d47d206e2998aa54c8200ff5b55d3f39ec3.
This is a subset of the headers that support multiple values.
It might make sense to add Content-Security-Policy there, although regex
substitution definitely feels useful for less-trivial cases where you need
to overwrite an existing part of the CSP (e.g overwrite or update an
existing media-src).
—
Reply to this email directly, view it on GitHub
<#626 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5LB5EWTF3D2D6RJ7MKP7UDZKKD35AVCNFSM6AAAAABIYPJLEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSHAYTGMJRGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Using the |
Ok, they should have clarified that in docs. What if I use regex values
along with the hosts and use the set operation ?
…On Tue, 2 Jul 2024, 17:44 Oliver Dunk, ***@***.***> wrote:
Using the append operation in general is not possible, even if you just
want to append a single value.
—
Reply to this email directly, view it on GitHub
<#626 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5LB5EXKKCBJFRSTSBCOYCLZKKKTBAVCNFSM6AAAAABIYPJLEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBTGAYDSMBXHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I'll see if we can clarify that. Regular expressions aren't supported for header values yet (the snippet above is something we are looking to implement shortly) but they should work for this when available. |
Ok thanks , guess I'll looking into workarounds
…On Tue, 2 Jul 2024, 17:58 Oliver Dunk, ***@***.***> wrote:
I'll see if we can clarify that. Regular expressions aren't supported for
header values yet (the snippet above is something we are looking to
implement shortly) but they should work for this when available.
—
Reply to this email directly, view it on GitHub
<#626 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5LB5ESHGTP7DBN5OZWPRSDZKKMFDAVCNFSM6AAAAABIYPJLEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBTGAZTINZQGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
There are two issues in manifest v3:
We have an extension wherein the users can have different login sessions in each tab.
Here is my manifest v2 code:
I am not able to replicate this in manifest v3 as the webRequestBlocking permission is not available and the rules (dynamic/static) doesn't support adding dynamic/runtime value for any header. Also, updating the "set-cookie" header is also not allowed.
The text was updated successfully, but these errors were encountered: