-
Notifications
You must be signed in to change notification settings - Fork 258
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
Migrate to amplify_auth_cognito with credentials present #593
Comments
We do not currently have this feature, but I'm marking this as a request to get it into the backlog. |
Hello, we are developing an application that also needs this feature, as our application (apart from the normal cognito auth flow) uses other kind of login that is performed in a backend using the cognito admin sdk that returns the cognito access tokens.
|
Hi !
This should only be done once on the first launch after the migration. Note that in next version |
Version 1.0 still allows for a custom SecureStorage impl. The API did change during developer preview though. You can see the docs for an example of how to implement your own version of secure storage. See: https://docs.amplify.aws/lib/auth/managing_credentials/q/platform/flutter/ This is NOT intended to be used to migrate with existing credentials. The purpose of allowing consumers to implement a custom SecureStorage impl is to change where sensitive data is persisted. The docs show an example of how to use an in memory implementation to avoid persisting credentials. The keys used to store credentials could change in the future, so implementations should not depend on specific key names or any other internal details. |
If I am not mistaken, what has changed (justified for security reason I guess) in the next.8 (and so probably in the 1.0), is the ability to easily inherit of AmplifySecureStorage, which is helpful to avoid changing how the credentials are store by default by amplify (using device secure storage), and guarantee that once the migration is done, it works exactly like it would have without the migration code. |
While I agree it is theoretically possible, I highly recommend against using this to migrate credentials as it would require relying on the internal implementation details of Auth (particularly the key names), and those implementation details could change at any point as they are not part of the public API. I also highly recommend against using any preview (*.next.x) version of amplify in production. We have released 1.0.0 which is stable. There are known breaking changes between some of the preview versions and the first stable version. Some of those breaking changes include changes in how credentials are stored, and there is no credential migration guarantees between preview versions. Amplify Auth will automatically migrate credentials between all stable versions. For example, from v0.6.x to v1.0.0. The changes around AmplifySecureStorage in next.8 (and later 1.0.0) had a few purposes
// old api
await Amplify.addPlugin(
AmplifyAuthCognito(
credentialStorage: AmplifySecureStorage(
scope: 'awsCognitoAuthPlugin', // <- this was a required argument, and if it ever changed, data would be lost.
webOptions: WebSecureStorageOptions(
persistenceOption: WebPersistenceOption.inMemory,
),
),
),
);
// current api - no scope required.
await Amplify.addPlugin(
AmplifyAuthCognito(
secureStorageFactory: AmplifySecureStorage.factoryFrom(
webOptions: WebSecureStorageOptions(
persistenceOption: WebPersistenceOption.inMemory,
),
),
),
); |
Thanks for the explanation and all the details. As I said, I neither recommand to do this but at the same time I haven't seen a better workaround to allow to migrate to the amplify lib without disconnecting all the users. |
I don't believe so |
Any updates on this one? Right now, I am doing a kinda of a hack: calling |
Hi!
Is it possible to "silently" initiate a user session given a valid
userId
,accessToken
,idToken
andrefreshToken
, possibly also for federated (apple) sign in?We are exploring migrating to the official libs but do not necessarily want to prompt users to sign in again.
The text was updated successfully, but these errors were encountered: