From b8a4e4dc2c6cc9a9c7fc7f9245c0efdecedb0422 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 12:40:44 -0700 Subject: [PATCH 01/28] Support using a debug app check provider during configuration --- .../GIDAppCheck/Implementations/GIDAppCheck.h | 9 +++++---- .../GIDAppCheck/Implementations/GIDAppCheck.m | 16 ++++++++++++++-- GoogleSignIn/Sources/GIDSignIn.m | 8 ++++++-- .../Sources/Public/GoogleSignIn/GIDSignIn.h | 8 +++++--- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 8 +++++--- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index 68d0a44e..10524390 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -30,13 +30,14 @@ extern NSString *const kGIDAppCheckPreparedKey; NS_CLASS_AVAILABLE_IOS(14) @interface GIDAppCheck : NSObject +- (instancetype)init NS_UNAVAILABLE; + /// Creates the instance of this App Check wrapper class. /// -/// The instance is created using `+[NSUserDefaults standardUserDefaults]` and the standard App -/// Check provider. +/// The instance is created using `+[NSUserDefaults standardUserDefaults]`. /// -/// @SeeAlso The App Check provider is constructed with `+[GIDAppCheck standardAppCheckProvider]`. -- (instancetype)init; +/// @param useDebugProvider Whether or not the debug App Check provider should be used. +- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider; /// Creates the instance of this App Check wrapper class. /// diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index 97a74241..055febdd 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -50,8 +50,13 @@ @interface GIDAppCheck () @implementation GIDAppCheck -- (instancetype)init { - id provider = [GIDAppCheck standardAppCheckProvider]; +- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider { + id provider = nil; + if (useDebugProvider) { + provider = [GIDAppCheck standardAppCheckProvider]; + } else { + provider = [GIDAppCheck debugAppCheckProvider]; + } NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; return [self initWithAppCheckProvider:provider userDefaults:userDefaults]; } @@ -165,6 +170,13 @@ + (NSString *)appAttestResourceName { requestHooks:nil]; } ++ (id)debugAppCheckProvider { + return [[GACAppCheckDebugProvider alloc] initWithServiceName:kGIDAppAttestServiceName + resourceName:[GIDAppCheck appAttestResourceName] + APIKey:nil + requestHooks:nil]; +} + @end #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index bf832d3c..3cacf05d 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -464,7 +464,7 @@ + (GIDSignIn *)sharedInstance { [[GTMKeychainStore alloc] initWithItemName:kGTMAppAuthKeychainName]; #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST if (@available(iOS 14.0, *)) { - GIDAppCheck *appCheck = [[GIDAppCheck alloc] init]; + GIDAppCheck *appCheck = [[GIDAppCheck alloc] initWithDebugProvider:NO]; sharedInstance = [[self alloc] initWithKeychainStore:keychainStore appCheck:appCheck]; } @@ -479,8 +479,12 @@ + (GIDSignIn *)sharedInstance { #pragma mark - Configuring and pre-warming #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST -- (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable))completion { +- (void)configureWithDebugProvider:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { + if (useDebugProvider) { + _appCheck = [[GIDAppCheck alloc] initWithDebugProvider:useDebugProvider]; + } [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { if (completion) { completion(error); diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index e6bd3407..53fe4966 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -70,15 +70,17 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// Configures `GIDSignIn` for use. /// +/// @param useDebugProvider Whether or not App Check should use the debug provider. /// @param completion A nullable callback block passing back any error arising from the -/// configuration process if any exists. +/// configuration process if any exists. /// /// Call this method on `GIDSignIn` prior to use and as early as possible. This method generates App /// Attest key IDs and the attestation object eagerly to minimize latency later on during the sign /// in or add scopes flows. -- (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable error))completion +- (void)configureWithDebugProvider:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) -NS_SWIFT_NAME(configureWithCompletion(completion:)); +NS_SWIFT_NAME(configure(usingDebugProvider:completion:)); #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 400e09fb..4a94c002 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -398,7 +398,8 @@ - (void)testConfigureSucceeds { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - [signIn configureWithCompletion:^(NSError * _Nullable error) { + // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. + [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { XCTAssertNil(error); [configureSucceedsExpecation fulfill]; }]; @@ -422,8 +423,9 @@ - (void)testConfigureFailsNoTokenOrError { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - // `configureWithCompletion:` should fail if neither a token or error is present - [signIn configureWithCompletion:^(NSError * _Nullable error) { + // `configureWithWithDebugProvider:completion:` should fail if missing both token and erro + // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. + [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqual(error.code, kGIDAppCheckUnexpectedError); [configureFailsExpecation fulfill]; From fd77924bc108c776033cbbc3903b1032a2b0c045 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 13:00:12 -0700 Subject: [PATCH 02/28] Update Podfile --- Samples/Swift/AppAttestExample/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Samples/Swift/AppAttestExample/Podfile b/Samples/Swift/AppAttestExample/Podfile index 2a5c41a5..e9762846 100644 --- a/Samples/Swift/AppAttestExample/Podfile +++ b/Samples/Swift/AppAttestExample/Podfile @@ -5,6 +5,6 @@ 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', :git => 'https://github.com/google/app-check.git', :tag => 'CocoaPods-0.1.0-alpha.4' platform :ios, '14.0' end From 5aa30fd3c8a26d9ba393d9233fca0026cce69ba9 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 13:22:44 -0700 Subject: [PATCH 03/28] Use debug provider in example app running in DEBUG --- .../Sources/GIDAppCheck/Implementations/GIDAppCheck.m | 1 + .../AppAttestExample/AppAttestExampleApp.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index 055febdd..2dcfcd18 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -22,6 +22,7 @@ #import #import #import +#import #import "GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h" #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDAppCheckError.h" diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift index a540b533..3850a845 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift +++ b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift @@ -22,11 +22,19 @@ class AppDelegate: NSObject, UIApplicationDelegate { _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil ) -> Bool { - GIDSignIn.sharedInstance.configureWithCompletion { error in + #if DEBUG + GIDSignIn.sharedInstance.configure(usingDebugProvider: true) { error in if let error { print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") } } + #else + GIDSignIn.sharedInstance.configure(usingDebugProvider: false) { error in + if let error { + print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") + } + } + #endif return true } From d21b7b26774fd30874945c6601c3d70eb52faf08 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 13:53:15 -0700 Subject: [PATCH 04/28] Add convenience class methods for creating GIDAppCheck --- .../GIDAppCheck/Implementations/GIDAppCheck.h | 9 ++++++--- .../GIDAppCheck/Implementations/GIDAppCheck.m | 19 +++++++++---------- GoogleSignIn/Sources/GIDSignIn.m | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index 10524390..49790878 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -32,12 +32,15 @@ NS_CLASS_AVAILABLE_IOS(14) - (instancetype)init NS_UNAVAILABLE; -/// Creates the instance of this App Check wrapper class. +/// Creates the instance of this App Check wrapper class using `GACAppCheckDebugProvider`. /// /// The instance is created using `+[NSUserDefaults standardUserDefaults]`. ++ (instancetype)appCheckUsingDebugProvider; + +/// Creates the instance of this App Check wrapper class using `GACAppAttestProvider`. /// -/// @param useDebugProvider Whether or not the debug App Check provider should be used. -- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider; +/// The instance is created using `+[NSUserDefaults standardUserDefaults]`. ++ (instancetype)appCheckUsingAppAttestProvider; /// Creates the instance of this App Check wrapper class. /// diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index 2dcfcd18..a7093ed8 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -51,15 +51,14 @@ @interface GIDAppCheck () @implementation GIDAppCheck -- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider { - id provider = nil; - if (useDebugProvider) { - provider = [GIDAppCheck standardAppCheckProvider]; - } else { - provider = [GIDAppCheck debugAppCheckProvider]; - } - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - return [self initWithAppCheckProvider:provider userDefaults:userDefaults]; ++ (instancetype)appCheckUsingDebugProvider { + return [[self alloc] initWithAppCheckProvider:[GIDAppCheck debugAppCheckProvider] + userDefaults:[NSUserDefaults standardUserDefaults]]; +} + ++ (instancetype)appCheckUsingAppAttestProvider { + return [[self alloc] initWithAppCheckProvider:[GIDAppCheck appAttestProvider] + userDefaults:[NSUserDefaults standardUserDefaults]]; } - (instancetype)initWithAppCheckProvider:(id)appCheckProvider @@ -162,7 +161,7 @@ + (NSString *)appAttestResourceName { return [NSString stringWithFormat:kGIDAppAttestResourceNameFormat, clientID]; } -+ (id)standardAppCheckProvider { ++ (id)appAttestProvider { return [[GACAppAttestProvider alloc] initWithServiceName:kGIDAppAttestServiceName resourceName:[GIDAppCheck appAttestResourceName] baseURL:kGIDAppAttestBaseURL diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 3cacf05d..7cdde369 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -464,7 +464,7 @@ + (GIDSignIn *)sharedInstance { [[GTMKeychainStore alloc] initWithItemName:kGTMAppAuthKeychainName]; #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST if (@available(iOS 14.0, *)) { - GIDAppCheck *appCheck = [[GIDAppCheck alloc] initWithDebugProvider:NO]; + GIDAppCheck *appCheck = [GIDAppCheck appCheckUsingAppAttestProvider]; sharedInstance = [[self alloc] initWithKeychainStore:keychainStore appCheck:appCheck]; } @@ -483,7 +483,7 @@ - (void)configureWithDebugProvider:(BOOL)useDebugProvider completion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { if (useDebugProvider) { - _appCheck = [[GIDAppCheck alloc] initWithDebugProvider:useDebugProvider]; + _appCheck = [GIDAppCheck appCheckUsingDebugProvider]; } [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { if (completion) { From b8083da8ec7b75286d34411c0c43e1660ad60632 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 12:01:24 -0700 Subject: [PATCH 05/28] Use targetEnvironment(simulator) instead of DEBUG --- .../AppAttestExample/AppAttestExampleApp.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift index 3850a845..3302f721 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift +++ b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift @@ -22,19 +22,17 @@ class AppDelegate: NSObject, UIApplicationDelegate { _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil ) -> Bool { - #if DEBUG - GIDSignIn.sharedInstance.configure(usingDebugProvider: true) { error in - if let error { - print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") - } - } + let useDebugProvider: Bool + #if targetEnvironment(simulator) + useDebugProvider = true #else - GIDSignIn.sharedInstance.configure(usingDebugProvider: false) { error in + useDebugProvider = false + #endif + GIDSignIn.sharedInstance.configure(usingDebugProvider: useDebugProvider) { error in if let error { print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") } } - #endif return true } From 1332eaf6527b9bf7c57e7f5de90a2880587e0a73 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 15:38:43 -0700 Subject: [PATCH 06/28] Some changes for the debug provider --- .../xcshareddata/xcschemes/AppAttestExample.xcscheme | 11 +++++------ .../AppAttestExample/AppAttestExample/Info.plist | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme index 43e79198..014c9d6d 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme +++ b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme @@ -49,13 +49,12 @@ ReferencedContainer = "container:AppAttestExample.xcodeproj"> - - + - - + + CFBundleTypeRole Editor CFBundleURLName - com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h + com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj CFBundleURLSchemes - com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h + com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj GIDClientID - 665845761721-a9g0c1k6buv131av6nnmburou5scd63h.apps.googleusercontent.com + 7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj.apps.googleusercontent.com From 8745b14497b56ad8ee8d8436c0886e5efe9d75c9 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 15:46:17 -0700 Subject: [PATCH 07/28] Clarify that configure method on GIDSignIn takes a bool --- GoogleSignIn/Sources/GIDSignIn.m | 4 ++-- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 7cdde369..726b2257 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -479,8 +479,8 @@ + (GIDSignIn *)sharedInstance { #pragma mark - Configuring and pre-warming #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST -- (void)configureWithDebugProvider:(BOOL)useDebugProvider - completion:(nullable void (^)(NSError * _Nullable))completion { +- (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { if (useDebugProvider) { _appCheck = [GIDAppCheck appCheckUsingDebugProvider]; diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 53fe4966..31dc67c7 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -77,8 +77,8 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// Call this method on `GIDSignIn` prior to use and as early as possible. This method generates App /// Attest key IDs and the attestation object eagerly to minimize latency later on during the sign /// in or add scopes flows. -- (void)configureWithDebugProvider:(BOOL)useDebugProvider - completion:(nullable void (^)(NSError * _Nullable error))completion +- (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) NS_SWIFT_NAME(configure(usingDebugProvider:completion:)); From d8fed0a05f4812d752ce10dc333bc56f09f1ce95 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 15:47:22 -0700 Subject: [PATCH 08/28] Update swift name for GIDSignIn configure method --- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 31dc67c7..a425053c 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -80,7 +80,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { - (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) -NS_SWIFT_NAME(configure(usingDebugProvider:completion:)); +NS_SWIFT_NAME(configure(debugProviderEnabled:completion:)); #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST From f25ca3f8211996119af8a5bd9cd1612664d69fa0 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 16:29:45 -0700 Subject: [PATCH 09/28] Use new configure method in GIDSignInTest --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 4a94c002..da2d57b9 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -399,7 +399,7 @@ - (void)testConfigureSucceeds { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { + [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { XCTAssertNil(error); [configureSucceedsExpecation fulfill]; }]; @@ -425,7 +425,7 @@ - (void)testConfigureFailsNoTokenOrError { // `configureWithWithDebugProvider:completion:` should fail if missing both token and erro // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { + [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqual(error.code, kGIDAppCheckUnexpectedError); [configureFailsExpecation fulfill]; From de9f81df4fa504e552ab74d5c2c320f3ef2c9b6e Mon Sep 17 00:00:00 2001 From: mdmathias Date: Thu, 31 Aug 2023 14:53:21 -0700 Subject: [PATCH 10/28] Remove use of GACAppCheckTokenProtocol per AppCheckCore api changes (#337) --- GoogleSignIn.podspec | 2 +- .../Fake/GIDAppCheckProviderFake.m | 10 +++++----- .../GIDAppCheck/Implementations/GIDAppCheck.h | 4 ++-- .../GIDAppCheck/Implementations/GIDAppCheck.m | 20 +++++++++---------- GoogleSignIn/Sources/GIDSignIn.m | 4 ++-- GoogleSignIn/Tests/Unit/GIDAppCheckTest.m | 8 ++++---- Package.swift | 2 +- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/GoogleSignIn.podspec b/GoogleSignIn.podspec index 8c7d93b7..697f5177 100644 --- a/GoogleSignIn.podspec +++ b/GoogleSignIn.podspec @@ -33,7 +33,7 @@ The Google Sign-In SDK allows users to sign in with their Google account from th ] s.ios.framework = 'UIKit' s.osx.framework = 'AppKit' - s.dependency 'AppCheckCore', '~> 0.1.0-alpha.4' + s.dependency 'AppCheckCore', '~> 0.1.0-alpha.6' s.dependency 'AppAuth', '~> 1.6' s.dependency 'GTMAppAuth', '~> 4.0' s.dependency 'GTMSessionFetcher/Core', '>= 1.1', '< 4.0' diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m index 0a3dfb1a..6ca88bc0 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m @@ -22,14 +22,14 @@ @interface GIDAppCheckProviderFake () -@property(nonatomic, strong, nullable) id token; +@property(nonatomic, strong, nullable) GACAppCheckToken *token; @property(nonatomic, strong, nullable) NSError *error; @end @implementation GIDAppCheckProviderFake -- (instancetype)initWithAppCheckToken:(nullable id)token +- (instancetype)initWithAppCheckToken:(nullable GACAppCheckToken *)token error:(nullable NSError *)error { if (self = [super init]) { _token = token; @@ -38,14 +38,14 @@ - (instancetype)initWithAppCheckToken:(nullable id)tok return self; } -- (void)getTokenWithCompletion:(nonnull void (^)(id _Nullable, - NSError * _Nullable))handler { +- (void)getTokenWithCompletion:(void (^)(GACAppCheckToken * _Nullable, + NSError * _Nullable))handler { dispatch_async(dispatch_get_main_queue(), ^{ handler(self.token, self.error); }); } -- (void)getLimitedUseTokenWithCompletion:(void (^)(id _Nullable, +- (void)getLimitedUseTokenWithCompletion:(void (^)(GACAppCheckToken * _Nullable, NSError * _Nullable))handler { dispatch_async(dispatch_get_main_queue(), ^{ handler(self.token, self.error); diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index 68d0a44e..dde7c9cd 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol GACAppCheckProvider; -@protocol GACAppCheckTokenProtocol; +@class GACAppCheckToken; extern NSString *const kGIDAppCheckPreparedKey; @@ -58,7 +58,7 @@ NS_CLASS_AVAILABLE_IOS(14) /// @param completion A `nullable` callback with the `FIRAppCheckToken` if present, or an `NSError` /// otherwise. - (void)getLimitedUseTokenWithCompletion: - (nullable void (^)(id _Nullable token, + (nullable void (^)(GACAppCheckToken * _Nullable token, NSError * _Nullable error))completion; /// Whether or not the App Attest key ID created and the attestation object has been fetched. diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index 97a74241..2e4d2c60 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -20,7 +20,7 @@ #import #import -#import +#import #import #import "GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h" @@ -35,7 +35,7 @@ static NSString *const kGIDAppAttestBaseURL = @"https://firebaseappcheck.googleapis.com/v1beta"; typedef void (^GIDAppCheckPrepareCompletion)(NSError * _Nullable); -typedef void (^GIDAppCheckTokenCompletion)(id _Nullable, +typedef void (^GIDAppCheckTokenCompletion)(GACAppCheckToken * _Nullable, NSError * _Nullable); @interface GIDAppCheck () @@ -110,17 +110,16 @@ - (void)prepareForAppCheckWithCompletion:(nullable GIDAppCheckPrepareCompletion) return; } - [self.appCheck limitedUseTokenWithCompletion:^(id _Nullable token, - NSError * _Nullable error) { - NSError * __block maybeError = error; + [self.appCheck limitedUseTokenWithCompletion:^(GACAppCheckTokenResult * _Nonnull result) { + NSError * __block maybeError = result.error; @synchronized (self) { - if (!token && !error) { + if (!result.token && !result.error) { maybeError = [NSError errorWithDomain:kGIDAppCheckErrorDomain code:kGIDAppCheckUnexpectedError userInfo:nil]; } - if (token) { + if (result.token) { [self.userDefaults setBool:YES forKey:kGIDAppCheckPreparedKey]; } @@ -139,13 +138,12 @@ - (void)prepareForAppCheckWithCompletion:(nullable GIDAppCheckPrepareCompletion) - (void)getLimitedUseTokenWithCompletion:(nullable GIDAppCheckTokenCompletion)completion { dispatch_async(self.workerQueue, ^{ - [self.appCheck limitedUseTokenWithCompletion:^(id _Nullable token, - NSError * _Nullable error) { - if (token) { + [self.appCheck limitedUseTokenWithCompletion:^(GACAppCheckTokenResult * _Nonnull result) { + if (result.token) { [self.userDefaults setBool:YES forKey:kGIDAppCheckPreparedKey]; } if (completion) { - completion(token, error); + completion(result.token, result.error); } }]; }); diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index bf832d3c..67e4cc9e 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -646,8 +646,8 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp _timedLoader = [[GIDTimedLoader alloc] initWithPresentingViewController:presentingVC]; } [_timedLoader startTiming]; - [self->_appCheck getLimitedUseTokenWithCompletion: - ^(id _Nullable token, NSError * _Nullable error) { + [self->_appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken * _Nullable token, + NSError * _Nullable error) { OIDAuthorizationRequest *request = nil; if (token) { additionalParameters[kClientAssertionTypeParameter] = kClientAssertionTypeParameterValue; diff --git a/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m b/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m index e84c9a84..8ba90887 100644 --- a/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m +++ b/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m @@ -45,7 +45,7 @@ - (void)tearDown { [self.userDefaults removeSuiteNamed:kUserDefaultsTestSuiteName]; } -- (void)testGetLimitedUseTokenFailure { +- (void)testGetLimitedUseTokenFailureReturnsPlaceholder { XCTestExpectation *tokenFailExpectation = [self expectationWithDescription:@"App check token fail"]; NSError *expectedError = [NSError errorWithDomain:kGIDAppCheckErrorDomain @@ -57,9 +57,9 @@ - (void)testGetLimitedUseTokenFailure { GIDAppCheck *appCheck = [[GIDAppCheck alloc] initWithAppCheckProvider:fakeProvider userDefaults:self.userDefaults]; - [appCheck getLimitedUseTokenWithCompletion:^(id _Nullable token, + [appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken * _Nullable token, NSError * _Nullable error) { - XCTAssertNil(token); + XCTAssertNotNil(token); // If there is an error, we expect a placeholder token XCTAssertEqualObjects(expectedError, error); [tokenFailExpectation fulfill]; }]; @@ -126,7 +126,7 @@ - (void)testGetLimitedUseTokenSucceeds { XCTestExpectation *getLimitedUseTokenSucceedsExpectation = [self expectationWithDescription:@"getLimitedUseToken should succeed"]; - [appCheck getLimitedUseTokenWithCompletion:^(id _Nullable token, + [appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken * _Nullable token, NSError * _Nullable error) { XCTAssertNil(error); XCTAssertNotNil(token); diff --git a/Package.swift b/Package.swift index cd74c50d..be46e8bd 100644 --- a/Package.swift +++ b/Package.swift @@ -48,7 +48,7 @@ let package = Package( .package( name: "AppCheck", url: "https://github.com/google/app-check.git", - .branch("main")), + .branch("CocoaPods-0.1.0-alpha.6")), .package( name: "GTMAppAuth", url: "https://github.com/google/GTMAppAuth.git", From d35b8d9bb4ea9ec497f89720ef6165a9e84612cd Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 12:40:44 -0700 Subject: [PATCH 11/28] Support using a debug app check provider during configuration --- .../GIDAppCheck/Implementations/GIDAppCheck.h | 9 +++++---- .../GIDAppCheck/Implementations/GIDAppCheck.m | 16 ++++++++++++++-- GoogleSignIn/Sources/GIDSignIn.m | 8 ++++++-- .../Sources/Public/GoogleSignIn/GIDSignIn.h | 8 +++++--- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 8 +++++--- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index dde7c9cd..17ee8be6 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -30,13 +30,14 @@ extern NSString *const kGIDAppCheckPreparedKey; NS_CLASS_AVAILABLE_IOS(14) @interface GIDAppCheck : NSObject +- (instancetype)init NS_UNAVAILABLE; + /// Creates the instance of this App Check wrapper class. /// -/// The instance is created using `+[NSUserDefaults standardUserDefaults]` and the standard App -/// Check provider. +/// The instance is created using `+[NSUserDefaults standardUserDefaults]`. /// -/// @SeeAlso The App Check provider is constructed with `+[GIDAppCheck standardAppCheckProvider]`. -- (instancetype)init; +/// @param useDebugProvider Whether or not the debug App Check provider should be used. +- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider; /// Creates the instance of this App Check wrapper class. /// diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index 2e4d2c60..d0c433ee 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -50,8 +50,13 @@ @interface GIDAppCheck () @implementation GIDAppCheck -- (instancetype)init { - id provider = [GIDAppCheck standardAppCheckProvider]; +- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider { + id provider = nil; + if (useDebugProvider) { + provider = [GIDAppCheck standardAppCheckProvider]; + } else { + provider = [GIDAppCheck debugAppCheckProvider]; + } NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; return [self initWithAppCheckProvider:provider userDefaults:userDefaults]; } @@ -163,6 +168,13 @@ + (NSString *)appAttestResourceName { requestHooks:nil]; } ++ (id)debugAppCheckProvider { + return [[GACAppCheckDebugProvider alloc] initWithServiceName:kGIDAppAttestServiceName + resourceName:[GIDAppCheck appAttestResourceName] + APIKey:nil + requestHooks:nil]; +} + @end #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 67e4cc9e..0de2cf86 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -464,7 +464,7 @@ + (GIDSignIn *)sharedInstance { [[GTMKeychainStore alloc] initWithItemName:kGTMAppAuthKeychainName]; #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST if (@available(iOS 14.0, *)) { - GIDAppCheck *appCheck = [[GIDAppCheck alloc] init]; + GIDAppCheck *appCheck = [[GIDAppCheck alloc] initWithDebugProvider:NO]; sharedInstance = [[self alloc] initWithKeychainStore:keychainStore appCheck:appCheck]; } @@ -479,8 +479,12 @@ + (GIDSignIn *)sharedInstance { #pragma mark - Configuring and pre-warming #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST -- (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable))completion { +- (void)configureWithDebugProvider:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { + if (useDebugProvider) { + _appCheck = [[GIDAppCheck alloc] initWithDebugProvider:useDebugProvider]; + } [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { if (completion) { completion(error); diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index e6bd3407..53fe4966 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -70,15 +70,17 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// Configures `GIDSignIn` for use. /// +/// @param useDebugProvider Whether or not App Check should use the debug provider. /// @param completion A nullable callback block passing back any error arising from the -/// configuration process if any exists. +/// configuration process if any exists. /// /// Call this method on `GIDSignIn` prior to use and as early as possible. This method generates App /// Attest key IDs and the attestation object eagerly to minimize latency later on during the sign /// in or add scopes flows. -- (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable error))completion +- (void)configureWithDebugProvider:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) -NS_SWIFT_NAME(configureWithCompletion(completion:)); +NS_SWIFT_NAME(configure(usingDebugProvider:completion:)); #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 400e09fb..4a94c002 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -398,7 +398,8 @@ - (void)testConfigureSucceeds { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - [signIn configureWithCompletion:^(NSError * _Nullable error) { + // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. + [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { XCTAssertNil(error); [configureSucceedsExpecation fulfill]; }]; @@ -422,8 +423,9 @@ - (void)testConfigureFailsNoTokenOrError { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - // `configureWithCompletion:` should fail if neither a token or error is present - [signIn configureWithCompletion:^(NSError * _Nullable error) { + // `configureWithWithDebugProvider:completion:` should fail if missing both token and erro + // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. + [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqual(error.code, kGIDAppCheckUnexpectedError); [configureFailsExpecation fulfill]; From 77ff98695087f72aa36b8f07088d359fc90ac6d4 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 13:00:12 -0700 Subject: [PATCH 12/28] Update Podfile --- Samples/Swift/AppAttestExample/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Samples/Swift/AppAttestExample/Podfile b/Samples/Swift/AppAttestExample/Podfile index 2a5c41a5..e9762846 100644 --- a/Samples/Swift/AppAttestExample/Podfile +++ b/Samples/Swift/AppAttestExample/Podfile @@ -5,6 +5,6 @@ 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', :git => 'https://github.com/google/app-check.git', :tag => 'CocoaPods-0.1.0-alpha.4' platform :ios, '14.0' end From 7a0f2e7ae80053b8429d9dfcff64913e73084103 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 13:22:44 -0700 Subject: [PATCH 13/28] Use debug provider in example app running in DEBUG --- .../Sources/GIDAppCheck/Implementations/GIDAppCheck.m | 1 + .../AppAttestExample/AppAttestExampleApp.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index d0c433ee..6ac10465 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -22,6 +22,7 @@ #import #import #import +#import #import "GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h" #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDAppCheckError.h" diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift index a540b533..3850a845 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift +++ b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift @@ -22,11 +22,19 @@ class AppDelegate: NSObject, UIApplicationDelegate { _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil ) -> Bool { - GIDSignIn.sharedInstance.configureWithCompletion { error in + #if DEBUG + GIDSignIn.sharedInstance.configure(usingDebugProvider: true) { error in if let error { print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") } } + #else + GIDSignIn.sharedInstance.configure(usingDebugProvider: false) { error in + if let error { + print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") + } + } + #endif return true } From 8607395f113e120b8c328e32a48ca5d1c38455c2 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 25 Aug 2023 13:53:15 -0700 Subject: [PATCH 14/28] Add convenience class methods for creating GIDAppCheck --- .../GIDAppCheck/Implementations/GIDAppCheck.h | 9 ++++++--- .../GIDAppCheck/Implementations/GIDAppCheck.m | 19 +++++++++---------- GoogleSignIn/Sources/GIDSignIn.m | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index 17ee8be6..671ecbd7 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -32,12 +32,15 @@ NS_CLASS_AVAILABLE_IOS(14) - (instancetype)init NS_UNAVAILABLE; -/// Creates the instance of this App Check wrapper class. +/// Creates the instance of this App Check wrapper class using `GACAppCheckDebugProvider`. /// /// The instance is created using `+[NSUserDefaults standardUserDefaults]`. ++ (instancetype)appCheckUsingDebugProvider; + +/// Creates the instance of this App Check wrapper class using `GACAppAttestProvider`. /// -/// @param useDebugProvider Whether or not the debug App Check provider should be used. -- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider; +/// The instance is created using `+[NSUserDefaults standardUserDefaults]`. ++ (instancetype)appCheckUsingAppAttestProvider; /// Creates the instance of this App Check wrapper class. /// diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index 6ac10465..bc9937bd 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -51,15 +51,14 @@ @interface GIDAppCheck () @implementation GIDAppCheck -- (instancetype)initWithDebugProvider:(BOOL)useDebugProvider { - id provider = nil; - if (useDebugProvider) { - provider = [GIDAppCheck standardAppCheckProvider]; - } else { - provider = [GIDAppCheck debugAppCheckProvider]; - } - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - return [self initWithAppCheckProvider:provider userDefaults:userDefaults]; ++ (instancetype)appCheckUsingDebugProvider { + return [[self alloc] initWithAppCheckProvider:[GIDAppCheck debugAppCheckProvider] + userDefaults:[NSUserDefaults standardUserDefaults]]; +} + ++ (instancetype)appCheckUsingAppAttestProvider { + return [[self alloc] initWithAppCheckProvider:[GIDAppCheck appAttestProvider] + userDefaults:[NSUserDefaults standardUserDefaults]]; } - (instancetype)initWithAppCheckProvider:(id)appCheckProvider @@ -160,7 +159,7 @@ + (NSString *)appAttestResourceName { return [NSString stringWithFormat:kGIDAppAttestResourceNameFormat, clientID]; } -+ (id)standardAppCheckProvider { ++ (id)appAttestProvider { return [[GACAppAttestProvider alloc] initWithServiceName:kGIDAppAttestServiceName resourceName:[GIDAppCheck appAttestResourceName] baseURL:kGIDAppAttestBaseURL diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 0de2cf86..e0d9f118 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -464,7 +464,7 @@ + (GIDSignIn *)sharedInstance { [[GTMKeychainStore alloc] initWithItemName:kGTMAppAuthKeychainName]; #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST if (@available(iOS 14.0, *)) { - GIDAppCheck *appCheck = [[GIDAppCheck alloc] initWithDebugProvider:NO]; + GIDAppCheck *appCheck = [GIDAppCheck appCheckUsingAppAttestProvider]; sharedInstance = [[self alloc] initWithKeychainStore:keychainStore appCheck:appCheck]; } @@ -483,7 +483,7 @@ - (void)configureWithDebugProvider:(BOOL)useDebugProvider completion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { if (useDebugProvider) { - _appCheck = [[GIDAppCheck alloc] initWithDebugProvider:useDebugProvider]; + _appCheck = [GIDAppCheck appCheckUsingDebugProvider]; } [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { if (completion) { From ff0d27a846c2aa6acd592968c9a087a625a5ea2d Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 12:01:24 -0700 Subject: [PATCH 15/28] Use targetEnvironment(simulator) instead of DEBUG --- .../AppAttestExample/AppAttestExampleApp.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift index 3850a845..3302f721 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift +++ b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift @@ -22,19 +22,17 @@ class AppDelegate: NSObject, UIApplicationDelegate { _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil ) -> Bool { - #if DEBUG - GIDSignIn.sharedInstance.configure(usingDebugProvider: true) { error in - if let error { - print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") - } - } + let useDebugProvider: Bool + #if targetEnvironment(simulator) + useDebugProvider = true #else - GIDSignIn.sharedInstance.configure(usingDebugProvider: false) { error in + useDebugProvider = false + #endif + GIDSignIn.sharedInstance.configure(usingDebugProvider: useDebugProvider) { error in if let error { print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") } } - #endif return true } From f26e917855fdde8f3cda8937582d7a5aa1f92510 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 15:38:43 -0700 Subject: [PATCH 16/28] Some changes for the debug provider --- .../xcshareddata/xcschemes/AppAttestExample.xcscheme | 11 +++++------ .../AppAttestExample/AppAttestExample/Info.plist | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme index 43e79198..014c9d6d 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme +++ b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme @@ -49,13 +49,12 @@ ReferencedContainer = "container:AppAttestExample.xcodeproj"> - - + - - + + CFBundleTypeRole Editor CFBundleURLName - com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h + com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj CFBundleURLSchemes - com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h + com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj GIDClientID - 665845761721-a9g0c1k6buv131av6nnmburou5scd63h.apps.googleusercontent.com + 7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj.apps.googleusercontent.com From 481c3d0cc2797ea39ccf0689189f89440cf958a4 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 15:46:17 -0700 Subject: [PATCH 17/28] Clarify that configure method on GIDSignIn takes a bool --- GoogleSignIn/Sources/GIDSignIn.m | 4 ++-- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index e0d9f118..9aa7921c 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -479,8 +479,8 @@ + (GIDSignIn *)sharedInstance { #pragma mark - Configuring and pre-warming #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST -- (void)configureWithDebugProvider:(BOOL)useDebugProvider - completion:(nullable void (^)(NSError * _Nullable))completion { +- (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { if (useDebugProvider) { _appCheck = [GIDAppCheck appCheckUsingDebugProvider]; diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 53fe4966..31dc67c7 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -77,8 +77,8 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// Call this method on `GIDSignIn` prior to use and as early as possible. This method generates App /// Attest key IDs and the attestation object eagerly to minimize latency later on during the sign /// in or add scopes flows. -- (void)configureWithDebugProvider:(BOOL)useDebugProvider - completion:(nullable void (^)(NSError * _Nullable error))completion +- (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider + completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) NS_SWIFT_NAME(configure(usingDebugProvider:completion:)); From 7ab2910c0091885005fbd14f70cf21cf78e7ceba Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 15:47:22 -0700 Subject: [PATCH 18/28] Update swift name for GIDSignIn configure method --- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 31dc67c7..a425053c 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -80,7 +80,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { - (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) -NS_SWIFT_NAME(configure(usingDebugProvider:completion:)); +NS_SWIFT_NAME(configure(debugProviderEnabled:completion:)); #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST From 862f870dfde586f49bc8734f4337aed1ea7397ac Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 30 Aug 2023 16:29:45 -0700 Subject: [PATCH 19/28] Use new configure method in GIDSignInTest --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 4a94c002..da2d57b9 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -399,7 +399,7 @@ - (void)testConfigureSucceeds { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { + [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { XCTAssertNil(error); [configureSucceedsExpecation fulfill]; }]; @@ -425,7 +425,7 @@ - (void)testConfigureFailsNoTokenOrError { // `configureWithWithDebugProvider:completion:` should fail if missing both token and erro // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProvider:NO completion:^(NSError * _Nullable error) { + [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqual(error.code, kGIDAppCheckUnexpectedError); [configureFailsExpecation fulfill]; From 9d080337853f01d746f12419f50564909dd72d50 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Tue, 5 Sep 2023 16:49:16 -0700 Subject: [PATCH 20/28] Support for debug tokens including a config for secrets --- .gitignore | 1 + .../GIDAppCheck/Implementations/GIDAppCheck.h | 4 +++- .../GIDAppCheck/Implementations/GIDAppCheck.m | 9 +++++---- GoogleSignIn/Sources/GIDSignIn.m | 18 +++++++++++++----- .../Sources/Public/GoogleSignIn/GIDSignIn.h | 19 +++++++++++++++---- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 8 +++----- .../project.pbxproj | 3 +++ .../xcschemes/AppAttestExample.xcscheme | 6 ------ .../AppAttestExampleApp.swift | 16 +++++++++++----- .../AppAttestExample/Info.plist | 8 +++++--- Samples/Swift/AppAttestExample/Podfile | 5 ++++- 11 files changed, 63 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 538419c3..103cb405 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ Podfile.lock # Firebase App Check Example **/GoogleService-Info.plist +**/AppCheckSecrets.xcconfig diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index 671ecbd7..2fe81e0e 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -34,8 +34,10 @@ NS_CLASS_AVAILABLE_IOS(14) /// Creates the instance of this App Check wrapper class using `GACAppCheckDebugProvider`. /// +/// @param APIKey The API Key to use when creating the debug App Check provider. +/// /// The instance is created using `+[NSUserDefaults standardUserDefaults]`. -+ (instancetype)appCheckUsingDebugProvider; ++ (instancetype)appCheckUsingDebugProviderWithAPIKey:(NSString *)APIKey; /// Creates the instance of this App Check wrapper class using `GACAppAttestProvider`. /// diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index bc9937bd..cfc8d4ff 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -51,8 +51,8 @@ @interface GIDAppCheck () @implementation GIDAppCheck -+ (instancetype)appCheckUsingDebugProvider { - return [[self alloc] initWithAppCheckProvider:[GIDAppCheck debugAppCheckProvider] ++ (instancetype)appCheckUsingDebugProviderWithAPIKey:(NSString *)APIKey { + return [[self alloc] initWithAppCheckProvider:[GIDAppCheck debugAppCheckProviderWithAPIKey:APIKey] userDefaults:[NSUserDefaults standardUserDefaults]]; } @@ -168,10 +168,11 @@ + (NSString *)appAttestResourceName { requestHooks:nil]; } -+ (id)debugAppCheckProvider { ++ (id)debugAppCheckProviderWithAPIKey:(NSString *)APIKey { return [[GACAppCheckDebugProvider alloc] initWithServiceName:kGIDAppAttestServiceName resourceName:[GIDAppCheck appAttestResourceName] - APIKey:nil + baseURL:kGIDAppAttestBaseURL + APIKey:APIKey requestHooks:nil]; } diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 9aa7921c..48b9f368 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -479,12 +479,20 @@ + (GIDSignIn *)sharedInstance { #pragma mark - Configuring and pre-warming #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST -- (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider - completion:(nullable void (^)(NSError * _Nullable))completion { +- (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable))completion { @synchronized(self) { - if (useDebugProvider) { - _appCheck = [GIDAppCheck appCheckUsingDebugProvider]; - } + [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { + if (completion) { + completion(error); + } + }]; + } +} + +- (void)configureDebugProviderWithAPIKey:(NSString *)APIKey + completion:(nullable void (^)(NSError * _Nullable))completion { + @synchronized(self) { + _appCheck = [GIDAppCheck appCheckUsingDebugProviderWithAPIKey:APIKey]; [_appCheck prepareForAppCheckWithCompletion:^(NSError * _Nullable error) { if (completion) { completion(error); diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index a425053c..5702fca1 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -70,17 +70,28 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// Configures `GIDSignIn` for use. /// -/// @param useDebugProvider Whether or not App Check should use the debug provider. /// @param completion A nullable callback block passing back any error arising from the /// configuration process if any exists. /// /// Call this method on `GIDSignIn` prior to use and as early as possible. This method generates App /// Attest key IDs and the attestation object eagerly to minimize latency later on during the sign /// in or add scopes flows. -- (void)configureWithDebugProviderEnabled:(BOOL)useDebugProvider - completion:(nullable void (^)(NSError * _Nullable error))completion +- (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable error))completion +NS_SWIFT_NAME(configure(completion:)); + +/// Configures `GIDSignIn` for use. +/// +/// @param APIKey The API Key to use during configuration of the App Check debug provider. +/// @param completion A nullable callback block passing back any error arising from the +/// configuration process if any exists. +/// +/// Call this method on `GIDSignIn` prior to use and as early as possible. This method generates App +/// Attest key IDs and the attestation object eagerly to minimize latency later on during the sign +/// in or add scopes flows. +- (void)configureDebugProviderWithAPIKey:(NSString *)APIKey + completion:(nullable void (^)(NSError * _Nullable error))completion API_AVAILABLE(ios(14)) -NS_SWIFT_NAME(configure(debugProviderEnabled:completion:)); +NS_SWIFT_NAME(configureDebugProvider(withAPIKey:completion:)); #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index da2d57b9..0f35dc6b 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -398,8 +398,7 @@ - (void)testConfigureSucceeds { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { + [signIn configureWithCompletion:^(NSError * _Nullable error) { XCTAssertNil(error); [configureSucceedsExpecation fulfill]; }]; @@ -423,9 +422,8 @@ - (void)testConfigureFailsNoTokenOrError { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - // `configureWithWithDebugProvider:completion:` should fail if missing both token and erro - // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { + // Should fail if missing both token and error + [signIn configureWithCompletion:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqual(error.code, kGIDAppCheckUnexpectedError); [configureFailsExpecation fulfill]; diff --git a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj index 15473767..eb2599f6 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj +++ b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ /* Begin PBXFileReference section */ 1C96B5B2B34E31F1A1CEE95E /* Pods-AppAttestExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppAttestExample.release.xcconfig"; path = "Target Support Files/Pods-AppAttestExample/Pods-AppAttestExample.release.xcconfig"; sourceTree = ""; }; 73443A232A55F56900A4932E /* AppAttestExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppAttestExample.entitlements; sourceTree = ""; }; + 738B4A302AA7EB840056885D /* AppCheckSecrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppCheckSecrets.xcconfig; sourceTree = ""; }; 738D5F722A26BC3B00A7F11B /* BirthdayLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BirthdayLoader.swift; sourceTree = ""; }; 73A065612A786D10007BC7FC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73A464002A1C3B3400BA8528 /* AppAttestExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppAttestExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -73,6 +74,7 @@ 73A464032A1C3B3400BA8528 /* AppAttestExampleApp.swift */, 73A464052A1C3B3400BA8528 /* ContentView.swift */, 738D5F722A26BC3B00A7F11B /* BirthdayLoader.swift */, + 738B4A302AA7EB840056885D /* AppCheckSecrets.xcconfig */, 73A065612A786D10007BC7FC /* Info.plist */, 73A464092A1C3B3500BA8528 /* Preview Content */, ); @@ -219,6 +221,7 @@ /* Begin XCBuildConfiguration section */ 73A4640C2A1C3B3500BA8528 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 738B4A302AA7EB840056885D /* AppCheckSecrets.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; diff --git a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme index 014c9d6d..f2c125f8 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme +++ b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme @@ -49,12 +49,6 @@ ReferencedContainer = "container:AppAttestExample.xcodeproj"> - - - - Bool { - let useDebugProvider: Bool #if targetEnvironment(simulator) - useDebugProvider = true + guard let apiKey = Bundle.main.infoDictionary!["APP_CHECK_WEB_API_KEY"] as? String else { + print("Failed to get App_Check_WEB_API_KEY from Bundle.") + return true + } + GIDSignIn.sharedInstance.configureDebugProvider(withAPIKey: apiKey) { error in + if let error { + print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") + } + } #else - useDebugProvider = false - #endif - GIDSignIn.sharedInstance.configure(usingDebugProvider: useDebugProvider) { error in + GIDSignIn.sharedInstance.configure { error in if let error { print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") } } + #endif return true } diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist b/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist index b250b555..e8f329f4 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist +++ b/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist @@ -2,20 +2,22 @@ + APP_CHECK_WEB_API_KEY + $(APP_CHECK_WEB_API_KEY) CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLName - com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj + com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h CFBundleURLSchemes - com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj + com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h GIDClientID - 7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj.apps.googleusercontent.com + 665845761721-a9g0c1k6buv131av6nnmburou5scd63h.apps.googleusercontent.com diff --git a/Samples/Swift/AppAttestExample/Podfile b/Samples/Swift/AppAttestExample/Podfile index e9762846..9554395e 100644 --- a/Samples/Swift/AppAttestExample/Podfile +++ b/Samples/Swift/AppAttestExample/Podfile @@ -1,3 +1,6 @@ +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' @@ -5,6 +8,6 @@ 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.4' + pod 'AppCheckCore' platform :ios, '14.0' end From 39cd41412ccbfaae7a1f54571ab6d2ddaea73dc6 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Tue, 5 Sep 2023 17:35:38 -0700 Subject: [PATCH 21/28] Fix xcscheme conflict --- .../xcshareddata/xcschemes/AppAttestExample.xcscheme | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme index 55e2925d..f2c125f8 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme +++ b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/xcshareddata/xcschemes/AppAttestExample.xcscheme @@ -49,15 +49,6 @@ ReferencedContainer = "container:AppAttestExample.xcodeproj"> -<<<<<<< HEAD -======= - - - - ->>>>>>> f25ca3f8211996119af8a5bd9cd1612664d69fa0 Date: Tue, 5 Sep 2023 17:56:15 -0700 Subject: [PATCH 22/28] Fix conflicts in GIDSignInTes --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 4a97d8ca..0f35dc6b 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -398,8 +398,7 @@ - (void)testConfigureSucceeds { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; - // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { + [signIn configureWithCompletion:^(NSError * _Nullable error) { XCTAssertNil(error); [configureSucceedsExpecation fulfill]; }]; @@ -423,14 +422,8 @@ - (void)testConfigureFailsNoTokenOrError { GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore appCheck:appCheck]; -<<<<<<< HEAD // Should fail if missing both token and error [signIn configureWithCompletion:^(NSError * _Nullable error) { -======= - // `configureWithWithDebugProvider:completion:` should fail if missing both token and erro - // Pass `NO` so that a debug provider is not created and used instead of `appCheck` above. - [signIn configureWithDebugProviderEnabled:NO completion:^(NSError * _Nullable error) { ->>>>>>> f25ca3f8211996119af8a5bd9cd1612664d69fa0 XCTAssertNotNil(error); XCTAssertEqual(error.code, kGIDAppCheckUnexpectedError); [configureFailsExpecation fulfill]; From 1920244d00dfaf14288b64012f7771816ac6cee9 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Tue, 5 Sep 2023 18:23:19 -0700 Subject: [PATCH 23/28] Remove unused param from doc comment --- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 1 - 1 file changed, 1 deletion(-) diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index d4b59840..5702fca1 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -70,7 +70,6 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// Configures `GIDSignIn` for use. /// -/// @param useDebugProvider Whether or not App Check should use the debug provider. /// @param completion A nullable callback block passing back any error arising from the /// configuration process if any exists. /// From ac495f01bcea742678d6129c76491e99145c0242 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 6 Sep 2023 15:11:57 -0700 Subject: [PATCH 24/28] Add AppCheckSecretReader --- .../project.pbxproj | 4 ++ .../AppAttestExampleApp.swift | 7 +-- .../AppCheckSecretReader.swift | 44 +++++++++++++++++++ .../AppAttestExample/Info.plist | 6 +-- 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 Samples/Swift/AppAttestExample/AppAttestExample/AppCheckSecretReader.swift diff --git a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj index eb2599f6..e976444d 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj +++ b/Samples/Swift/AppAttestExample/AppAttestExample.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 4D8DB53AAE2F7D0055DCEA7F /* Pods_AppAttestExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F3A930BB86D9E0648046BC /* Pods_AppAttestExample.framework */; }; + 738B4A322AA8FE800056885D /* AppCheckSecretReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 738B4A312AA8FE800056885D /* AppCheckSecretReader.swift */; }; 738D5F732A26BC3B00A7F11B /* BirthdayLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 738D5F722A26BC3B00A7F11B /* BirthdayLoader.swift */; }; 73A464042A1C3B3400BA8528 /* AppAttestExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73A464032A1C3B3400BA8528 /* AppAttestExampleApp.swift */; }; 73A464062A1C3B3400BA8528 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73A464052A1C3B3400BA8528 /* ContentView.swift */; }; @@ -18,6 +19,7 @@ 1C96B5B2B34E31F1A1CEE95E /* Pods-AppAttestExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppAttestExample.release.xcconfig"; path = "Target Support Files/Pods-AppAttestExample/Pods-AppAttestExample.release.xcconfig"; sourceTree = ""; }; 73443A232A55F56900A4932E /* AppAttestExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppAttestExample.entitlements; sourceTree = ""; }; 738B4A302AA7EB840056885D /* AppCheckSecrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppCheckSecrets.xcconfig; sourceTree = ""; }; + 738B4A312AA8FE800056885D /* AppCheckSecretReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCheckSecretReader.swift; sourceTree = ""; }; 738D5F722A26BC3B00A7F11B /* BirthdayLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BirthdayLoader.swift; sourceTree = ""; }; 73A065612A786D10007BC7FC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73A464002A1C3B3400BA8528 /* AppAttestExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppAttestExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -74,6 +76,7 @@ 73A464032A1C3B3400BA8528 /* AppAttestExampleApp.swift */, 73A464052A1C3B3400BA8528 /* ContentView.swift */, 738D5F722A26BC3B00A7F11B /* BirthdayLoader.swift */, + 738B4A312AA8FE800056885D /* AppCheckSecretReader.swift */, 738B4A302AA7EB840056885D /* AppCheckSecrets.xcconfig */, 73A065612A786D10007BC7FC /* Info.plist */, 73A464092A1C3B3500BA8528 /* Preview Content */, @@ -211,6 +214,7 @@ buildActionMask = 2147483647; files = ( 738D5F732A26BC3B00A7F11B /* BirthdayLoader.swift in Sources */, + 738B4A322AA8FE800056885D /* AppCheckSecretReader.swift in Sources */, 73A464062A1C3B3400BA8528 /* ContentView.swift in Sources */, 73A464042A1C3B3400BA8528 /* AppAttestExampleApp.swift in Sources */, ); diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift index a7f4c1df..46157e46 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift +++ b/Samples/Swift/AppAttestExample/AppAttestExample/AppAttestExampleApp.swift @@ -23,11 +23,12 @@ class AppDelegate: NSObject, UIApplicationDelegate { didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil ) -> Bool { #if targetEnvironment(simulator) - guard let apiKey = Bundle.main.infoDictionary!["APP_CHECK_WEB_API_KEY"] as? String else { - print("Failed to get App_Check_WEB_API_KEY from Bundle.") + let secretReader = AppCheckSecretReader() + guard let APIKey = secretReader.APIKey else { + print("Unable to read API key from bundle or environment") return true } - GIDSignIn.sharedInstance.configureDebugProvider(withAPIKey: apiKey) { error in + GIDSignIn.sharedInstance.configureDebugProvider(withAPIKey: APIKey) { error in if let error { print("Error configuring `GIDSignIn` for Firebase App Check: \(error)") } diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/AppCheckSecretReader.swift b/Samples/Swift/AppAttestExample/AppAttestExample/AppCheckSecretReader.swift new file mode 100644 index 00000000..bdcab6f1 --- /dev/null +++ b/Samples/Swift/AppAttestExample/AppAttestExample/AppCheckSecretReader.swift @@ -0,0 +1,44 @@ +/* + * Copyright 2023 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 + +struct AppCheckSecretReader { + private let APIKeyName = "APP_CHECK_WEB_API_KEY" + + var APIKey: String? { + return APIKeyFromBundle ?? APIKeyFromEnvironment + } + + /// Method for retrieving API key from environment variable used during CI tests + private var APIKeyFromEnvironment: String? { + guard let APIKey = ProcessInfo.processInfo.environment[APIKeyName], !APIKey.isEmpty else { + print("Failed to get \(APIKeyName) from environment.") + return nil + } + return APIKey + } + + /// Method for retrieving API key from the bundle during simulator or debug builds + private var APIKeyFromBundle: String? { + guard let APIKey = Bundle.main.infoDictionary?[APIKeyName] as? String, + !APIKey.isEmpty else { + print("Failed to get \(APIKeyName) from Bundle.") + return nil + } + return APIKey + } +} diff --git a/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist b/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist index 7d161f2d..e8f329f4 100644 --- a/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist +++ b/Samples/Swift/AppAttestExample/AppAttestExample/Info.plist @@ -10,14 +10,14 @@ CFBundleTypeRole Editor CFBundleURLName - com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj + com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h CFBundleURLSchemes - com.googleusercontent.apps.7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj + com.googleusercontent.apps.665845761721-a9g0c1k6buv131av6nnmburou5scd63h GIDClientID - 7094936827-l0b7c7l10jdbooi6r8s10ffq59ek04sj.apps.googleusercontent.com + 665845761721-a9g0c1k6buv131av6nnmburou5scd63h.apps.googleusercontent.com From 59c92de459a7f3d8538b0c73335cc929095a7c51 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Thu, 7 Sep 2023 15:40:08 -0700 Subject: [PATCH 25/28] Update GoogleSignIn.podspec dep on AppCheckCore to alpha.8 --- GoogleSignIn.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleSignIn.podspec b/GoogleSignIn.podspec index 697f5177..5d422891 100644 --- a/GoogleSignIn.podspec +++ b/GoogleSignIn.podspec @@ -33,7 +33,7 @@ The Google Sign-In SDK allows users to sign in with their Google account from th ] s.ios.framework = 'UIKit' s.osx.framework = 'AppKit' - s.dependency 'AppCheckCore', '~> 0.1.0-alpha.6' + s.dependency 'AppCheckCore', '~> 0.1.0-alpha.8' s.dependency 'AppAuth', '~> 1.6' s.dependency 'GTMAppAuth', '~> 4.0' s.dependency 'GTMSessionFetcher/Core', '>= 1.1', '< 4.0' From d966e2b91f53292ea6ace8b57ecd7665d89f27d4 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 8 Sep 2023 13:09:37 -0700 Subject: [PATCH 26/28] Update nullability declarations for token --- .../Implementations/Fake/GIDAppCheckProviderFake.h | 3 ++- .../Implementations/Fake/GIDAppCheckProviderFake.m | 5 ++--- .../Sources/GIDAppCheck/Implementations/GIDAppCheck.h | 6 ++---- .../Sources/GIDAppCheck/Implementations/GIDAppCheck.m | 3 +-- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 2 +- GoogleSignIn/Tests/Unit/GIDAppCheckTest.m | 6 +++--- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h index 2f0d64b8..ab6fe5de 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h @@ -31,7 +31,8 @@ NS_CLASS_AVAILABLE_IOS(14) /// error. /// /// @param token The `GACAppCheckToken` instance to pass into the completion called from -/// `getTokenWithCompletion:`. +/// `getTokenWithCompletion:`. Use `nullable` if you would like a placeholder token from +/// AppCheckCore. /// @param error The `NSError` to pass into the completion called from /// `getTokenWithCompletion:`. - (instancetype)initWithAppCheckToken:(nullable GACAppCheckToken *)token diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m index 6ca88bc0..903fc3ff 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.m @@ -38,14 +38,13 @@ - (instancetype)initWithAppCheckToken:(nullable GACAppCheckToken *)token return self; } -- (void)getTokenWithCompletion:(void (^)(GACAppCheckToken * _Nullable, - NSError * _Nullable))handler { +- (void)getTokenWithCompletion:(void (^)(GACAppCheckToken *, NSError * _Nullable))handler { dispatch_async(dispatch_get_main_queue(), ^{ handler(self.token, self.error); }); } -- (void)getLimitedUseTokenWithCompletion:(void (^)(GACAppCheckToken * _Nullable, +- (void)getLimitedUseTokenWithCompletion:(void (^)(GACAppCheckToken *, NSError * _Nullable))handler { dispatch_async(dispatch_get_main_queue(), ^{ handler(self.token, self.error); diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h index 2fe81e0e..6b7d1d92 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h @@ -61,11 +61,9 @@ NS_CLASS_AVAILABLE_IOS(14) /// Fetches the limited use Firebase token. /// -/// @param completion A `nullable` callback with the `FIRAppCheckToken` if present, or an `NSError` -/// otherwise. +/// @param completion A `nullable` callback with the `FIRAppCheckToken`, or an `NSError` otherwise. - (void)getLimitedUseTokenWithCompletion: - (nullable void (^)(GACAppCheckToken * _Nullable token, - NSError * _Nullable error))completion; + (nullable void (^)(GACAppCheckToken *token, NSError * _Nullable error))completion; /// Whether or not the App Attest key ID created and the attestation object has been fetched. - (BOOL)isPrepared; diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m index cfc8d4ff..7ac20947 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.m @@ -36,8 +36,7 @@ static NSString *const kGIDAppAttestBaseURL = @"https://firebaseappcheck.googleapis.com/v1beta"; typedef void (^GIDAppCheckPrepareCompletion)(NSError * _Nullable); -typedef void (^GIDAppCheckTokenCompletion)(GACAppCheckToken * _Nullable, - NSError * _Nullable); +typedef void (^GIDAppCheckTokenCompletion)(GACAppCheckToken *,NSError * _Nullable); @interface GIDAppCheck () diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 5702fca1..82655ca8 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -79,7 +79,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { - (void)configureWithCompletion:(nullable void (^)(NSError * _Nullable error))completion NS_SWIFT_NAME(configure(completion:)); -/// Configures `GIDSignIn` for use. +/// Configures `GIDSignIn` for use in debug or test environments. /// /// @param APIKey The API Key to use during configuration of the App Check debug provider. /// @param completion A nullable callback block passing back any error arising from the diff --git a/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m b/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m index 8ba90887..7c0610ae 100644 --- a/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m +++ b/GoogleSignIn/Tests/Unit/GIDAppCheckTest.m @@ -57,10 +57,10 @@ - (void)testGetLimitedUseTokenFailureReturnsPlaceholder { GIDAppCheck *appCheck = [[GIDAppCheck alloc] initWithAppCheckProvider:fakeProvider userDefaults:self.userDefaults]; - [appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken * _Nullable token, + [appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken *token, NSError * _Nullable error) { - XCTAssertNotNil(token); // If there is an error, we expect a placeholder token XCTAssertEqualObjects(expectedError, error); + XCTAssertNotNil(token); // If there is an error, we expect a placeholder token [tokenFailExpectation fulfill]; }]; @@ -126,7 +126,7 @@ - (void)testGetLimitedUseTokenSucceeds { XCTestExpectation *getLimitedUseTokenSucceedsExpectation = [self expectationWithDescription:@"getLimitedUseToken should succeed"]; - [appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken * _Nullable token, + [appCheck getLimitedUseTokenWithCompletion:^(GACAppCheckToken *token, NSError * _Nullable error) { XCTAssertNil(error); XCTAssertNotNil(token); From 53afe334c4e392579d8bfee6779ccf636ca03e31 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 8 Sep 2023 14:58:45 -0700 Subject: [PATCH 27/28] Replace nullable with nil in doc comment --- .../GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h index ab6fe5de..e294273f 100644 --- a/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h +++ b/GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h @@ -31,7 +31,7 @@ NS_CLASS_AVAILABLE_IOS(14) /// error. /// /// @param token The `GACAppCheckToken` instance to pass into the completion called from -/// `getTokenWithCompletion:`. Use `nullable` if you would like a placeholder token from +/// `getTokenWithCompletion:`. Use `nil` if you would like a placeholder token from /// AppCheckCore. /// @param error The `NSError` to pass into the completion called from /// `getTokenWithCompletion:`. From b89114f19487bb29c861c5781ef0110471b0b5d3 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Fri, 8 Sep 2023 15:14:34 -0700 Subject: [PATCH 28/28] Update to AppCheckCore alpha.9 --- GoogleSignIn.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleSignIn.podspec b/GoogleSignIn.podspec index 5d422891..3f1c9488 100644 --- a/GoogleSignIn.podspec +++ b/GoogleSignIn.podspec @@ -33,7 +33,7 @@ The Google Sign-In SDK allows users to sign in with their Google account from th ] s.ios.framework = 'UIKit' s.osx.framework = 'AppKit' - s.dependency 'AppCheckCore', '~> 0.1.0-alpha.8' + s.dependency 'AppCheckCore', '~> 0.1.0-alpha.9' s.dependency 'AppAuth', '~> 1.6' s.dependency 'GTMAppAuth', '~> 4.0' s.dependency 'GTMSessionFetcher/Core', '>= 1.1', '< 4.0'