-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support requesting a CAPTCHA during registration.
- Loading branch information
1 parent
2cfa431
commit 02b0800
Showing
5 changed files
with
188 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
|
||
<TextView | ||
android:id="@+id/registration_captcha_title" | ||
style="@style/Signal.Text.Headline" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="24dp" | ||
android:layout_marginLeft="24dp" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginEnd="24dp" | ||
android:layout_marginRight="24dp" | ||
android:text="@string/RegistrationActivity_we_need_to_verify_that_youre_human" | ||
android:gravity="center" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<WebView | ||
android:id="@+id/registration_captcha_web_view" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginLeft="16dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginRight="16dp" | ||
android:layout_marginBottom="16dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/registration_captcha_title" /> | ||
|
||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/org/thoughtcrime/securesms/registration/CaptchaActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.thoughtcrime.securesms.registration; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.text.TextUtils; | ||
import android.webkit.WebView; | ||
import android.webkit.WebViewClient; | ||
|
||
import org.thoughtcrime.securesms.BaseActionBarActivity; | ||
import org.thoughtcrime.securesms.R; | ||
|
||
public class CaptchaActivity extends BaseActionBarActivity { | ||
|
||
public static final String KEY_TOKEN = "token"; | ||
public static final String KEY_IS_SMS = "is_sms"; | ||
|
||
private static final String SIGNAL_SCHEME = "signalcaptcha://"; | ||
|
||
public static Intent getIntent(@NonNull Context context, boolean isSms) { | ||
Intent intent = new Intent(context, CaptchaActivity.class); | ||
intent.putExtra(KEY_IS_SMS, isSms); | ||
return intent; | ||
} | ||
|
||
@SuppressLint("SetJavaScriptEnabled") | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.captcha_activity); | ||
|
||
WebView webView = findViewById(R.id.registration_captcha_web_view); | ||
|
||
webView.getSettings().setJavaScriptEnabled(true); | ||
webView.clearCache(true); | ||
|
||
webView.setWebViewClient(new WebViewClient() { | ||
@Override | ||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
if (url != null && url.startsWith(SIGNAL_SCHEME)) { | ||
handleToken(url.substring(SIGNAL_SCHEME.length())); | ||
return true; | ||
} | ||
return false; | ||
} | ||
}); | ||
|
||
webView.loadUrl("https://signalcaptchas.org/registration/generate.html\n"); | ||
} | ||
|
||
public void handleToken(String token) { | ||
if (!TextUtils.isEmpty(token)) { | ||
Intent result = new Intent(); | ||
result.putExtra(KEY_TOKEN, token); | ||
result.putExtra(KEY_IS_SMS, getIntent().getBooleanExtra(KEY_IS_SMS, true)); | ||
setResult(RESULT_OK, result); | ||
} else { | ||
setResult(RESULT_CANCELED); | ||
} | ||
|
||
finish(); | ||
} | ||
} |
02b0800
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.
This commit breaks the expectation of privacy when Google Play Services is disabled and exposes users to potential identification by a subpeona to Google for all Recaptcha requests from Signal registrations. #10999