Support basic auth in JSON RPC endpoint (#6897)
* Support basic auth in JSON RPC endpoint * Review comment: Allow blank password in basi auth of JSON RPC endpoint * Reuse basic auth configuration function --------- Co-authored-by: sl1depengwyn <max.pengwyn@gmail.com>pull/6922/head
parent
7a704d8420
commit
65d7ad5b45
@ -0,0 +1,14 @@ |
||||
defmodule ConfigHelper do |
||||
def hackney_options() do |
||||
basic_auth_user = System.get_env("ETHEREUM_JSONRPC_USER", "") |
||||
basic_auth_pass = System.get_env("ETHEREUM_JSONRPC_PASSWORD", nil) |
||||
|
||||
hackney_opts = |
||||
[pool: :ethereum_jsonrpc] |
||||
|> (&if(System.get_env("ETHEREUM_JSONRPC_HTTP_INSECURE", "") == "true", do: [:insecure] ++ &1, else: &1)).() |
||||
|> (&if(basic_auth_user != "" && !is_nil(basic_auth_pass), |
||||
do: [basic_auth: {basic_auth_user, basic_auth_pass}] ++ &1, |
||||
else: &1 |
||||
)).() |
||||
end |
||||
end |
Loading…
Reference in new issue