Skip to content

Custom fdl domain #2121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions Example/Auth/Tests/FIRGetOOBConfirmationCodeRequestTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
*/
static NSString *const kCanHandleCodeInAppKey = @"canHandleCodeInApp";

/** @var kDynamicLinkDomainKey
@brief The key for the "dynamic link domain" value in the request.
*/
static NSString *const kDynamicLinkDomainKey = @"dynamicLinkDomain";

/** @var kDynamicLinkDomain
@brief Fake dynamic link domain for testing.
*/
static NSString *const kDynamicLinkDomain = @"test.page.link";

/** @class FIRGetOOBConfirmationCodeRequestTests
@brief Tests for @c FIRGetOOBConfirmationCodeRequest.
*/
Expand Down Expand Up @@ -194,6 +204,7 @@ - (void)testPasswordResetRequest {
[NSNumber numberWithBool:YES]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kCanHandleCodeInAppKey],
[NSNumber numberWithBool:YES]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kDynamicLinkDomainKey], kDynamicLinkDomain);
}

/** @fn testSignInWithEmailLinkRequest
Expand Down Expand Up @@ -230,6 +241,7 @@ - (void)testSignInWithEmailLinkRequest {
[NSNumber numberWithBool:YES]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kCanHandleCodeInAppKey],
[NSNumber numberWithBool:YES]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kDynamicLinkDomainKey], kDynamicLinkDomain);
}


Expand Down Expand Up @@ -268,6 +280,7 @@ - (void)testEmailVerificationRequest {
[NSNumber numberWithBool:YES]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kCanHandleCodeInAppKey],
[NSNumber numberWithBool:YES]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kDynamicLinkDomainKey], kDynamicLinkDomain);
}

#pragma mark - Helpers
Expand All @@ -284,6 +297,7 @@ - (FIRActionCodeSettings *)fakeActionCodeSettings {
minimumVersion:kAndroidMinimumVersion];
actionCodeSettings.handleCodeInApp = YES;
actionCodeSettings.URL = [NSURL URLWithString:kContinueURL];
actionCodeSettings.dynamicLinkDomain = kDynamicLinkDomain;
return actionCodeSettings;
}

Expand Down
7 changes: 7 additions & 0 deletions Firebase/Auth/Source/FIRAuthErrorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (NSError *)nullUserErrorWithMessage:(nullable NSString *)message;

/** @fn invalidDynamicLinkDomainErrorWithMessage:
@brief Constructs an @c NSError with the code and message provided.
@param message Error message from the backend, if any.
@return The nullable NSError instance associated with the given error message, if one is found.
*/
+ (NSError *)invalidDynamicLinkDomainErrorWithMessage:(nullable NSString *)message;

/** @fn keychainErrorWithFunction:status:
@brief Constructs an @c NSError with the @c FIRAuthErrorCodeKeychainError code.
@param keychainFunction The keychain function which was invoked and yielded an unexpected
Expand Down
15 changes: 15 additions & 0 deletions Firebase/Auth/Source/FIRAuthErrorUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@
static NSString *const kFIRAuthErrorMessageNullUser = @"A null user object was provided as the "
"argument for an operation which requires a non-null user object.";

/** @var kFIRAuthErrorMessageInvalidDynamicLinkDomain
@brief Message for @c kFIRAuthErrorMessageInvalidDynamicLinkDomain error code.
*/
static NSString *const kFIRAuthErrorMessageInvalidDynamicLinkDomain = @"The "
"Firebase Dynamic Link domain used is either not configured or is unauthorized "
"for the current project.";

/** @var kFIRAuthErrorMessageInternalError
@brief Message for @c FIRAuthErrorCodeInternalError error code.
*/
Expand Down Expand Up @@ -535,6 +542,8 @@
return kFIRAuthErrorMessageWebRequestFailed;
case FIRAuthErrorCodeNullUser:
return kFIRAuthErrorMessageNullUser;
case FIRAuthErrorCodeInvalidDynamicLinkDomain:
return kFIRAuthErrorMessageInvalidDynamicLinkDomain;
case FIRAuthErrorCodeWebInternalError:
return kFIRAuthErrorMessageWebInternalError;
case FIRAuthErrorCodeMalformedJWT:
Expand Down Expand Up @@ -658,6 +667,8 @@
return @"ERROR_WEB_NETWORK_REQUEST_FAILED";
case FIRAuthErrorCodeNullUser:
return @"ERROR_NULL_USER";
case FIRAuthErrorCodeInvalidDynamicLinkDomain:
return @"ERROR_INVALID_DYNAMIC_LINK_DOMAIN";
case FIRAuthErrorCodeWebInternalError:
return @"ERROR_WEB_INTERNAL_ERROR";
case FIRAuthErrorCodeMalformedJWT:
Expand Down Expand Up @@ -1019,6 +1030,10 @@ + (NSError *)nullUserErrorWithMessage:(nullable NSString *)message {
return [self errorWithCode:FIRAuthInternalErrorCodeNullUser message:message];
}

+ (NSError *)invalidDynamicLinkDomainErrorWithMessage:(nullable NSString *)message {
return [self errorWithCode:FIRAuthInternalErrorCodeInvalidDynamicLinkDomain message:message];
}

