Skip to content

Commit 1036cab

Browse files
authored
Merge branch 'main' into main
2 parents e467696 + 7d91611 commit 1036cab

7 files changed

Lines changed: 62 additions & 17 deletions

File tree

.github/workflows/pr_notification.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ jobs:
1111
- name: Pull Request Details
1212
run: |
1313
echo "Pull Request: ${{ github.event.pull_request.number }}"
14-
echo "Author: ${{ github.event.pull_request.user.login }}"
14+
echo "Author: ${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}"
15+
env:
16+
GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }}
1517

1618
- name: Google Chat Notification
1719
shell: bash
1820
env:
1921
TITLE: ${{ github.event.pull_request.title }}
2022
LABELS: ${{ join(github.event.pull_request.labels.*.name, ', ') }}
23+
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
24+
GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }}
25+
GITHUB_EVENT_PULL_REQUEST_HTML_URL: ${{ github.event.pull_request.html_url }}
2126
run: |
2227
curl --location --request POST '${{ secrets.WEBHOOK_URL }}' \
2328
--header 'Content-Type: application/json' \
@@ -34,7 +39,7 @@ jobs:
3439
{
3540
"keyValue": {
3641
"topLabel": "Repo",
37-
"content": "${{ github.event.pull_request.head.repo.full_name }}"
42+
"content": "${GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME}"
3843
}
3944
},
4045
{
@@ -46,7 +51,7 @@ jobs:
4651
{
4752
"keyValue": {
4853
"topLabel": "Creator",
49-
"content": "${{ github.event.pull_request.user.login }}"
54+
"content": "${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}"
5055
}
5156
},
5257
{
@@ -80,7 +85,7 @@ jobs:
8085
"text": "Open Pull Request",
8186
"onClick": {
8287
"openLink": {
83-
"url": "${{ github.event.pull_request.html_url }}"
88+
"url": "${GITHUB_EVENT_PULL_REQUEST_HTML_URL}"
8489
}
8590
}
8691
}

.github/workflows/push_notification.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ jobs:
1414
- name: Main Branch Push
1515
run: |
1616
echo "Workflow initiated by event with name: ${{ github.event_name }}"
17-
echo "Pushing commit to main: ${{ github.event.head_commit.id }}"
18-
echo "Pushed by: ${{ github.event.pusher.name }}"
17+
echo "Pushing commit to main: ${GITHUB_EVENT_HEAD_COMMIT_ID}"
18+
echo "Pushed by: ${GITHUB_EVENT_PUSHER_NAME}"
19+
env:
20+
GITHUB_EVENT_HEAD_COMMIT_ID: ${{ github.event.head_commit.id }}
21+
GITHUB_EVENT_PUSHER_NAME: ${{ github.event.pusher.name }}
1922

2023
- name: Push Notification to Google Chat
2124
run: |
@@ -34,13 +37,13 @@ jobs:
3437
{
3538
"keyValue": {
3639
"topLabel": "Repo",
37-
"content": "${{ github.event.repository.full_name }}"
40+
"content": "${GITHUB_EVENT_REPOSITORY_FULL_NAME}"
3841
}
3942
},
4043
{
4144
"keyValue": {
4245
"topLabel": "Committed by",
43-
"content": "${{ github.event.head_commit.author.username }}"
46+
"content": "${GITHUB_EVENT_HEAD_COMMIT_AUTHOR_USERNAME}"
4447
}
4548
},
4649
{
@@ -50,7 +53,7 @@ jobs:
5053
"text": "Ref comparison",
5154
"onClick": {
5255
"openLink": {
53-
"url": "${{ github.event.compare }}"
56+
"url": "${GITHUB_EVENT_COMPARE}"
5457
}
5558
}
5659
}
@@ -63,4 +66,8 @@ jobs:
6366
}
6467
]
6568
}'
69+
env:
70+
GITHUB_EVENT_REPOSITORY_FULL_NAME: ${{ github.event.repository.full_name }}
71+
GITHUB_EVENT_HEAD_COMMIT_AUTHOR_USERNAME: ${{ github.event.head_commit.author.username }}
72+
GITHUB_EVENT_COMPARE: ${{ github.event.compare }}
6673

GoogleSignIn/Sources/GIDSignIn.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@
120120
// Error string for user cancelations.
121121
static NSString *const kUserCanceledError = @"The user canceled the sign-in flow.";
122122

123-
// User preference key to detect fresh install of the app.
124-
static NSString *const kAppHasRunBeforeKey = @"GID_AppHasRunBefore";
123+
NSString *const kAppHasRunBeforeKey = @"GID_AppHasRunBefore";
125124

