Skip to content

Commit 83357b6

Browse files
authored
Remove fiam scope tokens (#11361)
Getting rid of "fiam" scoped tokens which are cached in keychain by old FIAM SDK.
1 parent f2194c8 commit 83357b6

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

FirebaseMessaging/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 10.12.0
2+
- [changed] Removing fiam scoped tokens set by old FIAM SDK(s) from keychain if exisits (b/284207019).
3+
14
# 10.6.0
25
- [fixed] Configure flow validates existence of an APNS token before fetching an FCM token (#10742). This also addresses the scenario 1 mentioned in the comment - https://github.com/firebase/firebase-ios-sdk/issues/10679#issuecomment-1402776795
36

FirebaseMessaging/Sources/FIRMessagingConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ FOUNDATION_EXPORT NSString *const kFIRMessaging_CMD_RST;
5959
FOUNDATION_EXPORT NSString *const kFIRMessagingAllScopeIdentifier;
6060
/// The scope used to save the IID "*" scope token.
6161
FOUNDATION_EXPORT NSString *const kFIRMessagingDefaultTokenScope;
62+
/// Denylisted "fiam" token scope.
63+
FOUNDATION_EXPORT NSString *const kFIRMessagingFIAMTokenScope;
6264

6365
/// Subdirectory in search path directory to store InstanceID preferences.
6466
FOUNDATION_EXPORT NSString *const kFIRMessagingInstanceIDSubDirectoryName;

FirebaseMessaging/Sources/FIRMessagingConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
// Miscellaneous
6868
NSString *const kFIRMessagingAllScopeIdentifier = @"iid-all";
6969
NSString *const kFIRMessagingDefaultTokenScope = @"*";
70+
NSString *const kFIRMessagingFIAMTokenScope = @"fiam";
7071
NSString *const kFIRMessagingInstanceIDSubDirectoryName = @"Google/FirebaseInstanceID";
7172

7273
// Registration Options

FirebaseMessaging/Sources/Token/FIRMessagingTokenInfo.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ - (BOOL)isFreshWithIID:(NSString *)IID {
8181
return NO;
8282
}
8383

84+
if ([self hasDenylistedScope]) {
85+
return NO;
86+
}
87+
8488
// Check if app has just been updated to a new version.
8589
NSString *currentAppVersion = FIRMessagingCurrentAppVersion();
8690
if (!_appVersion || ![_appVersion isEqualToString:currentAppVersion]) {
@@ -115,6 +119,16 @@ - (BOOL)isFreshWithIID:(NSString *)IID {
115119
return (timeSinceLastFetchToken < kDefaultFetchTokenInterval);
116120
}
117121

122+
- (BOOL)hasDenylistedScope {
123+
/// The token with fiam scope is set by old FIAM SDK(s) which will remain in keychain for ever. So
124+
/// we need to remove these tokens to deny its usage.
125+
if ([self.scope isEqualToString:kFIRMessagingFIAMTokenScope]) {
126+
return YES;
127+
}
128+
129+
return NO;
130+
}
131+
118132
- (BOOL)isDefaultToken {
119133
return [self.scope isEqualToString:kFIRMessagingDefaultTokenScope];
120134
}

0 commit comments

Comments
 (0)