Skip to content
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

AWSMobileClient._showSignIn calls addSignInProvider multiple times for each call to AWSMobileClient.getInstance().showSignIn #766

Closed
BillBunting opened this issue Mar 5, 2019 · 4 comments
Assignees
Labels
cognito Issues with the AWS Android SDK for Cognito feature-request Request a new feature mobile client Issues with AWS Mobile's client-side Cognito wrapper pending-release Code has been merged but pending release

Comments

@BillBunting
Copy link
Contributor

BillBunting commented Mar 5, 2019

Describe the bug

Minor bug, if a bug at all.

Make one call to AWSMobileClient.getInstance().initialize then for each call to AWSMobileClient.getInstance().showSignIn, each call to identityManager.addSignInProvider results to adding the sign in provider multiple times. So, when an app calls AWSMobileClient.getInstance().SignOut() then repeats the call to SignIn() the class is added to the list again.

If using awsconfiguration.json, the sign in provider will also already be added so there are two right from the start.

To Reproduce
call AWSMobileClient.getInstance().SignIn(... followed by calls to SignOut then in again or for any reason call SignIn again.

Observe log output of an increasing number of Facebook calls for each iteration of sign out and sign in.

/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook provider sign-in succeeded.
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode =
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode =
/FacebookSignInProvider: Facebook provider signing out...
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook provider sign-in succeeded.
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode = -
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode = -
/FacebookSignInProvider: Facebook provider signing out...
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook provider sign-in succeeded.
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode =
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode =
/FacebookSignInProvider: Facebook provider signing out...
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook SDK initialization completed
/FacebookSignInProvider: Facebook provider sign-in succeeded.
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode =
/FacebookSignInProvider: Facebook Access Token is OK. Token hashcode =

From AWSMobileClient.java in context.

if (isConfigurationKeyPresent(USER_POOLS)) {
                        authUIConfigBuilder.userPools(true);
                        identityManager.addSignInProvider(CognitoUserPoolsSignInProvider.class); **HERE**
                    }

                    if (isConfigurationKeyPresent(FACEBOOK)) {
                        authUIConfigBuilder.signInButton(FacebookButton.class);
                        identityManager.addSignInProvider(FacebookSignInProvider.class);  **HERE**! 
                    }

                    if (isConfigurationKeyPresent(GOOGLE)) {
                        authUIConfigBuilder.signInButton(GoogleButton.class);
                        identityManager.addSignInProvider(GoogleSignInProvider.class); **HERE** ! 
                    }
private Runnable _showSignIn(final Activity callingActivity,
                                 final SignInUIOptions signInUIOptions,
                                 final Callback<UserStateDetails> callback) {

        return new Runnable() {
            @Override
            public void run() {
                synchronized (showSignInLockObject) {
                    UserState userState = getUserStateDetails(false).getUserState();
                    if (UserState.SIGNED_IN.equals(userState)) {
                        callback.onError(new RuntimeException("Called showSignIn while user is already signed-in"));
                        return;
                    }

                    final AuthUIConfiguration.Builder authUIConfigBuilder = new AuthUIConfiguration.Builder()
                            .canCancel(signInUIOptions.canCancel())
                            .isBackgroundColorFullScreen(false);

                    if (signInUIOptions.getLogo() != null) {
                        authUIConfigBuilder.logoResId(signInUIOptions.getLogo());
                    }
                    if (signInUIOptions.getBackgroundColor() != null) {
                        authUIConfigBuilder.backgroundColor(signInUIOptions.getBackgroundColor());
                    }

                    final IdentityManager identityManager = IdentityManager.getDefaultIdentityManager();

                    if (isConfigurationKeyPresent(USER_POOLS)) {
                        authUIConfigBuilder.userPools(true);
                        identityManager.addSignInProvider(CognitoUserPoolsSignInProvider.class);
                    }

                    if (isConfigurationKeyPresent(FACEBOOK)) {
                        authUIConfigBuilder.signInButton(FacebookButton.class);
                        identityManager.addSignInProvider(FacebookSignInProvider.class);
                    }

                    if (isConfigurationKeyPresent(GOOGLE)) {
                        authUIConfigBuilder.signInButton(GoogleButton.class);
                        identityManager.addSignInProvider(GoogleSignInProvider.class);
                    }

                    Class<? extends Activity> nextActivityClass =
                            signInUIOptions.nextActivity() == null ?
                                callingActivity.getClass() : signInUIOptions.nextActivity();
                    SignInUI signin = (SignInUI) getClient(mContext, SignInUI.class);
                    signin.login(callingActivity, nextActivityClass)
                            .authUIConfiguration(authUIConfigBuilder.build())
                            .enableFederation(false)
                            .execute();

                    showSignInWaitLatch = new CountDownLatch(1);
                    try {
                        showSignInWaitLatch.await();
                        Log.d(TAG, "run: showSignIn completed");
                    } catch (InterruptedException e) {
                        callback.onError(e);
                    }
                }
            }
        };
    }

Which AWS service(s) are affected?
AWSMobileClient

Expected behavior
Clear the list prior to adding them or just only add them the first time.

Screenshots
N/A

Environment Information (please complete the following information):

  • AWS Android SDK Version: Any
  • Device: [e.g. Pixel XL, Simulator] Any
  • Android Version: Any
  • Specific to simulators: No
@mutablealligator mutablealligator added the mobile client Issues with AWS Mobile's client-side Cognito wrapper label Mar 5, 2019
@mutablealligator mutablealligator self-assigned this Mar 5, 2019
@mutablealligator mutablealligator added the cognito Issues with the AWS Android SDK for Cognito label Mar 5, 2019
@mutablealligator
Copy link
Contributor

@BillBunting Thank you for reporting this to us. Sorry for the inconvenience caused. I am looking into the issue.

@mutablealligator
Copy link
Contributor

@BillBunting A fix for this issue is in the works. We will update here once the fix is released.

@minbi minbi added pending-release Code has been merged but pending release feature-request Request a new feature labels Mar 7, 2019
@minbi
Copy link
Contributor

minbi commented Mar 15, 2019

Hi,

Please see if SDK release 2.12.5 fixes this issue for you.

You may see all changes in the changelog

@BillBunting
Copy link
Contributor Author

@minbi Appears to be resolved in 2.12.5. Thank you.

awsmobilesdk pushed a commit to awsmobilesdk/aws-sdk-android that referenced this issue Apr 12, 2020
awsmobilesdk pushed a commit to awsmobilesdk/aws-sdk-android that referenced this issue Apr 12, 2020
* Secure information stored in SharedPreferences

* Lower aws-android-sdk-core-test compile and target sdk version to 27

* Add a symlink to android-23.jar for core

* Add a gradle task that creates a symlink to android-23.jar for AWS Core

* Fix the gradle task that creates symbolic link to android-23.jar

* Change config.yml to setup android-23

* Enable core, cognitoidentityprovider and cognitoauth integration tests on CircleCI

* Enable core, cognitoidentityprovider and cognitoauth integration tests on CircleCI

* Fix pom.xml

* Improve exception handling in AWSKeyValueStore

* [2.12.3] Bump the patch version of 2.12.z

* Update 2.12.3 CHANGELOG

* Add the missing bucket prefixes to CleanupBucketIntegrationTests

* Fix a bug where migrating expirationDate in CognitoCachingCredentialsProvider crashes

* [2.12.4] Update changelog and bump version

* Annotate code specific to API Level 23 and above in AWSKeyValueStore

* Added API to accept key-value pairs which are appended to the connection username (aws-amplify#765)

The connection username is used as user metadata by the service for the purpose of metrics calculation.

* build android sdk with android-10 (aws-amplify#782)

* Add sign out options

* [MobileClient] Cleanup javadocs and remove unnecessary try..catch blocks

* [MobileClient] Add developer authenticated identities to federatedSignIn fixes aws-amplify#577

* [MobileClient] Add test for developer authenticated idenities federatedSignIn

* [MobileClient] Persist identity id for developer authenticated identities

* [MobileClient] Add AWSMobileClient as client usage tracker in user agent

* [MobileClient] Add device operations; Add error message to ReturningRunnable

* [MobileClient] Add global sign-out functionality

* [MobileClient] Add custom role arn to settings in federated sign-in persistence

* [MobileClient] Add forgot password test; Fix sign out globally test

* [MobileClient] [Userpools] [CognitoAuth] Add HostedUI and OAuth 2.0 code grant flow support

[MobileClient]
Add HostedUI and OAuth 2.0 code grant flow support

[Userpools]
Fix threading issues reported in issue aws-amplify#722

[CognitoAuth]
Added methods to reset AuthHandler and get session without launching UI
Fix erroneous user cancelled when redirecting back to app fixes aws-amplify#328

* [MobileClient] Fix multiple adds of SignInProvider to provider list fixes aws-amplify#766

* [MobileClient] Fix git merge issues

* [MobileClient] Fix integration tests for new configuration

* [CognitoAuth] Fix NPE when ASF feature turned off

* [MobileClient] Finalize APIs before release, add persistence flag to OAuth 2.0 and HostedUI features

* [AuthSDKs] Update maven repositories in pom to maven.google.com

* [Core] Fix NPE when setting persistence in AWSKeyValueStore after initialization

* [MobileClient] Ignore manual tests in automation

* [MobileClient] Ignore drop-in UI test due to timeout; Default OAuth 2.0 client to persist

* Fix the transition between persistence enabled and disabled in AWSKeyValueStore

* Enable core, cognitoidentityprovider and cognitoauth integration tests on CircleCI

* Update changelog for 2.12.5; Add mobile client; Remove IoT metrics

* Skip reserved keynames (aws-amplify#791)

* Skip reserved keynames

* Add log when reserved key names are encountered

* Bump version 2.12.5 (aws-amplify#792)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cognito Issues with the AWS Android SDK for Cognito feature-request Request a new feature mobile client Issues with AWS Mobile's client-side Cognito wrapper pending-release Code has been merged but pending release
Projects
None yet
Development

No branches or pull requests

3 participants