-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[google_sign_in] Enable FedCM for web. Use token expiration. (#5225)
* Enables [**FedCM API**](https://developer.mozilla.org/en-US/docs/Web/API/FedCM_API) on compatible browsers. * The GIS JS SDK falls-back to the JS implementation on browsers that don't support the new standard. See [migration instructions](https://developers.google.com/identity/gsi/web/guides/fedcm-migration)). * Uses the supplied token expiration information to **more accurately compute `isSignedIn()` and `canAccessScopes(scopes)`**. * This does not handle the case where users sign in/out in another tab or from outside the web app, that's still something that needs to be checked server-side. * **Deprecates the `signIn()` method on the web.** * Users should migrate to a combination of `renderButton()` and `silentSignIn()`, as described [here](https://pub.dev/packages/google_sign_in_web#migrating-to-v011-and-v012-google-identity-services). ### Issues * FedCM: * Fixes flutter/flutter#133703 (once rebuilt/redeployed) * Fixes `b/301259123` * Token expiration: * Unblocks `b/245740319` ### Testing * Added a few unit tests * Manually verified token expiration: https://dit-gis-test.web.app
- Loading branch information
Showing
6 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ final CredentialResponse minimalCredential = | |
'credential': minimalJwtToken, | ||
}); | ||
|
||
final CredentialResponse expiredCredential = | ||
jsifyAs<CredentialResponse>(<String, Object?>{ | ||
'credential': expiredJwtToken, | ||
}); | ||
|
||
/// A JWT token with predefined values. | ||
/// | ||
/// 'email': '[email protected]', | ||
|
@@ -55,11 +60,30 @@ const String minimalJwtToken = | |
|
||
/// The payload of a JWT token that contains only non-nullable values. | ||
/// | ||
/// "email": "[email protected]", | ||
/// "sub": "123456" | ||
/// 'email': '[email protected]', | ||
/// 'sub': '123456' | ||
const String minimalPayload = | ||
'eyJlbWFpbCI6ImFkdWx0bWFuQGV4YW1wbGUuY29tIiwic3ViIjoiMTIzNDU2In0'; | ||
|
||
/// A JWT token with minimal set of predefined values and an expiration timestamp. | ||
/// | ||
/// 'email': '[email protected]', | ||
/// 'sub': '123456', | ||
/// 'exp': 1430330400 | ||
/// | ||
/// Signed with HS256 and the private key: 'symmetric-encryption-is-weak' | ||
const String expiredJwtToken = | ||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.$expiredPayload.--gb5tnVSSsLg4zjjVH0FUUvT4rbehIcnBhB-8Iekm4'; | ||
|
||
/// The payload of a JWT token that contains only non-nullable values, and an | ||
/// expiration timestamp of 1430330400 (Wednesday, April 29, 2015 6:00:00 PM UTC) | ||
/// | ||
/// 'email': '[email protected]', | ||
/// 'sub': '123456', | ||
/// 'exp': 1430330400 | ||
const String expiredPayload = | ||
'eyJlbWFpbCI6ImFkdWx0bWFuQGV4YW1wbGUuY29tIiwic3ViIjoiMTIzNDU2IiwiZXhwIjoxNDMwMzMwNDAwfQ'; | ||
|
||
// More encrypted JWT Tokens may be created on https://jwt.io. | ||
// | ||
// First, decode the `goodJwtToken` above, modify to your heart's | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters