Skip to content
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

Added ability to set a proxy domain that firebase auth calls utilize #12356

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [added] Added host override support for IdentityToolKit and SecureToken api endpoints. (#11858)

# 10.21.0
- [fixed] Fixed multifactor resolver to use the correct Auth instance instead of
always the default. (#12265)
Expand Down
5 changes: 5 additions & 0 deletions FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (NSURL *)requestURL {
NSString *apiHostAndPathPrefix;

NSString *emulatorHostAndPort = _requestConfiguration.emulatorHostAndPort;
NSString *overrideIdentityToolKitHost = _requestConfiguration.auth.overrideIdentityToolKitHost;

if (_useIdentityPlatform) {
apiURLFormat = kIdentityPlatformAPIURLFormat;
Expand All @@ -90,6 +91,8 @@ - (NSURL *)requestURL {
kIdentityPlatformAPIHost];
} else if (_useStaging) {
apiHostAndPathPrefix = kIdentityPlatformStagingAPIHost;
} else if (overrideIdentityToolKitHost) {
apiHostAndPathPrefix = overrideIdentityToolKitHost;
} else {
apiHostAndPathPrefix = kIdentityPlatformAPIHost;
}
Expand All @@ -102,6 +105,8 @@ - (NSURL *)requestURL {
stringWithFormat:kEmulatorHostAndPrefixFormat, emulatorHostAndPort, kFirebaseAuthAPIHost];
} else if (_useStaging) {
apiHostAndPathPrefix = kFirebaseAuthStagingAPIHost;
} else if (overrideIdentityToolKitHost) {
apiHostAndPathPrefix = overrideIdentityToolKitHost;
} else {
apiHostAndPathPrefix = kFirebaseAuthAPIHost;
}
Expand Down
4 changes: 4 additions & 0 deletions FirebaseAuth/Sources/Backend/RPC/FIRSecureTokenRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ - (NSURL *)requestURL {
NSString *URLString;

NSString *emulatorHostAndPort = _requestConfiguration.emulatorHostAndPort;
NSString *overrideSecureTokenHost = _requestConfiguration.auth.overrideSecureTokenHost;
if (emulatorHostAndPort) {
URLString =
[NSString stringWithFormat:kFIREmulatorURLFormat, emulatorHostAndPort, gAPIHost, _APIKey];
} else if (overrideSecureTokenHost) {
URLString = [NSString
stringWithFormat:kFIRSecureTokenServiceGetTokenURLFormat, overrideSecureTokenHost, _APIKey];
} else {
URLString =
[NSString stringWithFormat:kFIRSecureTokenServiceGetTokenURLFormat, gAPIHost, _APIKey];
Expand Down
16 changes: 16 additions & 0 deletions FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,22 @@ NS_SWIFT_NAME(Auth)
*/
@property(nonatomic, copy, nullable) NSString *customAuthDomain;

/**
* @property overrideIdentityToolKitHost
* @brief A custom host used to handle proxying identityToolKit signins. This gives organizations
* the ability to create a proxy that is behind a firewall to prevent brute force attacks using the
* public key against the identitytoolkit api directly.
*/
@property(nonatomic, copy, nullable) NSString *overrideIdentityToolKitHost;

/**
* @property overrideSecureTokenHost
* @brief A custom host used to handle proxying securetoken signins. This gives organizations the
* ability to create a proxy that is behind a firewall to prevent brute force attacks using the
* public key against the secure token api directly.
*/
@property(nonatomic, copy, nullable) NSString *overrideSecureTokenHost;

/** @fn init
@brief Please access auth instances using `Auth.auth()` and `Auth.auth(app:)`.
*/
Expand Down