Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e7e16c8 authored by Arnau Vàzquez's avatar Arnau Vàzquez Committed by Romain Hunault
Browse files

ui: LoginActivity: set alert dialog for device spoof

Currently, AppAuth doesn't have any implementation on sending the device
credentials and google takes the device name from within the Browser info
to be shown at Google Account->Security->Devices which is basically getting
spoofed due to some security reasons.

So just put up an alert dialog before the sign in to make user aware of
the fact and also for avoiding unnecessary panics on their side.

Issue was reported here https://gitlab.e.foundation/e/apps/AccountManager/-/issues/51
parent eb65d24b
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -59,11 +59,6 @@ class GoogleAuthenticatorFragment : Fragment(), AuthorizationService.TokenRespon
	model = ViewModelProviders.of(this).get(GoogleAuthenticatorModel::class.java)
        loginModel = ViewModelProviders.of(requireActivity()).get(LoginModel::class.java)
	
	if (!isNetworkAvailable()) {
            Toast.makeText(context, "Please check your internet connection", Toast.LENGTH_LONG).show()
            activity!!.finish()
        }

        // Initialise the authorization service
        authorizationService = AuthorizationService(context!!)

@@ -83,8 +78,10 @@ class GoogleAuthenticatorFragment : Fragment(), AuthorizationService.TokenRespon
                    val retrieveCallback = AuthorizationServiceConfiguration.RetrieveConfigurationCallback { serviceConfiguration, ex ->
                        if (ex == null && serviceConfiguration != null) {
                            makeAuthRequest(serviceConfiguration, idp)
                        }
                        else {
                        } else if (!isNetworkAvailable()) {
            		    Toast.makeText(context, "Please check your internet connection", Toast.LENGTH_LONG).show()
            		    activity!!.finish()
        		} else {
			    Toast.makeText(context, "Login failed, please try again later", Toast.LENGTH_LONG).show()
                            activity!!.finish()
                        }
@@ -104,8 +101,10 @@ class GoogleAuthenticatorFragment : Fragment(), AuthorizationService.TokenRespon

                    if (response != null) {
                       exchangeAuthorizationCode(response)
                    }
                    else {
                    } else if (!isNetworkAvailable()) {
                            Toast.makeText(context, "Please check your internet connection", Toast.LENGTH_LONG).show()
                            activity!!.finish()
                    } else {
		        Toast.makeText(context, "Login failed, please try again later", Toast.LENGTH_LONG).show()
                        activity!!.finish()
                    }
+28 −3
Original line number Diff line number Diff line
@@ -10,8 +10,13 @@ package foundation.e.accountmanager.ui.setup

import android.os.Bundle
import android.view.MenuItem
import android.text.Layout
import android.text.SpannableString
import android.text.style.AlignmentSpan
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import foundation.e.accountmanager.R
import foundation.e.accountmanager.App
import foundation.e.accountmanager.log.Logger
import foundation.e.accountmanager.ui.UiUtils
@@ -67,10 +72,30 @@ class LoginActivity: AppCompatActivity() {
                                .commit()
                    }
                    ACCOUNT_PROVIDER_GOOGLE -> {
			val builder = AlertDialog.Builder(this)
			val title = SpannableString(getString(R.string.google_alert_title))

			// alert dialog title align center
            		title.setSpan(
                	    AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER),
                	    0,
                	    title.length,
                	    0
            		)

            		builder.setTitle(title)
        		builder.setMessage(getString(R.string.google_alert_message))
			builder.setPositiveButton(android.R.string.yes) { dialog, which ->
			    dialog.cancel()	
			    supportFragmentManager.beginTransaction()
                            	.replace(android.R.id.content, GoogleAuthenticatorFragment())
                            	.commit()
		    	}
			builder.setCancelable(false)

			val dialog = builder.create()
			dialog.show()
                    }
                else ->
                    // first call, add first login fragment
                    supportFragmentManager.beginTransaction()
+3 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
                android:id="@+id/tab_layout"
                android:layout_width="match_parent"
		android:layout_height="wrap_content"
		app:tabTextColor="@android:color/white"
                style="@style/Widget.MaterialComponents.TabLayout.Colored" />

        </com.google.android.material.appbar.AppBarLayout>
+4 −0
Original line number Diff line number Diff line
@@ -348,4 +348,8 @@
    <string name="certificate_notification_connection_security">Account Manager: Connection security</string>
    <string name="trust_certificate_unknown_certificate_found">Account Manager has encountered an unknown certificate. Do you want to trust it?</string>

    <!-- google alert dialog -->
    <string name="google_alert_title">WARNING</string>
    <string name="google_alert_message">/e/ will report a fake device model to Google to protect your privacy.\nYou can check which one on Google\'s Device Activity after you log in.</string>

</resources>
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
        android:title="@string/manage_accounts">
        <intent
            android:action="ACTION_VIEW"
            android:targetClass="foundation.e.accountmanager.ui.AccountActivity"
            android:targetClass="foundation.e.accountmanager.ui.AccountsActivity"
            android:targetPackage="foundation.e.accountmanager" />
    </PreferenceScreen>