diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 15299173d..3d1b31457 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -184,6 +184,7 @@ usage! { or |c: &Config| otry!(c.dapps).user.clone().map(Some), flag_dapps_pass: Option = None, or |c: &Config| otry!(c.dapps).pass.clone().map(Some), + flag_dapps_apis_all: bool = false, or |_| None, // -- Sealing/Mining Options flag_author: Option = None, @@ -629,6 +630,7 @@ mod tests { flag_dapps_path: "$HOME/.parity/dapps".into(), flag_dapps_user: Some("test_user".into()), flag_dapps_pass: Some("test_pass".into()), + flag_dapps_apis_all: false, // -- Sealing/Mining Options flag_author: Some("0xdeadbeefcafe0000000000000000000000000001".into()), diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index 55329c7b9..9f554eb10 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -171,6 +171,9 @@ API and Console Options: conjunction with --dapps-user. (default: {flag_dapps_pass:?}) --dapps-path PATH Specify directory where dapps should be installed. (default: {flag_dapps_path}) + --dapps-apis-all Expose all possible RPC APIs on Dapps port. + WARNING: INSECURE. Used only for development. + (default: {flag_dapps_apis_all}) Sealing/Mining Options: --author ADDRESS Specify the block author (aka "coinbase") address diff --git a/parity/configuration.rs b/parity/configuration.rs index cf10884a0..d7d1a5f60 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -534,6 +534,7 @@ impl Configuration { } else { vec![] }, + all_apis: self.args.flag_dapps_apis_all, } } diff --git a/parity/dapps.rs b/parity/dapps.rs index 4f895c4a5..9f674eadb 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -16,15 +16,15 @@ use std::path::PathBuf; use std::sync::Arc; -use io::PanicHandler; -use rpc_apis; + +use dir::default_data_path; use ethcore::client::Client; use ethsync::SyncProvider; -use helpers::replace_home; -use dir::default_data_path; -use jsonrpc_core::reactor::Remote; -use rpc_apis::SignerService; use hash_fetch::fetch::Client as FetchClient; +use helpers::replace_home; +use io::PanicHandler; +use jsonrpc_core::reactor::Remote; +use rpc_apis::{self, SignerService}; #[derive(Debug, PartialEq, Clone)] pub struct Configuration { @@ -36,6 +36,7 @@ pub struct Configuration { pub pass: Option, pub dapps_path: PathBuf, pub extra_dapps: Vec, + pub all_apis: bool, } impl Default for Configuration { @@ -50,6 +51,7 @@ impl Default for Configuration { pass: None, dapps_path: replace_home(&data_dir, "$BASE/dapps").into(), extra_dapps: vec![], + all_apis: false, } } } @@ -89,7 +91,8 @@ pub fn new(configuration: Configuration, deps: Dependencies) -> Result>, _auth: Option<(String, String)>, + _all_apis: bool, ) -> Result { Err("Your Parity version has been compiled without WebApps support.".into()) } @@ -124,14 +128,14 @@ mod server { use std::io; use util::{Bytes, Address, U256}; + use ansi_term::Colour; use ethcore::transaction::{Transaction, Action}; use ethcore::client::{Client, BlockChainClient, BlockId}; - - use rpc_apis; use ethcore_rpc::is_major_importing; use hash_fetch::urlhint::ContractClient; use jsonrpc_core::reactor::RpcHandler; use parity_reactor; + use rpc_apis; pub use ethcore_dapps::Server as WebappServer; @@ -142,6 +146,7 @@ mod server { url: &SocketAddr, allowed_hosts: Option>, auth: Option<(String, String)>, + all_apis: bool, ) -> Result { use ethcore_dapps as dapps; @@ -162,7 +167,14 @@ mod server { .signer_address(deps.signer.address()) .allowed_hosts(allowed_hosts); - let apis = rpc_apis::setup_rpc(Default::default(), deps.apis.clone(), rpc_apis::ApiSet::UnsafeContext); + let api_set = if all_apis { + warn!("{}", Colour::Red.bold().paint("*** INSECURE *** Running Dapps with all APIs exposed.")); + info!("If you do not intend this, exit now."); + rpc_apis::ApiSet::SafeContext + } else { + rpc_apis::ApiSet::UnsafeContext + }; + let apis = rpc_apis::setup_rpc(Default::default(), deps.apis.clone(), api_set); let handler = RpcHandler::new(Arc::new(apis), deps.remote); let start_result = match auth { None => {