Skip to content

Commit 0216c1a

Browse files
author
chuanr
authored
Multi-app fix (#10805)
1 parent 6d1e7f5 commit 0216c1a

14 files changed

+156
-15
lines changed

FirebaseAuth.podspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ supports email and password accounts, as well as several 3rd party authenticatio
8181
'FirebaseAuth/Tests/Unit/FIRVerifyClient*',
8282
'FirebaseAuth/Tests/Unit/FIRVerifyPhoneNumber*',
8383
'FirebaseAuth/Tests/Unit/FIROAuthProviderTests.m',
84+
'FirebaseAuth/Tests/Unit/FIRMultiFactorResolverTests.m',
8485
]
8586
unit_tests.tvos.exclude_files = [
8687
'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenManagerTests.m',
@@ -93,6 +94,7 @@ supports email and password accounts, as well as several 3rd party authenticatio
9394
'FirebaseAuth/Tests/Unit/FIRVerifyClient*',
9495
'FirebaseAuth/Tests/Unit/FIRVerifyPhoneNumber*',
9596
'FirebaseAuth/Tests/Unit/FIROAuthProviderTests.m',
97+
'FirebaseAuth/Tests/Unit/FIRMultiFactorResolverTests.m',
9698
]
9799
# app_host is needed for tests with keychain
98100
unit_tests.requires_app_host = true

FirebaseAuth/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 10.6.0
2+
- [fixed] Fixed a bug where user is created in a specific tenant although tenantID was not specified. (#10748)
3+
- [fixed] Fixed a bug where the resolver exposed in MFA is not associated to the correct app. (#10690)
4+
15
# 10.5.0
26
- [fixed] Use team player ID, game player ID and fetchItems for signature verification. (#10441)
37
- [fixed] Prevent keychain pop-up when accessing Auth keychain in a Mac

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ - (nullable instancetype)initWithAPIKey:(NSString *)APIKey
487487
_listenerHandles = [NSMutableArray array];
488488
_requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:APIKey
489489
appID:appID
490+
auth:self
490491
heartbeatLogger:heartbeatLogger];
491492
_firebaseAppName = [appName copy];
492493
#if TARGET_OS_IOS

FirebaseAuth/Sources/Backend/FIRAuthBackend.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,9 @@ - (void)verifyAssertion:(FIRVerifyAssertionRequest *)request
776776
}
777777
NSError *multiFactorRequiredError = [FIRAuthErrorUtils
778778
secondFactorRequiredErrorWithPendingCredential:response.MFAPendingCredential
779-
hints:multiFactorInfo];
779+
hints:multiFactorInfo
780+
auth:request.requestConfiguration
781+
.auth];
780782
callback(nil, multiFactorRequiredError);
781783
#endif
782784
} else {
@@ -820,7 +822,9 @@ - (void)verifyPassword:(FIRVerifyPasswordRequest *)request
820822
}
821823
NSError *multiFactorRequiredError = [FIRAuthErrorUtils
822824
secondFactorRequiredErrorWithPendingCredential:response.MFAPendingCredential
823-
hints:multiFactorInfo];
825+
hints:multiFactorInfo
826+
auth:request.requestConfiguration
827+
.auth];
824828
callback(nil, multiFactorRequiredError);
825829
#endif
826830
} else {
@@ -850,7 +854,9 @@ - (void)emailLinkSignin:(FIREmailLinkSignInRequest *)request
850854
}
851855
NSError *multiFactorRequiredError = [FIRAuthErrorUtils
852856
secondFactorRequiredErrorWithPendingCredential:response.MFAPendingCredential
853-
hints:multiFactorInfo];
857+
hints:multiFactorInfo
858+
auth:request.requestConfiguration
859+
.auth];
854860
callback(nil, multiFactorRequiredError);
855861
#endif
856862
} else {

FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import <Foundation/Foundation.h>
1818

1919
#import "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
20+
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h"
2021

2122
@protocol FIRHeartbeatLoggerProtocol;
2223

@@ -37,6 +38,11 @@ NS_ASSUME_NONNULL_BEGIN
3738
*/
3839
@property(nonatomic, copy, readonly) NSString *appID;
3940

41+
/** @property auth
42+
@brief The FIRAuth instance used in the request.
43+
*/
44+
@property(nonatomic, weak, readonly, nullable) FIRAuth *auth;
45+
4046
/** @property heartbeatLogger
4147
@brief The heartbeat logger used to add heartbeats to the corresponding request's header.
4248
*/
@@ -66,14 +72,36 @@ NS_ASSUME_NONNULL_BEGIN
6672
*/
6773
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey appID:(NSString *)appID;
6874

75+
/** @fn initWithAPIKey:appID:
76+
@brief Convenience initializer.
77+
@param APIKey The API key to be used in the request.
78+
@param appID The Firebase app ID to be passed in the request header.
79+
@param auth The FIRAuth instance used in the request.
80+
*/
81+
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
82+
appID:(NSString *)appID
83+
auth:(nullable FIRAuth *)auth;
84+
6985
/** @fn initWithAPIKey:appID:heartbeatLogger:
7086
@brief Designated initializer.
7187
@param APIKey The API key to be used in the request.
72-
@param appID The Firebase app ID to be passed in the request header.
88+
@param appID The Firebase app ID to be passed in the request header.
89+
@param heartbeatLogger The heartbeat logger used to add heartbeats to the request header.
90+
*/
91+
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
92+
appID:(NSString *)appID
93+
heartbeatLogger:(nullable id<FIRHeartbeatLoggerProtocol>)heartbeatLogger;
94+
95+
/** @fn initWithAPIKey:appID:heartbeatLogger:
96+
@brief Designated initializer.
97+
@param APIKey The API key to be used in the request.
98+
@param appID The Firebase app ID to be passed in the request header.
99+
@param auth The FIRAuth instance used in the request.
73100
@param heartbeatLogger The heartbeat logger used to add heartbeats to the request header.
74101
*/
75102
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
76103
appID:(NSString *)appID
104+
auth:(nullable FIRAuth *)auth
77105
heartbeatLogger:(nullable id<FIRHeartbeatLoggerProtocol>)heartbeatLogger
78106
NS_DESIGNATED_INITIALIZER;
79107

FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,30 @@
2323
@implementation FIRAuthRequestConfiguration
2424

2525
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey appID:(NSString *)appID {
26-
return [self initWithAPIKey:APIKey appID:appID heartbeatLogger:nil];
26+
return [self initWithAPIKey:APIKey appID:appID auth:nil heartbeatLogger:nil];
2727
}
2828

2929
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
3030
appID:(NSString *)appID
31+
auth:(nullable FIRAuth *)auth {
32+
return [self initWithAPIKey:APIKey appID:appID auth:auth heartbeatLogger:nil];
33+
}
34+
35+
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
36+
appID:(NSString *)appID
37+
heartbeatLogger:(nullable id<FIRHeartbeatLoggerProtocol>)heartbeatLogger {
38+
return [self initWithAPIKey:APIKey appID:appID auth:nil heartbeatLogger:heartbeatLogger];
39+
}
40+
41+
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
42+
appID:(NSString *)appID
43+
auth:(nullable FIRAuth *)auth
3144
heartbeatLogger:(nullable id<FIRHeartbeatLoggerProtocol>)heartbeatLogger {
3245
self = [super init];
3346
if (self) {
3447
_APIKey = [APIKey copy];
3548
_appID = [appID copy];
49+
_auth = auth;
3650
_heartbeatLogger = heartbeatLogger;
3751
}
3852
return self;

FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint
5858
// Automatically set the tenant ID. If the request is initialized before FIRAuth is configured,
5959
// set tenant ID to nil.
6060
@try {
61-
_tenantID = [FIRAuth auth].tenantID;
61+
_tenantID = [self requestConfiguration].auth.tenantID;
6262
} @catch (NSException *e) {
6363
_tenantID = nil;
6464
}

FirebaseAuth/Sources/MultiFactor/FIRMultiFactorResolver+Internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
2525
@property(nonatomic) NSString *MFAPendingCredential;
2626

2727
- (instancetype)initWithMFAPendingCredential:(NSString *_Nullable)MFAPendingCredential
28-
hints:(NSArray<FIRMultiFactorInfo *> *)hints;
28+
hints:(NSArray<FIRMultiFactorInfo *> *)hints
29+
auth:(FIRAuth *)auth;
2930

3031
@end
3132

FirebaseAuth/Sources/MultiFactor/FIRMultiFactorResolver.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@
3939
@implementation FIRMultiFactorResolver
4040

4141
- (instancetype)initWithMFAPendingCredential:(NSString *_Nullable)MFAPendingCredential
42-
hints:(NSArray<FIRMultiFactorInfo *> *)hints {
42+
hints:(NSArray<FIRMultiFactorInfo *> *)hints
43+
auth:(FIRAuth *)auth {
4344
self = [super init];
4445
if (self) {
4546
_MFAPendingCredential = MFAPendingCredential;
4647
_hints = hints;
47-
_auth = [FIRAuth auth];
48+
_auth = auth;
4849
_session = [[FIRMultiFactorSession alloc] init];
4950
_session.MFAPendingCredential = MFAPendingCredential;
5051
}

FirebaseAuth/Sources/User/FIRUser.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
377377
// The `heartbeatLogger` will be set later via a property update.
378378
_requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:APIKey
379379
appID:appID
380+
auth:_auth
380381
heartbeatLogger:nil];
381382
#if TARGET_OS_IOS
382383
_multiFactor = multiFactor ?: [[FIRMultiFactor alloc] init];

0 commit comments

Comments
 (0)