-
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
Fix 5869: Google OAuth should work by default #3784
Conversation
4a6a17a
to
e0c3923
Compare
@@ -205,6 +205,20 @@ ControlType GetCookieControlType(Profile* profile, const GURL& url) { | |||
HostContentSettingsMapFactory::GetForProfile(profile), url); | |||
} | |||
|
|||
void SetCookieWhitelist(HostContentSettingsMap* map, ControlType type, |
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.
it's confusing to me that we have a method called SetCookieWhitelist
that takes a ControlType. It seems to me that this is just an overloaded SetCookieControlType
with a string pattern instead of a GURL, 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'd say SetCookieControlTypeForPattern
? Overloads are often confusing and also not encouraged by CC.
CONTENT_SETTINGS_TYPE_PLUGINS, kCookies, | ||
GetDefaultBlockFromControlType(type)); | ||
|
||
// Allow cookies for social media sites when used in first party context |
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.
why does this method care whether it's social media or not?
map->SetContentSettingCustomScope( | ||
ContentSettingsPattern::FromString(pattern), | ||
ContentSettingsPattern::FromString("https://firstParty/*"), | ||
CONTENT_SETTINGS_TYPE_PLUGINS, kCookies, CONTENT_SETTING_ALLOW); |
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.
why is this always ALLOW
if we're passing a ControlType?
ControlType type = prefs->GetBoolean(kGoogleLoginControlType) | ||
? ControlType::ALLOW | ||
: ControlType::BLOCK; | ||
SetCookieWhitelist(map, type, kGoogleOAuthPattern); |
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's problematic to set this as a brave cookie plugin type because it will always end up with an override one direction or the other which could potentially conflict with user overrides. It seems better to convert this directly to cookie settings in BravePrefProvider so we only add an override when it's enabled
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.
it's especially problematic because of this https://github.com/brave/brave-core/pull/3784/files#diff-6c160ccdf43d9f23e468a95ec08b4d12R219 which adds an allow override no matter what the setting is
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.
as per comment we should not be adding any content settings when kGoogleLoginControlType
is disabled and the current code just changes what the override is. We should convert it to non-persistent chrome cookie settings instead when we convert everything else in BravePrefProvider
@@ -21,6 +23,21 @@ namespace brave_shields { | |||
|
|||
namespace { | |||
|
|||
void SetCookieWhitelistForSocialMedia(HostContentSettingsMap* map, |
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.
this method makes more sense as SetCookieWhitelist
because it will potentially add other pref based overrides, but ForSocialMedia
seems irrelevant to the method and google auth isn't social media anyway. This is just setting a whitelist based on prefs
please add tests for this including a test to ensure that no overrides are added when the pref is false |
|
||
void SetCookieWhitelist(HostContentSettingsMap* map, | ||
ControlType type, | ||
std::string pattern); |
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.
const std::string&
or base::StringPiece
0977c74
to
a7be6ec
Compare
} | ||
|
||
void NavigateToPageWithFrame(const std::string& host) { | ||
GURL main_url(https_server_.GetURL(host, "/iframe.html")); |
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.
pls correct spaces everywhere (or use clang-format
)
@@ -17,6 +17,7 @@ const char kFingerprinting[] = "fingerprinting"; | |||
const char kBraveShields[] = "braveShields"; | |||
const char kReferrers[] = "referrers"; | |||
const char kCookies[] = "cookies"; | |||
const char kGoogleLogin[] = "google-login"; |
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.
is it used anywhere?
@@ -56,6 +56,8 @@ class BravePrefProvider : public PrefProvider, | |||
const ContentSettingsPattern& secondary_pattern, | |||
ContentSettingsType content_type, | |||
const std::string& resource_identifier) override; | |||
void OnCookiePrefsChanged(const std::string& pref); | |||
void SetOAuthCookieException(ContentSettingsType type); |
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.
unused?
|
||
IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, | ||
IframeGoogleAccountsCookieBlocked) { | ||
BlockGoogleOAuthCookies(); |
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.
we need a test, showing that the new preference doesn't override user choice in per-site shields settings
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 actually requested this in the last review and should verify your comment below
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.
@@ -254,6 +261,14 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, | |||
} | |||
} | |||
|
|||
if (prefs_->GetBoolean(kGoogleLoginControlType)) { |
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.
not sure if this overrides user shields settings or not.
Anyway, this method becomes too fat, so i'd prefer to put it into a separate method (or at least add a comment).
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.
it shouldn't override shields settings as long as it comes last, but it should have a test to verify
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.
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.
although actually we want it to override site shield settings because it should work the same whether the default is block 3p cookies or whether the default is something else and site shield settings are block 3p cookies. In the case where site settings are block all you won't be able to login to anything anyway
|
||
void BravePrefProvider::OnCookiePrefsChanged( | ||
const std::string& pref) { | ||
OnCookieSettingsChanged(CONTENT_SETTINGS_TYPE_PLUGINS); |
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.
lint - 2 spaces
@@ -188,7 +212,7 @@ IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, DefaultCookiesBlocked) { | |||
IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, | |||
PrefToggleBlockAllToBlockThirdParty) { | |||
DefaultBlockAllCookies(); | |||
BlockThirdPartyCookies(); | |||
BlockAllThirdPartyCookies(); |
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.
Renamed so that it's consistent with other helper functions like DefaultBlockAllCookies
rules.clear(); | ||
|
||
if (prefs_->GetBoolean(kGoogleLoginControlType)) { |
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 desperately desire a comment here, describing the whole situation. So an occasional stranger could have a little chance to understand why and what happens here :)
server->GetURL("a.com", "/")); | ||
} | ||
|
||
void BlockThirdPartyCookies(const EmbeddedTestServer* server) { |
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 this method name is confusing because it's not obvious in the tests that this is a site override and not the default. I think it's better to pass in the URL instead of the server
@@ -67,21 +82,28 @@ class BraveNetworkDelegateBrowserTest : public InProcessBrowserTest { | |||
browser()->profile(), brave_shields::ControlType::ALLOW, GURL()); | |||
} | |||
|
|||
void AllowCookies() { | |||
void AllowCookies(const EmbeddedTestServer* server) { |
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.
same as below
} | ||
|
||
void BlockCookies() { | ||
void BlockCookies(const EmbeddedTestServer* server) { |
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.
same ^^
void DefaultBlockAllCookies() { | ||
brave_shields::SetCookieControlType( | ||
browser()->profile(), brave_shields::ControlType::BLOCK, GURL()); | ||
} | ||
|
||
void BlockThirdPartyCookies() { | ||
void BlockAllThirdPartyCookies() { |
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.
BlockAllThirdPartyCookies
doesn't mean anything different to me than BlockThirdPartyCookies
. DefaultBlockThirdPartyCookies
maybe?
@@ -298,3 +329,58 @@ IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, | |||
ExpectCookiesOnHost(embedded_test_server(), "a.com", ""); | |||
ExpectCookiesOnHost(embedded_test_server(), "b.com", ""); | |||
} | |||
|
|||
IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, | |||
IframeGoogleAccountsCookieAllowed) { |
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.
should these maybe be ThirdPartyGoogleAccountsCookiesAllowed
? Instead of Iframe
? I know it's basically equivalent, but I think ThirdParty
is a better description
29563ff
to
0728dde
Compare
🎉 !! |
Fix brave/brave-browser#5869
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
brave://settings/socialBlocking
and disable Google loginbrave://settings/clearBrowserData
and clear all dataReviewer Checklist:
After-merge Checklist:
changes has landed on.