-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(appcheck): Add new internal, default provider #16190
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
Draft
ncooke3
wants to merge
3
commits into
main
Choose a base branch
from
nc/fac-sim
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
FirebaseAppCheck/Sources/DefaultProviderFactory/FIRDefaultProviderFactory.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckProviderFactory.h" | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /// The internal default provider factory that is set at +load time. It returns | ||
| /// the Debug provider for simulator builds; otherwise, the DeviceCheck | ||
| /// provider. | ||
| @interface FIRDefaultProviderFactory : NSObject <FIRAppCheckProviderFactory> | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
37 changes: 37 additions & 0 deletions
37
FirebaseAppCheck/Sources/DefaultProviderFactory/FIRDefaultProviderFactory.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #import "FirebaseAppCheck/Sources/DefaultProviderFactory/FIRDefaultProviderFactory.h" | ||
|
|
||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheck.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckDebugProviderFactory.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRDeviceCheckProviderFactory.h" | ||
|
|
||
| @implementation FIRDefaultProviderFactory | ||
|
|
||
| + (void)load { | ||
| [FIRAppCheck setAppCheckProviderFactory:[[self alloc] init]]; | ||
| } | ||
|
|
||
| - (nullable id<FIRAppCheckProvider>)createProviderWithApp:(nonnull FIRApp *)app { | ||
| // TODO(ncooke3): What about for local dev targeting macOS? | ||
| #if TARGET_OS_SIMULATOR | ||
| return [[[FIRAppCheckDebugProviderFactory alloc] init] createProviderWithApp:app]; | ||
| // TODO(ncooke3): Add elif case for future reCAPTCHA provider. | ||
| #else | ||
| return [[[FIRDeviceCheckProviderFactory alloc] init] createProviderWithApp:app]; | ||
| #endif | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
FirebaseAppCheck/Tests/Unit/DefaultProviderFactory/FIRDefaultProviderFactoryTests.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #import <XCTest/XCTest.h> | ||
|
|
||
| #import "FirebaseAppCheck/Sources/DefaultProviderFactory/FIRDefaultProviderFactory.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckAvailability.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckDebugProvider.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRDeviceCheckProvider.h" | ||
|
|
||
| #import "FirebaseCore/Extension/FirebaseCoreInternal.h" | ||
|
|
||
| FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY | ||
| @interface FIRDefaultProviderFactoryTests : XCTestCase | ||
| @end | ||
|
|
||
| @implementation FIRDefaultProviderFactoryTests | ||
|
|
||
| - (void)testCreateProviderWithApp { | ||
| FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app_id" GCMSenderID:@"sender_id"]; | ||
| options.APIKey = @"api_key"; | ||
| options.projectID = @"project_id"; | ||
| FIRApp *app = [[FIRApp alloc] initInstanceWithName:@"testInitWithValidApp" options:options]; | ||
| // The following disables automatic token refresh, which could interfere with tests. | ||
| app.dataCollectionDefaultEnabled = NO; | ||
|
|
||
| FIRDefaultProviderFactory *factory = [[FIRDefaultProviderFactory alloc] init]; | ||
|
|
||
| id<FIRAppCheckProvider> provider = [factory createProviderWithApp:app]; | ||
|
|
||
| XCTAssertNotNil(provider); | ||
|
|
||
| #if TARGET_OS_SIMULATOR | ||
| XCTAssert([provider isKindOfClass:[FIRAppCheckDebugProvider class]]); | ||
| #else | ||
| XCTAssert([provider isKindOfClass:[FIRDeviceCheckProvider class]]); | ||
| #endif | ||
| } | ||
|
|
||
| @end |
44 changes: 44 additions & 0 deletions
44
FirebaseAppCheck/Tests/Unit/DeviceCheckProvider/FIRDeviceCheckProviderFactoryTests.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #import <XCTest/XCTest.h> | ||
|
|
||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckAvailability.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRDeviceCheckProvider.h" | ||
| #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRDeviceCheckProviderFactory.h" | ||
|
|
||
| #import "FirebaseCore/Extension/FirebaseCoreInternal.h" | ||
|
|
||
| FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY | ||
| @interface FIRDeviceCheckProviderFactoryTests : XCTestCase | ||
| @end | ||
|
|
||
| @implementation FIRDeviceCheckProviderFactoryTests | ||
|
|
||
| - (void)testCreateProviderWithApp { | ||
| FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app_id" GCMSenderID:@"sender_id"]; | ||
| options.APIKey = @"api_key"; | ||
| options.projectID = @"project_id"; | ||
| FIRApp *app = [[FIRApp alloc] initInstanceWithName:@"testInitWithValidApp" options:options]; | ||
| // The following disables automatic token refresh, which could interfere with tests. | ||
| app.dataCollectionDefaultEnabled = NO; | ||
|
|
||
| FIRDeviceCheckProviderFactory *factory = [[FIRDeviceCheckProviderFactory alloc] init]; | ||
|
|
||
| FIRDeviceCheckProvider *createdProvider = [factory createProviderWithApp:app]; | ||
|
|
||
| XCTAssert([createdProvider isKindOfClass:[FIRDeviceCheckProvider class]]); | ||
| } | ||
|
|
||
| @end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any possible improvements to the Mac App user journey? Maybe asserting or returning nil with a log to use a custom provider?