126125
// Maximum retry interval in seconds for the fetcher.
127126
static const NSTimeInterval kFetcherMaxRetryInterval = 15.0;
@@ -672,6 +671,11 @@ - (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore
672671

673672
// Check to see if the 3P app is being run for the first time after a fresh install.
674673
BOOL isFreshInstall = [self isFreshInstall];
674+
675+
// If this is a fresh install, ensure that any pre-existing keychain data is purged.
676+
if (isFreshInstall) {
677+
[self removeAllKeychainEntries];
678+
}
675679

676680
NSString *authorizationEnpointURL = [NSString stringWithFormat:kAuthorizationURLTemplate,
677681
[GIDSignInPreferences googleAuthorizationServer]];

GoogleSignIn/Sources/GIDSignIn_Private.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN
3232
@class GIDAppCheck;
3333
@class GIDAuthStateMigration;
3434

35+
/// User preference key to detect fresh install of the app.
36+
extern NSString *const kAppHasRunBeforeKey;
37+
3538
/// Represents a completion block that takes a `GIDSignInResult` on success or an error if the
3639
/// operation was unsuccessful.
3740
typedef void (^GIDSignInCompletion)(GIDSignInResult *_Nullable signInResult,

GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,4 @@
2525
#import "GIDToken.h"
2626
#import "GIDSignInResult.h"
2727
#import "GIDClaim.h"
28-
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
2928
#import "GIDSignInButton.h"
30-
#endif

GoogleSignIn/Tests/Unit/GIDSignInTest.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@
120120
@"com.google.UnitTests:///emmcallback?action=unrecognized";
121121
static NSString * const kDevicePolicyAppBundleID = @"com.google.DevicePolicy";
122122

123-
static NSString * const kAppHasRunBeforeKey = @"GPP_AppHasRunBefore";
124-
125123
static NSString * const kFingerprintKeychainName = @"fingerprint";
126124
static NSString * const kVerifierKeychainName = @"verifier";
127125
static NSString * const kVerifierKey = @"verifier";
@@ -1212,6 +1210,19 @@ - (void)testNotHandleWrongPath {
12121210
XCTAssertFalse(_completionCalled, @"should not call delegate");
12131211
}
12141212

1213+
#pragma mark - Test Fresh Install
1214+
1215+
- (void)testFreshInstall_removesKeychainEntries {
1216+
// Simulate that the app has been deleted and user defaults removed.
1217+
[NSUserDefaults.standardUserDefaults removeObjectForKey:kAppHasRunBeforeKey];
1218+
// Initialization should check `isFreshInstall`.
1219+
GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:_keychainStore
1220+
authStateMigrationService:_authStateMigrationService];
1221+
// If `isFreshInstall`, keychain entries should be removed.
1222+
XCTAssertNotNil(signIn);
1223+
XCTAssertTrue(self->_keychainRemoved);
1224+
}
1225+
12151226
#pragma mark - Tests - disconnectWithCallback:
12161227

12171228
// Verifies disconnect calls callback with no errors if access token is present.

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ Google Sign-In allows your users to sign-in to your native macOS app using their
4848
and default browser. When building for macOS, the `signInWithConfiguration:` and `addScopes:`
4949
methods take a `presentingWindow:` parameter in place of `presentingViewController:`. Note that
5050
in order for your macOS app to store credentials via the Keychain on macOS, you will need to add
51-
`$(AppIdentifierPrefix)$(CFBundleIdentifier)` to its keychain access group.
51+
`$(AppIdentifierPrefix)$(CFBundleIdentifier)` as the first item in its keychain access group.
5252

5353
### Mac Catalyst
5454

5555
Google Sign-In also supports iOS apps that are built for macOS via
5656
[Mac Catalyst](https://developer.apple.com/mac-catalyst/). In order for your Mac Catalyst app
5757
to store credentials via the Keychain on macOS, you will need to add
58-
`$(AppIdentifierPrefix)$(CFBundleIdentifier)` to its keychain access group.
58+
`$(AppIdentifierPrefix)$(CFBundleIdentifier)` as the first item in the keychain
59+
access group.
5960

6061
## Using the Google Sign-In Button
6162

@@ -107,3 +108,19 @@ let signInButton = GoogleSignInButton {
107108
}
108109
let hostedButton = NSHostingView(rootView: signInButton)
109110
```
111+
112+
## A Note on iOS Keychain Access Groups
113+
114+
GSI uses your default (first listed) keychain access group. If you don't add a
115+
custom keychain access group, the default keychain access group is provided by
116+
Xcode and looks like `$(AppIdentifierPrefix)$(CFBundleIdentifier)`.
117+
118+
GSI [removes keychain items upon fresh install](https://github.com/google/GoogleSignIn-iOS/pull/567)
119+
to ensure that stale credentials from previous installs of your app are not
120+
mistakenly used. If your app uses a shared access group by default this may
121+
lead to new installs of apps sharing the same keychain access group to remove
122+
keychain credentials for apps already installed.
123+
124+
To prevent unintentional credential removal, you can explicitly list the
125+
typical default access group (or whatever you prefer so long as it is not
126+
shared) in your list first. GSI, will then use that default access group.

0 commit comments

Comments
 (0)