Skip to content

Commit

Permalink
Merge pull request #8321 from nextcloud/https
Browse files Browse the repository at this point in the history
Prevent http redirection if https is used during login
  • Loading branch information
tobiasKaminsky authored May 11, 2021
2 parents c318115 + 17b52e8 commit 02d0f8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private boolean onlyAdd = false;
@SuppressLint("ResourceAsColor") @ColorInt
private int primaryColor = R.color.primary;
private boolean strictMode = false;

@VisibleForTesting
public AccountSetupBinding getAccountSetupBinding() {
Expand Down Expand Up @@ -382,6 +383,10 @@ private void initWebViewLogin(String baseURL, boolean useGenericUserAgent) {
url = getResources().getString(R.string.webview_login_url);
}

if (url.startsWith(HTTPS_PROTOCOL)) {
strictMode = true;
}

accountSetupWebviewBinding.loginWebview.loadUrl(url, headers);

setClient();
Expand Down Expand Up @@ -423,6 +428,10 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
parseAndLoginFromWebView(url);
return true;
}
if (strictMode && url.startsWith(HTTP_PROTOCOL)) {
Snackbar.make(view, R.string.strict_mode, Snackbar.LENGTH_LONG).show();
return true;
}
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -957,4 +957,5 @@
<string name="create">Create</string>
<string name="select_one_template">Please select one template</string>
<string name="choose_template_helper_text">Please choose a template and enter a file name.</string>
<string name="strict_mode">Strict mode: no http connection allowed!</string>
</resources>

0 comments on commit 02d0f8a

Please sign in to comment.