+ (NSError *)keychainErrorWithFunction:(NSString *)keychainFunction status:(OSStatus)status {
NSString *failureReason = [NSString stringWithFormat:@"%@ (%li)", keychainFunction, (long)status];
return [self errorWithCode:FIRAuthInternalErrorCodeKeychainError userInfo:@{
Expand Down
6 changes: 6 additions & 0 deletions Firebase/Auth/Source/FIRAuthInternalErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ typedef NS_ENUM(NSInteger, FIRAuthInternalErrorCode) {
FIRAuthInternalErrorCodeNullUser =
FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeNullUser,

/** Indicates that the Firebase Dynamic Link domain used is either not configured or is unauthorized
for the current project.
*/
FIRAuthInternalErrorCodeInvalidDynamicLinkDomain =
FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeInvalidDynamicLinkDomain,

FIRAuthInternalErrorCodeMalformedJWT =
FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeMalformedJWT,

Expand Down
5 changes: 5 additions & 0 deletions Firebase/Auth/Source/Public/FIRActionCodeSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
*/
@property(nonatomic, assign, readonly) BOOL androidInstallIfNotAvailable;

/** @property dynamicLinkDomain
@brief The Firebase Dynamic Link domain used for out of band code flow.
*/
@property (copy, nonatomic, nullable) NSString *dynamicLinkDomain;

/** @fn setIOSBundleID
@brief Sets the iOS bundle Id.
@param iOSBundleID The iOS bundle ID.
Expand Down
5 changes: 5 additions & 0 deletions Firebase/Auth/Source/Public/FIRAuthErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ typedef NS_ENUM(NSInteger, FIRAuthErrorCode) {
*/
FIRAuthErrorCodeNullUser = 17067,

/** Indicates that the Firebase Dynamic Link domain used is either not configured or is unauthorized
for the current project.
*/
FIRAuthErrorCodeInvalidDynamicLinkDomain = 17074,

/** Indicates an error occurred while attempting to access the keychain.
*/
FIRAuthErrorCodeKeychainError = 17995,
Expand Down
10 changes: 10 additions & 0 deletions Firebase/Auth/Source/RPCs/FIRAuthBackend.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
*/
static NSString *const kUnauthorizedDomainErrorMessage = @"UNAUTHORIZED_DOMAIN";

/** @var kInvalidDynamicLinkDomainErrorMessage
@brief This is the error message the server will respond with if the dynamic link domain provided
in the request is invalid.
*/
static NSString *const kInvalidDynamicLinkDomainErrorMessage = @"INVALID_DYNAMIC_LINK_DOMAIN";

/** @var kInvalidContinueURIErrorMessage
@brief This is the error message the server will respond with if the continue URL provided in
the request is invalid.
Expand Down Expand Up @@ -1044,6 +1050,10 @@ + (nullable NSError *)clientErrorWithServerErrorMessage:(NSString *)serverErrorM
return [FIRAuthErrorUtils invalidContinueURIErrorWithMessage:serverDetailErrorMessage];
}

if ([shortErrorMessage isEqualToString:kInvalidDynamicLinkDomainErrorMessage]) {
return [FIRAuthErrorUtils invalidDynamicLinkDomainErrorWithMessage:serverDetailErrorMessage];
}

if ([shortErrorMessage isEqualToString:kMissingContinueURIErrorMessage]) {
return [FIRAuthErrorUtils missingContinueURIErrorWithMessage:serverDetailErrorMessage];
}
Expand Down
6 changes: 6 additions & 0 deletions Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ typedef NS_ENUM(NSInteger, FIRGetOOBConfirmationCodeRequestType) {
*/
@property(assign, nonatomic) BOOL handleCodeInApp;

/** @property dynamicLinkDomain
@brief The Firebase Dynamic Link domain used for out of band code flow.
*/
@property (copy, nonatomic, nullable) NSString *dynamicLinkDomain;


/** @fn passwordResetRequestWithEmail:actionCodeSettings:requestConfiguration:
@brief Creates a password reset request.
@param email The user's email address.
Expand Down
10 changes: 10 additions & 0 deletions Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
*/
static NSString *const kCanHandleCodeInAppKey = @"canHandleCodeInApp";

/** @var kDynamicLinkDomainKey
@brief The key for the "dynamic link domain" value in the request.
*/
static NSString *const kDynamicLinkDomainKey = @"dynamicLinkDomain";

/** @var kPasswordResetRequestTypeValue
@brief The value for the "PASSWORD_RESET" request type.
*/
Expand Down Expand Up @@ -177,6 +182,7 @@ - (nullable instancetype)initWithRequestType:(FIRGetOOBConfirmationCodeRequestTy
_androidMinimumVersion = actionCodeSettings.androidMinimumVersion;
_androidInstallApp = actionCodeSettings.androidInstallIfNotAvailable;
_handleCodeInApp = actionCodeSettings.handleCodeInApp;
_dynamicLinkDomain = actionCodeSettings.dynamicLinkDomain;
}
return self;
}
Expand Down Expand Up @@ -228,6 +234,10 @@ - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)
body[kCanHandleCodeInAppKey] = @YES;
}

if (_dynamicLinkDomain) {
body[kDynamicLinkDomainKey] = _dynamicLinkDomain;
}

return body;
}

Expand Down