Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 281
Update GIDSignIn to handle placeholder app check tokens#335
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
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
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -183,6 +183,8 @@ @implementation GIDSignIn { | ||
| #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| // The class used to manage presenting the loading screen for fetching app check tokens. | ||
| GIDTimedLoader *_timedLoader; | ||
| // Flag indicating developer's intent to use App Check. | ||
| BOOL _configureAppCheckCalled; | ||
| #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| } | ||
| @@ -481,6 +483,7 @@ + (GIDSignIn *)sharedInstance { | ||
| #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| - (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable))completion { | ||
| @synchronized(self) { | ||
| _configureAppCheckCalled = YES; | ||
| [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { | ||
| if (completion) { | ||
| completion(error); | ||
| @@ -538,6 +541,7 @@ - (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore | ||
| self = [self initWithKeychainStore:keychainStore]; | ||
| if (self) { | ||
| _appCheck = appCheck; | ||
| _configureAppCheckCalled = NO; | ||
| } | ||
| return self; | ||
| } | ||
| @@ -632,15 +636,18 @@ - (void)authenticateInteractivelyWithOptions:(GIDSignInInternalOptions *)options | ||
| - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options completion: | ||
| (void (^)(OIDAuthorizationRequest *_Nullable request, NSError *_Nullable error))completion { | ||
| BOOL shouldCallCompletion = YES; | ||
| BOOL shouldCreateAuthRequest = YES; | ||
| NSMutableDictionary<NSString *, NSString *> *additionalParameters = | ||
| [self additionalParametersFromOptions:options]; | ||
| #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| if (@available(iOS 14.0, *)) { | ||
| // Only use `_appCheck` (created via singleton `+[GIDSignIn sharedInstance]` call) if | ||
| // `-[GIDAppCheck prepareForAppCheckWithCompletion:]` has been called | ||
| if ([_appCheck isPrepared]) { | ||
| shouldCallCompletion = NO; | ||
| // `GIDAppCheck` has been successfully prepared OR if the developer has attempted to configure. | ||
| // If former is false and the latter true, then preparation step failed for some reason; we | ||
| // still want to try to pass along the app check token (it just may take longer since the | ||
| // pre-warm step failed). | ||
| if ([_appCheck isPrepared] || _configureAppCheckCalled) { | ||
| shouldCreateAuthRequest = NO; | ||
| UIViewController *presentingVC = options.presentingViewController; | ||
| if (!_timedLoader) { | ||
| _timedLoader = [[GIDTimedLoader alloc] initWithPresentingViewController:presentingVC]; | ||
| @@ -652,9 +659,14 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp | ||
| if (token) { | ||
| additionalParameters[kClientAssertionTypeParameter] = kClientAssertionTypeParameterValue; | ||
| additionalParameters[kClientAssertionParameter] = token.token; | ||
| request = [self authorizationRequestWithOptions:options | ||
| additionalParameters:additionalParameters]; | ||
| } | ||
| #if DEBUG | ||
| if (error) { | ||
| NSLog(@"[Google Sign-In iOS]: Error retrieving App Check limited use token: %@", error); | ||
| } | ||
| #endif | ||
mdmathias marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| request = [self authorizationRequestWithOptions:options | ||
| additionalParameters:additionalParameters]; | ||
| if (self->_timedLoader.animationStatus == GIDTimedLoaderAnimationStatusAnimating) { | ||
| [self->_timedLoader stopTimingWithCompletion:^{ | ||
| completion(request, error); | ||
| @@ -666,7 +678,7 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp | ||
| } | ||
| } | ||
| #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| if (shouldCallCompletion) { | ||
| if (shouldCreateAuthRequest) { | ||
| OIDAuthorizationRequest *request = [self authorizationRequestWithOptions:options | ||
| additionalParameters:additionalParameters]; | ||
| completion(request, nil); | ||
7 changes: 0 additions & 7 deletions
7 ...AttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme
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
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 |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| source 'https://github.com/CocoaPods/Specs.git' | ||
| source 'https://github.com/firebase/SpecsDev.git' | ||
| pod 'GoogleSignIn', :path => '../../../', :testspecs => ['unit'] | ||
| pod 'GoogleSignInSwiftSupport', :path => '../../../', :testspecs => ['unit'] | ||
| project 'AppAttestExample.xcodeproj' | ||
| use_frameworks! :linkage => :static | ||
| target 'AppAttestExample' do | ||
| pod 'AppCheckCore', :git => 'https://github.com/google/app-check.git', :tag => 'CocoaPods-0.1.0-alpha.1' | ||
| pod 'AppCheckCore' | ||
mdmathias marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| platform :ios, '14.0' | ||
| end | ||
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.
Uh oh!
There was an error while loading. Please reload this page.