-
Notifications
You must be signed in to change notification settings - Fork 900
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
Add ephemeral storage support for network cookies #7387
Add ephemeral storage support for network cookies #7387
Conversation
Note that the first commit in this PR is: #7154 and this change will be rebased once that PR lands. |
6ada214
to
4bdbfb4
Compare
4bdbfb4
to
40ff9b3
Compare
4fa55ef
to
fe5a8ec
Compare
40ff9b3
to
2695cfa
Compare
|
||
#define BRAVE_ADDCOOKIEHEADERANDSTART \ | ||
if (ShouldUseEphemeralStorage(this)) { \ | ||
DCHECK(request()->isolation_info().top_frame_origin().has_value()); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to move this DCHECK here https://github.com/brave/brave-core/pull/7387/files#diff-2b849c37882ef112e7d503ffa24e13c9987f94b8f4cc5ee2870c4f87a357b8c4R24 so it doesn't have to be duplicated and also so you don't need the NOLINT for the weird parens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove the DCHECK, but:
- At line 24 we should have returned early if request()->isolation_info().top_frame_origin().has_value() so the assertion might be a bit redundant.
- I think that since the code in the first if-block spans multiple lines it still needs braces and the NOLINT continues to be unavoidable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
braces are only needed if the there is more than one statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I've removed the DCHECK and the brace. Now the NOLINT statement is unnecessary.
ui_test_utils::NavigateToURL(browser(), b_site_set_cookie_url); | ||
ui_test_utils::NavigateToURL(browser(), a_site_ephemeral_storage_url_); | ||
|
||
std::string a_cookie = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we covering all the cases here? For instance what about verifying that 1st-party iframe does not use ephemeral storage with and without being nested in 3p domain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to the following situation?
- Top frame:
- 3rd party iframe
- 1st party iframe
- 3rd party iframe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a new browsertest for this functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that was the only one that is missing, but please check with @pes10k and add any others in a follow-up
|
||
IN_PROC_BROWSER_TEST_F(EphemeralStorageBrowserTest, | ||
NavigationCookiesArePartitioned) { | ||
AllowAllCookies(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a ticket for connecting this to block3p shield setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm whether or not one of these tickets is what you are referring to?
- Ephemeral storage should work when third-party cookies are blocked brave-browser#12789
- Do not use ephemeral storage for third-party domains that block cookies with a domain override brave-browser#12790
I believe that the first bug covers the situation where cookies are blocked in brave shield.
if (!base::FeatureList::IsEnabled(net::features::kBraveEphemeralStorage)) | ||
return false; | ||
|
||
const net::IsolationInfo& isolation_info = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing headers for isolation info, and request https://google.github.io/styleguide/cppguide.html#Include_What_You_Use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
->SetEphemeralCanonicalCookieAsync( \ | ||
std::move(cookie), request_->url(), \ | ||
request()->isolation_info().top_frame_origin()->GetURL(), options, \ | ||
base::BindOnce(&URLRequestHttpJob::OnSetCookieResult, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing headers for BindOnce https://google.github.io/styleguide/cppguide.html#Include_What_You_Use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
2695cfa
to
f02a83a
Compare
@bridiver I've pushed a new version of the branch which I believe addresses all your review comments. Please take a look. |
Thanks very kindly for the reviews. The two failures look like an unrelated issue with the ios bot (a failure in |
This change adds ephemeral storage support for network cookies
which are cookies that set and sent via HTTP headers.
Resolves brave/brave-browser#12788
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed).Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on.
Test Plan:
This change relies on browsertests for functionality testing. Later changes enabling ephemeral storage will have a broader testing plan.