Add ability to disable reCAPTCHA

pull/7416/head
bretep 2 years ago
parent 9615e2fa0b
commit ba17626ead
  1. 1
      CHANGELOG.md
  2. 9
      apps/block_scout_web/assets/js/lib/csv_download.js
  3. 52
      apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex
  4. 2
      apps/block_scout_web/lib/block_scout_web/templates/csv_export/index.html.eex
  5. 1
      apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex
  6. 3
      config/runtime.exs
  7. 3
      docker-compose/envs/common-blockscout.env
  8. 3
      docker/Makefile

@ -4,6 +4,7 @@
### Features
- [#7416](https://github.com/blockscout/blockscout/pull/7416) - Add option to disable reCAPTCHA
- [#6694](https://github.com/blockscout/blockscout/pull/6694) - Add withdrawals support (EIP-4895)
- [#7355](https://github.com/blockscout/blockscout/pull/7355) - Add endpoint for token info import
- [#7393](https://github.com/blockscout/blockscout/pull/7393) - Realtime fetcher max gap

@ -31,10 +31,17 @@ $button.on('click', () => {
// @ts-ignore
// eslint-disable-next-line
const reCaptchaV3ClientKey = document.getElementById('js-re-captcha-v3-client-key').value
// @ts-ignore
// eslint-disable-next-line
const reCaptchaDisabled = document.getElementById('js-re-captcha-disabled').value
const addressHash = $button.data('address-hash')
const from = $('.js-datepicker-from').val()
const to = $('.js-datepicker-to').val()
if (reCaptchaV3ClientKey) {
if (reCaptchaDisabled) {
const url = `${$button.data('link')}?address_id=${addressHash}&from_period=${from}&to_period=${to}`
download(url)
} else if (reCaptchaV3ClientKey) {
disableBtnWithSpinner()
// @ts-ignore
// eslint-disable-next-line

@ -180,6 +180,42 @@ defmodule BlockScoutWeb.AddressTransactionController do
|> send_chunked(200)
end
defp items_csv(
conn,
%{
"address_id" => address_hash_string,
"from_period" => from_period,
"to_period" => to_period
},
csv_export_module
)
when is_binary(address_hash_string) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
true <- Application.get_env(:block_scout_web, :recaptcha)[:is_disabled] do
address
|> csv_export_module.export(from_period, to_period)
|> Enum.reduce_while(put_resp_params(conn), fn chunk, conn ->
case Conn.chunk(conn, chunk) do
{:ok, conn} ->
{:cont, conn}
{:error, :closed} ->
{:halt, conn}
end
end)
else
:error ->
unprocessable_entity(conn)
{:error, :not_found} ->
not_found(conn)
{:recaptcha, false} ->
not_found(conn)
end
end
defp items_csv(
conn,
%{
@ -232,6 +268,22 @@ defmodule BlockScoutWeb.AddressTransactionController do
)
end
def transactions_csv(conn, %{
"address_id" => address_hash_string,
"from_period" => from_period,
"to_period" => to_period
}) do
items_csv(
conn,
%{
"address_id" => address_hash_string,
"from_period" => from_period,
"to_period" => to_period
},
AddressTransactionCsvExporter
)
end
def transactions_csv(conn, %{
"address_id" => address_hash_string,
"from_period" => from_period,

@ -41,4 +41,4 @@
<script src="https://www.google.com/recaptcha/api.js?render=<%= Application.get_env(:block_scout_web, :recaptcha)[:v3_client_key] %>" defer></script>
<% true -> %>
<% end %>
</section>
</section>

@ -66,6 +66,7 @@
<input id="js-coin-name" class="d-none" value="<%= Application.get_env(:explorer, :coin_name) %>" />
<input id="js-re-captcha-client-key" class="d-none" value="<%= Application.get_env(:block_scout_web, :recaptcha)[:v2_client_key] %>" />
<input id="js-re-captcha-v3-client-key" class="d-none" value="<%= Application.get_env(:block_scout_web, :recaptcha)[:v3_client_key] %>" />
<input id="js-re-captcha-disabled" class="d-none" value="<%= Application.get_env(:block_scout_web, :recaptcha)[:is_disabled] %>" />
<input id="js-network-path" class="d-none" value="<%= Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:path] %>" />
<!-- -->
<% show_maintenance_alert = Application.get_env(:block_scout_web, BlockScoutWeb.Chain)[:show_maintenance_alert] %>

@ -38,7 +38,8 @@ config :block_scout_web, :recaptcha,
v2_client_key: System.get_env("RE_CAPTCHA_CLIENT_KEY"),
v2_secret_key: System.get_env("RE_CAPTCHA_SECRET_KEY"),
v3_client_key: System.get_env("RE_CAPTCHA_V3_CLIENT_KEY"),
v3_secret_key: System.get_env("RE_CAPTCHA_V3_SECRET_KEY")
v3_secret_key: System.get_env("RE_CAPTCHA_V3_SECRET_KEY"),
is_disabled: ConfigHelper.parse_bool_env_var("RE_CAPTCHA_DISABLED")
network_path =
"NETWORK_PATH"

@ -156,6 +156,7 @@ RE_CAPTCHA_SECRET_KEY=
RE_CAPTCHA_CLIENT_KEY=
RE_CAPTCHA_V3_SECRET_KEY=
RE_CAPTCHA_V3_CLIENT_KEY=
RE_CAPTCHA_DISABLED=false
JSON_RPC=
#API_RATE_LIMIT_DISABLED=true
API_RATE_LIMIT_TIME_INTERVAL=1s
@ -199,4 +200,4 @@ ACCOUNT_REDIS_URL=redis://redis_db:6379
# AMPLITUDE_API_KEY=
# AMPLITUDE_URL=
EIP_1559_ELASTICITY_MULTIPLIER=2
# API_SENSITIVE_ENDPOINTS_KEY=
# API_SENSITIVE_ENDPOINTS_KEY=

@ -369,6 +369,9 @@ endif
ifdef RE_CAPTCHA_V3_CLIENT_KEY
BLOCKSCOUT_CONTAINER_PARAMS += -e 'RE_CAPTCHA_V3_CLIENT_KEY=$(RE_CAPTCHA_V3_CLIENT_KEY)'
endif
ifdef RE_CAPTCHA_IS_ENTERPRISE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'RE_CAPTCHA_IS_ENTERPRISE=$(RE_CAPTCHA_IS_ENTERPRISE)'
endif
ifdef CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD
BLOCKSCOUT_CONTAINER_PARAMS += -e 'CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD=$(CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD)'
endif

Loading…
Cancel
Save