Skip to content

Commit 0f00694

Browse files
committed
Merge branch 'main' into mdmathias/async-support
2 parents 0d1f63d + f434473 commit 0f00694

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2190
-1555
lines changed

.github/workflows/builds.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Build GSI for Valid Architectures
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
49
schedule:
510
- cron: '0 8 * * *' # Cron uses UTC; run at nightly at midnight PST
611

.github/workflows/tests.yml renamed to .github/workflows/unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: tests
1+
name: unit_tests
22

33
on:
44
push:

GoogleSignIn.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'GoogleSignIn'
3-
s.version = '6.2.4'
3+
s.version = '7.0.0'
44
s.summary = 'Enables iOS apps to sign in with Google.'
55
s.description = <<-DESC
66
The Google Sign-In SDK allows users to sign in with their Google account from third-party apps.
@@ -12,7 +12,7 @@ The Google Sign-In SDK allows users to sign in with their Google account from th
1212
:git => 'https://github.com/google/GoogleSignIn-iOS.git',
1313
:tag => s.version.to_s
1414
}
15-
ios_deployment_target = '9.0'
15+
ios_deployment_target = '10.0'
1616
osx_deployment_target = '10.15'
1717
s.ios.deployment_target = ios_deployment_target
1818
s.osx.deployment_target = osx_deployment_target
@@ -33,8 +33,8 @@ The Google Sign-In SDK allows users to sign in with their Google account from th
3333
s.ios.framework = 'UIKit'
3434
s.osx.framework = 'AppKit'
3535
s.dependency 'AppAuth', '~> 1.5'
36-
s.dependency 'GTMAppAuth', '~> 1.3'
37-
s.dependency 'GTMSessionFetcher/Core', '>= 1.1', '< 3.0'
36+
s.dependency 'GTMAppAuth', '>= 1.3', '< 3.0'
37+
s.dependency 'GTMSessionFetcher/Core', '>= 1.1', '< 4.0'
3838
s.resource_bundle = {
3939
'GoogleSignIn' => ['GoogleSignIn/Sources/{Resources,Strings}/*']
4040
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <TargetConditionals.h>
18+
19+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
20+
21+
#ifdef SWIFT_PACKAGE
22+
@import GTMAppAuth;
23+
#else
24+
#import <GTMAppAuth/GTMAppAuth.h>
25+
#endif
26+
27+
NS_ASSUME_NONNULL_BEGIN
28+
29+
// A specialized GTMAppAuthFetcherAuthorization subclass with EMM support.
30+
@interface GIDAppAuthFetcherAuthorizationWithEMMSupport : GTMAppAuthFetcherAuthorization
31+
32+
@end
33+
34+
NS_ASSUME_NONNULL_END
35+
36+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <TargetConditionals.h>
18+
19+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
20+
21+
#import "GoogleSignIn/Sources/GIDAppAuthFetcherAuthorizationWithEMMSupport.h"
22+
23+
#import "GoogleSignIn/Sources/GIDEMMSupport.h"
24+
25+
#ifdef SWIFT_PACKAGE
26+
@import AppAuth;
27+
@import GTMAppAuth;
28+
#else
29+
#import <AppAuth/AppAuth.h>
30+
#import <GTMAppAuth/GTMAppAuth.h>
31+
#endif
32+
33+
NS_ASSUME_NONNULL_BEGIN
34+
35+
// The specialized GTMAppAuthFetcherAuthorization delegate that handles potential EMM error
36+
// responses.
37+
@interface GIDAppAuthFetcherAuthorizationEMMChainedDelegate : NSObject
38+
39+
// Initializes with chained delegate and selector.
40+
- (instancetype)initWithDelegate:(id)delegate selector:(SEL)selector;
41+
42+
// The callback method for GTMAppAuthFetcherAuthorization to invoke.
43+
- (void)authentication:(GTMAppAuthFetcherAuthorization *)auth
44+
request:(NSMutableURLRequest *)request
45+
finishedWithError:(nullable NSError *)error;
46+
47+
@end
48+
49+
@implementation GIDAppAuthFetcherAuthorizationEMMChainedDelegate {
50+
// We use a weak reference here to match GTMAppAuthFetcherAuthorization.
51+
__weak id _delegate;
52+
SEL _selector;
53+
// We need to maintain a reference to the chained delegate because GTMAppAuthFetcherAuthorization
54+
// only keeps a weak reference.
55+
GIDAppAuthFetcherAuthorizationEMMChainedDelegate *_retained_self;
56+
}
57+
58+
- (instancetype)initWithDelegate:(id)delegate selector:(SEL)selector {
59+
self = [super init];
60+
if (self) {
61+
_delegate = delegate;
62+
_selector = selector;
63+
_retained_self = self;
64+
}
65+
return self;
66+
}
67+
68+
- (void)authentication:(GTMAppAuthFetcherAuthorization *)auth
69+
request:(NSMutableURLRequest *)request
70+
finishedWithError:(nullable NSError *)error {
71+
[GIDEMMSupport handleTokenFetchEMMError:error completion:^(NSError *_Nullable error) {
72+
if (!self->_delegate || !self->_selector) {
73+
return;
74+
}
75+
NSMethodSignature *signature = [self->_delegate methodSignatureForSelector:self->_selector];
76+
if (!signature) {
77+
return;
78+
}
79+
id argument1 = auth;
80+
id argument2 = request;
81+
id argument3 = error;
82+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
83+
[invocation setTarget:self->_delegate]; // index 0
84+
[invocation setSelector:self->_selector]; // index 1
85+
[invocation setArgument:&argument1 atIndex:2];
86+
[invocation setArgument:&argument2 atIndex:3];
87+
[invocation setArgument:&argument3 atIndex:4];
88+
[invocation invoke];
89+
}];
90+
// Prepare to deallocate the chained delegate instance because the above block will retain the
91+
// iVar references it uses.
92+
_retained_self = nil;
93+
}
94+
95+
@end
96+
97+
@implementation GIDAppAuthFetcherAuthorizationWithEMMSupport
98+
99+
#pragma clang diagnostic push
100+
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
101+
- (void)authorizeRequest:(nullable NSMutableURLRequest *)request
102+
delegate:(id)delegate
103+
didFinishSelector:(SEL)sel {
104+
#pragma clang diagnostic pop
105+
GIDAppAuthFetcherAuthorizationEMMChainedDelegate *chainedDelegate =
106+
[[GIDAppAuthFetcherAuthorizationEMMChainedDelegate alloc] initWithDelegate:delegate
107+
selector:sel];
108+
#pragma clang diagnostic push
109+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
110+
[super authorizeRequest:request
111+
delegate:chainedDelegate
112+
didFinishSelector:@selector(authentication:request:finishedWithError:)];
113+
#pragma clang diagnostic pop
114+
}
115+
116+
- (void)authorizeRequest:(nullable NSMutableURLRequest *)request
117+
completionHandler:(GTMAppAuthFetcherAuthorizationCompletion)handler {
118+
[super authorizeRequest:request completionHandler:^(NSError *_Nullable error) {
119+
[GIDEMMSupport handleTokenFetchEMMError:error completion:^(NSError *_Nullable error) {
120+
handler(error);
121+
}];
122+
}];
123+
}
124+
125+
@end
126+
127+
NS_ASSUME_NONNULL_END
128+
129+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Tests/Unit/GIDAuthentication+Testing.h renamed to GoogleSignIn/Sources/GIDAuthentication.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Google LLC
2+
* Copyright 2022 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,12 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDAuthentication.h"
17+
#import <Foundation/Foundation.h>
1818

19-
@interface GIDAuthentication (Testing)
19+
@class OIDAuthState;
2020

21-
- (BOOL)isEqual:(id)object;
22-
- (BOOL)isEqualToAuthentication:(GIDAuthentication *)other;
23-
- (NSUInteger)hash;
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
// Internal class for GIDGoogleUser NSCoding backward compatibility.
24+
@interface GIDAuthentication : NSObject <NSSecureCoding>
25+
26+
@property(nonatomic) OIDAuthState* authState;
27+
28+
- (instancetype)initWithAuthState:(OIDAuthState *)authState;
2429

2530
@end
31+
32+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)