amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

No upgrade path for custom auth.storage configuration

Open jfloodnet opened this issue 1 year ago • 4 comments

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

None

Environment information

# Put output below this line


Describe the bug

Hi, so I'm going through the upgrade for v5 to v6. Was a lot of work to just get it to the point that I could attempt to run anything.

However, there is no upgrade path for people who used a "custom storage" provider for auth.

Please see the v5 definition for Auth config: https://docs.amplify.aws/gen1/javascript/prev/tools/libraries/configure-categories/

image

Expected behavior

v6 would offer some equivalent method of customising the storage of tokens and attributes

Reproduction steps

Migrate v5 to v6

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

export default {
    Auth: {

        // identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',

        region: region,

        // identityPoolRegion: 'XX-XXXX-X',

        userPoolId: userPoolId,

        userPoolWebClientId: appClientId,

        identityPoolId: identityPoolId,

        providerKey: `cognito-idp.${region}.amazonaws.com/${userPoolId}`,

        mandatorySignIn: true,

        storage: CustomUserStorage,
    }
}

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

jfloodnet avatar Aug 21 '24 06:08 jfloodnet

If there is an alternative api provided in v6, please provide documentation on how one could migrate their custom storage implementation to it.

jfloodnet avatar Aug 21 '24 06:08 jfloodnet

Hey @jfloodnet. Thank you for upgrading to v6. You can provide your own Storage mechanism by implementing the KeyValueStorageInterface interface. You can find the Custom Storage section in the following documentation

israx avatar Aug 21 '24 12:08 israx

Thank you @israx I think you could add something to the migration docs https://docs.amplify.aws/gen1/react/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/

The current docs don't do a great job of instructing how to actually upgrade the config. It points you to to where you can see the v6 config schema, but you're then on your own.

image

Once we've arrived here, you hit a dead end https://docs.amplify.aws/gen1/react/build-a-backend/auth/set-up-auth/#set-up-and-configure-amplify-auth

Even a little note in the v6 auth config section that hints that this custom storage api is registered via a different method in v6 and point the user to the link you gave me.

image

jfloodnet avatar Aug 21 '24 12:08 jfloodnet

Thanks @jfloodnet for bringing this up. I created a task in our backlog to add specific documentation to migrate the use cases of Amplify.configure in v5.

israx avatar Aug 21 '24 13:08 israx

@jfloodnet, thanks again for creating this issue. We'll be tracking the docs improvement within the above linked docs issue #7981. Feel free to follow that for updates on when the docs update gets merged in, but I'll back to this issue with a comment when it's complete as well.

cwomack avatar Sep 24 '24 20:09 cwomack