Skip to content

Commit

Permalink
custom auth domain changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pragatimodi committed Sep 18, 2023
1 parent 6278cd6 commit bde2053
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions FirebaseAuth/Sources/AuthProvider/OAuth/FIROAuthProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ @implementation FIROAuthProvider {
BOOL _usingClientIDScheme;

/** var _customAuthDomain
@brief AuthDomain if set
@brief customAuthDomain if set
*/
NSString *_customAuthDomain;
}
Expand Down Expand Up @@ -259,8 +259,8 @@ - (nullable instancetype)initWithProviderID:(NSString *)providerID auth:(FIRAuth
stringByReplacingOccurrencesOfString:@":"
withString:@"-"]];
}
if (auth.AuthDomain.length) {
_customAuthDomain = auth.AuthDomain;
if (auth.customAuthDomain.length) {
_customAuthDomain = auth.customAuthDomain;
}
}
return self;
Expand Down
10 changes: 6 additions & 4 deletions FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,13 @@ NS_SWIFT_NAME(Auth)
*/
@property(nonatomic, strong, nullable) NSData *APNSToken API_UNAVAILABLE(macos, tvos, watchos);

/** @property AuthDomain
* @brief The authentication domain used to handle all sign-in redirects. End-users will see this
* domain when signing in. This domain must be whitelisted in the Firebase Console.
/**
* @property customAuthDomain
* @brief The custom authentication domain used to handle all sign-in redirects. End-users will see this domain when signing in.
* This domain must be allowlisted in the Firebase Console.
*/
@property(nonatomic, strong, nullable) NSString *AuthDomain;
@property(nonatomic, nullable) NSString *customAuthDomain;


/** @fn init
@brief Please access auth instances using `Auth.auth()` and `Auth.auth(app:)`.
Expand Down
5 changes: 4 additions & 1 deletion FirebaseAuth/Sources/Utilities/FIRAuthWebUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,17 @@ + (void)fetchAuthDomainWithRequestConfiguration:(FIRAuthRequestConfiguration *)r
// The sequence of supportedAuthDomains matters. ("firebaseapp.com", "web.app")
// The searching ends once the first valid suportedAuthDomain is found.
NSString *authDomain;
NSString *customAuthDomain = requestConfiguration.auth.AuthDomain;
NSString *customAuthDomain = requestConfiguration.auth.customAuthDomain;
if (customAuthDomain) {
for (NSString *domain in response.authorizedDomains) {
if (customAuthDomain == domain) {
authDomain = customAuthDomain;
break;
}
}
NSError *customDomainError = [FIRAuthErrorUtils unauthorizedDomainErrorWithMessage:@"Custom domain is not authorized."];
completion(nil, customDomainError);
return;
} else {
for (NSString *domain in response.authorizedDomains) {
for (NSString *suportedAuthDomain in [self supportedAuthDomains]) {
Expand Down

0 comments on commit bde2053

Please sign in to comment.