-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add reauthentication #583
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
Add reauthentication #583
Conversation
| private boolean mAllowNewEmailAccounts = true; | ||
|
|
||
| private SignInIntentBuilder() { | ||
| @SuppressWarnings(value="unchecked") |
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.
@amandle the build should pass if you put space around the =.
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.
Done
SUPERCILEX
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.
@amandle You're back! 😄 I left a few comments about style nits and some improvements I think could be made.
| getSelectedTheme(), | ||
| getSelectedProviders(), | ||
| getSelectedTosUrl(), | ||
| mEnableSmartLock.isEnabled()))); |
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.
@amandle Maybe make the new SignedInActivity.SignedInConfig(...) part a method since it's a copy paste of the same thing above? (Actually, I think you could do a Ctrl + Alt + M on the whole startActivity thing and Intellij should only generate a response parameter which would be nicer than having a method for just the SignedInConfig part.)
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 point, done
| * Set an explanation for why reauth was requested e.g. "To delete your account you must | ||
| * reauthenticate." | ||
| * | ||
| * @param reauthReason A string explaining why reauthentication was requested. |
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.
Oops?
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.
I think you're referring to the empty return? I have now removed it.
|
|
||
| public final boolean allowNewEmailAccounts; | ||
|
|
||
| public final boolean isReauth; |
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.
@amandle Couldn't this be a method instead? It seems weird to have a parameter just for something that can be inferred programmatically.
Something like:
public boolean isReauth() {
return !TextUtils.isEmpty(reauthEmail);
}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.
Nevermind, I thought the reauthenticate method required an email but it doesn't so this won't work.
| if (visibleProviders.size() == 0) { | ||
| Log.e(TAG, "There are no configured providers associated with the user's account"); | ||
| } | ||
| populateIdpList(visibleProviders); |
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.
Before this happens I think we should check to see if visibleProviders.size() == 1 and just launch the sign in right away if that is the case.
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.
Agreed and I think we already have this logic somewhere to steal.
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.
| if (mActivityHelper.getFlowParams().isReauth) { | ||
| String reauthEmail = mActivityHelper.getFlowParams().reauthEmail; | ||
| if (reauthEmail == null) { | ||
| Log.e(TAG, "Attempting to reauth with email but no reauthEmail provided"); |
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.
I think the build() method should prevent this and throw an IllegalArgumentException if the dev tries to do this.
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.
As per Sam's comment reauthEmail is now removed, and the user is required to be logged in to start, so this whole block can go away
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.
Awesome!
| android:layout_width="wrap_content" | ||
| android:orientation="vertical"> | ||
|
|
||
| <TextView |
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.
It looks like this is just copy past from the landscape layout so we could use a <merge /> tag for this.
| true /* allowNewEmailAccounts */, | ||
| false /* isReauth */, | ||
| null /* reauthEmail */, | ||
| null /* reauthReason */); |
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.
👍
| RC_EMAIL_DIRECT_SIGN_IN); | ||
| } else { | ||
| startActivityForResult( | ||
| RegisterEmailActivity.createIntent(this, mActivityHelper.getFlowParams()), |
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.
@amandle I'm just being nit picky here (Sorry! 😄), but I feel like mActivityHelper.getFlowParams() could be Ctrl + Alt + Ved into something like params.
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.
Done.
| "theme identifier is unknown or not a style definition"); | ||
| mTheme = theme; | ||
| return this; | ||
| return (T) this; |
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.
Sigh. I looked at this and thought "there's no way that Java really requires this generic + cast situation" but it looks like we do!
| * | ||
| * @param reauthEmail The email address of the account for which reauthentication is being | ||
| * requested | ||
| */ |
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.
Is it possible to do re-auth and not use the currently signed in user? In which case this email would be FirebaseAuth.getInstance().getCurrentUser().getEmail() I feel like we could remove this setter and therefore reduce the chance of error/misunderstanding.
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.
Nice, that simplifies things considerably.
| } | ||
| List<IdpConfig> visibleProviders = new ArrayList<>(); | ||
| if (mActivityHelper.getFlowParams().isReauth) { | ||
| // display the reauthReason if available |
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.
We should ask UX about this, but instinctively a dialog feels like the "normal" reauth flow.
- User clicks a button requiring reauth ("Delete Account" for example)
- A dialog shows up that says "This action requires you to sign in again, would you like to continue"
- Yes launches the flow, No returns
RESULT_CANCELED
| // their account. | ||
| List<String> providerIds = mActivityHelper.getCurrentUser().getProviders(); | ||
| if (providerIds.size() == 0) { | ||
| // zero providers indicates that it is an email account |
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.
Doesn't the providers array contain just "password" in this case or is that only when you call fetchProvidersForEmail()?
| new ArrayList<>(mProviders), | ||
| mTheme, | ||
| mLogo, | ||
| mTosUrl, |
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.
@amandle Have you tried reauthenticating with smart lock enabled? Given @samtstern's comment about showing a dialog before we show auth stuff, I feel like things will get complicated with smart lock enabled. @samtstern @amandle Am I missing something or could this be a problem?
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.
Yeah, it's a little complicated/confusing, but I think we have to have it as an option for the case where the person doesn't know their password but has it stored in smartlock
|
@amandle FYI there are merge conflicts between your branch and the base. I left one more comment, but other than that (and the conflicts) this LGTM |
| // their account. | ||
| List<String> providerIds = mHelper.getCurrentUser().getProviders(); | ||
| if (providerIds.size() == 0) { | ||
| // zero providers indicates that it is an email account |
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.
For an email account when you do fetchProvidersForEmail you get a list that's just ["password"]. Is this different when you access the providers from the user object directly?
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.
It does seem to be different, asking some of the Firebase folks for more information
|
I checked out the branch and tried a few things. I am noticing some strange behavior when using Google Sign In:
Also the re authentication dialog does not seem to respect my theme colors, the buttons are always straight black. Ideally this dialog would inherit the theme passed to the sign in flow. |
|
|
||
| boolean smartLockEnabled = smartLockEnabledInt != 0; | ||
| boolean allowNewEmailAccounts = allowNewEmailAccountsInt != 0; | ||
| boolean isReauth = isReauthInt != 0; |
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.
@amandle The merge conflicts are my fault, sorry about that! I removed this unnecessary abstraction so this should work once you merge:
boolean smartLockEnabled = in.readInt() != 0;
boolean allowNewEmailAccounts = in.readInt() != 0;
boolean isReauth = in.readInt() != 0;
String reauthReason = in.readString();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 reauth does happen though. Since the user is already signed in to Google and we know the email address it happens automatically. You can verify this by putting a breakpoint at
Ah, yep this is a bug in the sample app. Should be fixed now.
Hmm, I'm not sure how to do this without going back to using standard activities instead of AlertDialogs. The RecoveryEmailSentDialog uses the same theme: FirebaseUI-Android/auth/src/main/java/com/firebase/ui/auth/ui/email/RecoveryEmailSentDialog.java Line 32 in e14170d
|
|
@amandle I moved this to target the The only remaining concern I still have is the bad UX with SmartLock and "None of the Above" where GSI succeeds even though the user never really did anything. Can we clarify this somehow? Options include:
|
|
@samtstern I think this is ready to review now. I added a toast when the automatic Google Sign In happens and skip Smart Lock if it's a reauth with a non-password account. |
|
@amandle approved! Going to squash and merge. @yramanchuk @morganchen12 @bojeil-google FYI we need to coordinate the same abilities across platforms. This is merging into our next release branch. |
|
Would love to have this feature back but can't find it in the repo. Was it removed? |
|
This feature was never released actually since amandle left the project and
we were focused on stability work.
…On Fri, Jun 1, 2018, 7:31 AM develuxe ***@***.***> wrote:
Would love to have this feature back but can't find it in the repo. Was it
removed?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#583 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIEw6kxlVeTFBfpDlXAjtH9uZYs0LF1Eks5t4VBegaJpZM4L7nov>
.
|
|
Thanks for your quick response. Is there any best practice on how to reauthenticate the user? |
|
So sad they abandoned this feature. I'm actually facing this situation, it's so much complex to retrieve credentials from Google and other providers, Firebase's reauthenticate function is pretty easy, but it requires that credentials. I think the easiest way is forcing sign out and ask user to sign in again - it would needed to login back to reauthenticate anyway. |
|
Hey folks, we have not abandoned our plans to support re-authentication in FirebaseUI (it is indeed a missing key functionality that we should support). The priority has been lowered in favor of some other popular/critical feature requests such as support for email link sign-in and account management UI. |
|
That's good! |
|
Any updates on this feature? And would there be an ETA for this? |
|
Will this be released any time soon? |
Adds reauthentication as discussed in #563
AuthUI.createReauthIntentBuilder()which returns an intent builder very similar toAuthUI.createSignInIntent()but adds the methodssetReauthReasonandsetReauthEmailand removessetAllowNewEmailAccounts. Both builders extend a common builder which contains the common methods.