Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Firebase/Auth/Source/Auth/FIRAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#import "FIRAuthErrorUtils.h"
#import "FIRAuthExceptionUtils.h"
#import "FIRAuthGlobalWorkQueue.h"
#import "FIRAuthKeychain.h"
#import "FIRAuthKeychainServices.h"
#import "FIRAuthOperationType.h"
#import "FIRAuthSettings.h"
#import "FIRAuthStoredUserManager.h"
Expand Down Expand Up @@ -277,10 +277,10 @@ @implementation FIRAuth {
*/
NSMutableArray<FIRAuthStateDidChangeListenerHandle> *_listenerHandles;

/** @var _keychain
/** @var _keychainServices
@brief The keychain service.
*/
FIRAuthKeychain *_keychain;
FIRAuthKeychainServices *_keychainServices;

/** @var _lastNotifiedUserToken
@brief The user access (ID) token used last time for posting auth state changed notification.
Expand Down Expand Up @@ -393,7 +393,7 @@ - (nullable instancetype)initWithAPIKey:(NSString *)APIKey appName:(NSString *)a
NSString *keychainServiceName =
[FIRAuth keychainServiceNameForAppName:strongSelf->_firebaseAppName];
if (keychainServiceName) {
strongSelf->_keychain = [[FIRAuthKeychain alloc] initWithService:keychainServiceName];
strongSelf->_keychainServices = [[FIRAuthKeychainServices alloc] initWithService:keychainServiceName];
strongSelf.storedUserManager =
[[FIRAuthStoredUserManager alloc] initWithServiceName:keychainServiceName];
}
Expand Down Expand Up @@ -428,7 +428,7 @@ - (nullable instancetype)initWithAPIKey:(NSString *)APIKey appName:(NSString *)a
[[FIRAuthAPNSTokenManager alloc] initWithApplication:application];

strongSelf->_appCredentialManager =
[[FIRAuthAppCredentialManager alloc] initWithKeychain:strongSelf->_keychain];
[[FIRAuthAppCredentialManager alloc] initWithKeychain:strongSelf->_keychainServices];

strongSelf->_notificationManager = [[FIRAuthNotificationManager alloc]
initWithApplication:application
Expand Down Expand Up @@ -1800,7 +1800,7 @@ - (BOOL)saveUser:(nullable FIRUser *)user
if (!self.userAccessGroup) {
NSString *userKey = [NSString stringWithFormat:kUserKey, _firebaseAppName];
if (!user) {
success = [_keychain removeDataForKey:userKey error:outError];
success = [_keychainServices removeDataForKey:userKey error:outError];
} else {
// Encode the user object.
NSMutableData *archiveData = [NSMutableData data];
Expand All @@ -1809,7 +1809,7 @@ - (BOOL)saveUser:(nullable FIRUser *)user
[archiver finishEncoding];

// Save the user object's encoded value.
success = [_keychain setData:archiveData forKey:userKey error:outError];
success = [_keychainServices setData:archiveData forKey:userKey error:outError];
}
} else {
if (!user) {
Expand Down Expand Up @@ -1840,7 +1840,7 @@ - (BOOL)getUser:(FIRUser *_Nullable *)outUser
NSString *userKey = [NSString stringWithFormat:kUserKey, _firebaseAppName];

NSError *keychainError;
NSData *encodedUserData = [_keychain dataForKey:userKey error:&keychainError];
NSData *encodedUserData = [_keychainServices dataForKey:userKey error:&keychainError];
if (keychainError) {
if (error) {
*error = keychainError;
Expand Down Expand Up @@ -1906,7 +1906,7 @@ - (void)appWillBeDeleted:(nonnull FIRApp *)app {
NSString *keychainServiceName = [FIRAuth keychainServiceNameForAppName:app.name];
if (keychainServiceName) {
[[self class] deleteKeychainServiceNameForAppName:app.name];
FIRAuthKeychain *keychain = [[FIRAuthKeychain alloc] initWithService:keychainServiceName];
FIRAuthKeychainServices *keychain = [[FIRAuthKeychainServices alloc] initWithService:keychainServiceName];
NSString *userKey = [NSString stringWithFormat:kUserKey, app.name];
[keychain removeDataForKey:userKey error:NULL];
}
Expand Down Expand Up @@ -1999,7 +1999,7 @@ - (BOOL)useUserAccessGroup:(NSString *_Nullable)accessGroup

if(_userAccessGroup == nil && accessGroup != nil) {
NSString *userKey = [NSString stringWithFormat:kUserKey, _firebaseAppName];
[_keychain removeDataForKey:userKey error:outError];
[_keychainServices removeDataForKey:userKey error:outError];
}
_userAccessGroup = accessGroup;
self->_lastNotifiedUserToken = user.rawAccessToken;
Expand All @@ -2012,7 +2012,7 @@ - (nullable FIRUser *)getStoredUserForAccessGroup:(NSString *_Nullable)accessGro
FIRUser *user;
if (!accessGroup) {
NSString *userKey = [NSString stringWithFormat:kUserKey, _firebaseAppName];
NSData *encodedUserData = [_keychain dataForKey:userKey error:outError];
NSData *encodedUserData = [_keychainServices dataForKey:userKey error:outError];
if (!encodedUserData) {
return nil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
/** @class FIRAuthKeychain
@brief The utility class to manipulate data in iOS Keychain.
*/
@interface FIRAuthKeychain : NSObject <FIRAuthStorage>
@interface FIRAuthKeychainServices : NSObject <FIRAuthStorage>

/** @fn getItemWithQuery:error:
@brief Get the item from keychain by given query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

#import "FIRAuthKeychain.h"
#import "FIRAuthKeychainServices.h"

#import <Security/Security.h>

#import "FIRAuthErrorUtils.h"
#import "FIRAuthUserDefaultsStorage.h"
#import "FIRAuthUserDefaults.h"

/** @var kAccountPrefix
@brief The prefix string for keychain item account attribute before the key.
Expand All @@ -29,7 +29,7 @@

NS_ASSUME_NONNULL_BEGIN

@implementation FIRAuthKeychain {
@implementation FIRAuthKeychainServices {
/** @var _service
@brief The name of the keychain service.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

#import <Foundation/Foundation.h>

#import "FIRAuthKeychain.h"
#import "FIRAuthKeychainServices.h"

NS_ASSUME_NONNULL_BEGIN

/** @class FIRAuthUserDefaultsStorage
@brief The utility class to storage data in NSUserDefaults.
*/
@interface FIRAuthUserDefaultsStorage : NSObject <FIRAuthStorage>
@interface FIRAuthUserDefaults : NSObject <FIRAuthStorage>

/** @fn clear
@brief Clears all data from the storage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

#import "FIRAuthUserDefaultsStorage.h"
#import "FIRAuthUserDefaults.h"

NS_ASSUME_NONNULL_BEGIN

static NSString *const kPersistentDomainNamePrefix = @"com.google.Firebase.Auth.";

@implementation FIRAuthUserDefaultsStorage {
@implementation FIRAuthUserDefaults {
/** @var _persistentDomainName
@brief The name of the persistent domain in user defaults.
*/
Expand All @@ -32,7 +32,7 @@ @implementation FIRAuthUserDefaultsStorage {
NSUserDefaults *_storage;
}

- (id<FIRAuthStorage>)initWithService:(NSString *)service {
- (instancetype)initWithService:(NSString *)service {
self = [super init];
if (self) {
_persistentDomainName = [kPersistentDomainNamePrefix stringByAppendingString:service];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

#import <Foundation/Foundation.h>

@class FIRAuthAppCredential;
@class FIRAuthKeychain;
#import "FIRAuthAppCredential.h"
#import "FIRAuthKeychainServices.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -53,7 +53,7 @@ typedef void (^FIRAuthAppCredentialCallback)(FIRAuthAppCredential *credential);
@param keychain The iOS Keychain storage to back up the app credential with.
@return The initialized instance.
*/
- (instancetype)initWithKeychain:(FIRAuthKeychain *)keychain NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithKeychain:(FIRAuthKeychainServices *)keychain NS_DESIGNATED_INITIALIZER;

/** @fn didStartVerificationWithReceipt:timeout:callback:
@brief Notifies that the app verification process has started.
Expand Down
14 changes: 7 additions & 7 deletions Firebase/Auth/Source/SystemService/FIRAuthAppCredentialManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import "FIRAuthAppCredential.h"
#import "FIRAuthGlobalWorkQueue.h"
#import "FIRAuthKeychain.h"
#import "FIRAuthKeychainServices.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -43,10 +43,10 @@
static const NSUInteger kMaximumNumberOfPendingReceipts = 32;

@implementation FIRAuthAppCredentialManager {
/** @var _keychain
/** @var _keychainServices
@brief The keychain for app credentials to load from and to save to.
*/
FIRAuthKeychain *_keychain;
FIRAuthKeychainServices *_keychainServices;

/** @var _pendingReceipts
@brief A list of pending receipts sorted in the order they were recorded.
Expand All @@ -59,13 +59,13 @@ @implementation FIRAuthAppCredentialManager {
NSMutableDictionary<NSString *, FIRAuthAppCredentialCallback> *_callbacksByReceipt;
}

- (instancetype)initWithKeychain:(FIRAuthKeychain *)keychain {
- (instancetype)initWithKeychain:(FIRAuthKeychainServices *)keychain {
self = [super init];
if (self) {
_keychain = keychain;
_keychainServices = keychain;
// Load the credentials from keychain if possible.
NSError *error;
NSData *encodedData = [_keychain dataForKey:kKeychainDataKey error:&error];
NSData *encodedData = [_keychainServices dataForKey:kKeychainDataKey error:&error];
if (!error && encodedData) {
NSKeyedUnarchiver *unarchiver =
[[NSKeyedUnarchiver alloc] initForReadingWithData:encodedData];
Expand Down Expand Up @@ -139,7 +139,7 @@ - (void)saveData {
[archiver encodeObject:_credential forKey:kFullCredentialKey];
[archiver encodeObject:_pendingReceipts forKey:kPendingReceiptsKey];
[archiver finishEncoding];
[_keychain setData:archiveData forKey:kKeychainDataKey error:NULL];
[_keychainServices setData:archiveData forKey:kKeychainDataKey error:NULL];
}

/** @fn callBackWithReceipt:
Expand Down
8 changes: 4 additions & 4 deletions Firebase/Auth/Source/SystemService/FIRAuthStoredUserManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#import <Foundation/Foundation.h>

#import "FIRUser.h"
#import "FIRAuthKeychain.h"
#import "FIRAuthUserDefaultsStorage.h"
#import "FIRAuthKeychainServices.h"
#import "FIRAuthUserDefaults.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -27,12 +27,12 @@ NS_ASSUME_NONNULL_BEGIN
/** @property keychain
@brief The mediator object to access to the system Keychain services.
*/
@property (readonly, nonatomic, strong) FIRAuthKeychain *keychain;
@property (readonly, nonatomic, strong) FIRAuthKeychainServices *keychainServices;

/** @property userDefaults
@brief The mediator object to access to the system User Defaults services.
*/
@property (readonly, nonatomic, strong) FIRAuthUserDefaultsStorage *userDefaults;
@property (readonly, nonatomic, strong) FIRAuthUserDefaults *userDefaults;

/** @fn init
@brief The default initializer is disabled.
Expand Down
10 changes: 5 additions & 5 deletions Firebase/Auth/Source/SystemService/FIRAuthStoredUserManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ @implementation FIRAuthStoredUserManager
- (instancetype)initWithServiceName:(NSString *)serviceName {
self = [super init];
if (self) {
_keychain = [[FIRAuthKeychain alloc] initWithService:serviceName];
_userDefaults = [[FIRAuthUserDefaultsStorage alloc] initWithService:serviceName];
_keychainServices = [[FIRAuthKeychainServices alloc] initWithService:serviceName];
_userDefaults = [[FIRAuthUserDefaults alloc] initWithService:serviceName];
}
return self;
}
Expand Down Expand Up @@ -81,7 +81,7 @@ - (FIRUser *)getStoredUserForAccessGroup:(NSString *)accessGroup
query[(__bridge id)kSecAttrService] = projectIdentifier;
query[(__bridge id)kSecAttrAccount] = kSharedKeychainAccountValue;

NSData *data = [self.keychain getItemWithQuery:query error:outError];
NSData *data = [self.keychainServices getItemWithQuery:query error:outError];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
FIRUser *user = [unarchiver decodeObjectOfClass:[FIRUser class] forKey:kStoredUserCoderKey];

Expand All @@ -105,7 +105,7 @@ - (BOOL)setStoredUser:(FIRUser *)user
[archiver encodeObject:user forKey:kStoredUserCoderKey];
[archiver finishEncoding];

return [self.keychain setItem:data withQuery:query error:outError];
return [self.keychainServices setItem:data withQuery:query error:outError];
}

- (BOOL)removeStoredUserForAccessGroup:(NSString *)accessGroup
Expand All @@ -119,7 +119,7 @@ - (BOOL)removeStoredUserForAccessGroup:(NSString *)accessGroup
query[(__bridge id)kSecAttrService] = projectIdentifier;
query[(__bridge id)kSecAttrAccount] = kSharedKeychainAccountValue;

return [self.keychain removeItemWithQuery:query error:outError];
return [self.keychainServices removeItemWithQuery:query error:outError];
}

@end
1 change: 0 additions & 1 deletion Firebase/Auth/Source/SystemService/FIRSecureTokenService.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import "FIRSecureTokenService.h"

#import "FIRAuth.h"
#import "FIRAuthKeychain.h"
#import "FIRAuthSerialTaskQueue.h"
#import "FIRAuthBackend.h"
#import "FIRAuthRequestConfiguration.h"
Expand Down