-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[google_sign_in] Fix iOS sever auth codes #10021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[google_sign_in] Fix iOS sever auth codes #10021
Conversation
Fixes an issue where `serverAuthorizationTokensForScopes` would usually return the results of `getRefreshedAuthorizationTokens` directly, even though `getRefreshedAuthorizationTokens` will never include a server auth code. Now, the server auth code is cached when it is returned from authn steps, so that it can be returned when it is requested, since those are different APIs in this plugin (unlike the underlying SDK on iOS). Fixes flutter/flutter#175313
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request fixes an issue on iOS where serverAuthorizationTokensForScopes would incorrectly return null. The fix introduces caching for the server authorization code, ensuring it's available for later calls. The implementation is sound, correctly handling user changes by associating the cached code with a user ID. The accompanying tests are thorough, covering the new caching logic and various edge cases. I've added one suggestion to improve the readability of a new test case.
packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart
Outdated
Show resolved
Hide resolved
|
|
||
| /// The user identifier for the cached server auth code, to ensure that a | ||
| /// cached code isn't returned across users. | ||
| String? _cachedServerAuthCodeUserId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache doesn't seem to be invalidated on logout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! For signOut it's probably harmless since the grant should still be active, but it definitely shouldn't be returned after disconnect, and since I can't think of any reason someone should expect to get it after signOut I'll go ahead and clear it there.
Also added cache unit tests for both signOut and disconnect that would have caught this.
LongCatIsLooong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment regarding cache invalidation otherwise LGTM.
flutter/packages@f2a65fd...3d5c419 2025-09-19 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump camerax_version from 1.5.0-rc01 to 1.5.0 in /packages/camera/camera_android_camerax/android (flutter/packages#10009) 2025-09-18 stuartmorgan@google.com [google_sign_in] Fix iOS sever auth codes (flutter/packages#10021) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#175668) flutter/packages@f2a65fd...3d5c419 2025-09-19 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump camerax_version from 1.5.0-rc01 to 1.5.0 in /packages/camera/camera_android_camerax/android (flutter/packages#10009) 2025-09-18 stuartmorgan@google.com [google_sign_in] Fix iOS sever auth codes (flutter/packages#10021) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes an issue where
serverAuthorizationTokensForScopeswould usually return the results ofgetRefreshedAuthorizationTokensdirectly, even thoughgetRefreshedAuthorizationTokenswill never include a server auth code. Now, the server auth code is cached when it is returned from authn steps, so that it can be returned when it is requested, since those are different APIs in this plugin (unlike the underlying SDK on iOS).Fixes flutter/flutter#175313
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3