Skip to content

Commit b378a74

Browse files
cynthiajianga-maurice
authored andcommitted
[Auth][macOS] remove the check for NSUserDefaults for keychain ever exist.
The issue we are running into is: with this check, if replace SDK in Unity, system would think it's a different app and there is no way to remove / replace existing key entry for the app. PiperOrigin-RevId: 265091403
1 parent 2bcd61e commit b378a74

File tree

2 files changed

+0
-34
lines changed

2 files changed

+0
-34
lines changed

app/src/secure/user_secure_darwin_internal.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ class UserSecureDarwinInternal : public UserSecureInternal {
4949
void DeleteAllData() override;
5050

5151
private:
52-
// Does the user have secure data set for this app? Don't access the keychain
53-
// unless this is true.
54-
bool UserHasSecureData();
55-
// Set whether the user has secure data set for this app.
56-
void SetUserHasSecureData(bool b);
57-
5852
// Delete either a single key, or (if app_name is null) all keys.
5953
// func_name is used for error messages.
6054
void DeleteData(const char* app_name, const char* func_name);

app/src/secure/user_secure_darwin_internal.mm

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,7 @@
8080
return service_ + "/" + app;
8181
}
8282

83-
bool UserSecureDarwinInternal::UserHasSecureData() {
84-
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
85-
if (!defaults) {
86-
// For some reason we can't get NSUserDefaults, so just err on the safe side and return true so
87-
// we check the keychain directly.
88-
return true;
89-
}
90-
return [defaults boolForKey:@(user_defaults_key_.c_str())] ? true : false;
91-
}
92-
93-
void UserSecureDarwinInternal::SetUserHasSecureData(bool b) {
94-
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
95-
[defaults setBool:(b ? YES : NO) forKey:@(user_defaults_key_.c_str())];
96-
[defaults synchronize];
97-
}
98-
9983
std::string UserSecureDarwinInternal::LoadUserData(const std::string& app_name) {
100-
if (!UserHasSecureData()) {
101-
LogDebug("LoadUserData: User has no data stored.");
102-
return "";
103-
}
10484
NSMutableDictionary* query = GetQueryForApp(service_.c_str(), app_name.c_str());
10585
std::string keystore_location = GetKeystoreLocation(app_name);
10686
// We want to return the data and attributes.
@@ -164,16 +144,9 @@
164144
error_string.UTF8String);
165145
return;
166146
}
167-
168-
SetUserHasSecureData(true);
169147
}
170148

171149
void UserSecureDarwinInternal::DeleteData(const char* app_name, const char* func_name) {
172-
if (!UserHasSecureData()) {
173-
LogDebug("%s: User has no data stored.", func_name);
174-
return;
175-
}
176-
177150
NSMutableDictionary* query = GetQueryForApp(service_.c_str(), app_name);
178151
std::string keystore_location = app_name ? GetKeystoreLocation(app_name) : service_;
179152

@@ -201,7 +174,6 @@
201174

202175
void UserSecureDarwinInternal::DeleteAllData() {
203176
DeleteData(nullptr, "DeleteAllData");
204-
SetUserHasSecureData(false);
205177
}
206178

207179
} // namespace secure

0 commit comments

Comments
 (0)