Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Secure WS-RPC: grant access to all apis (#10246)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelchalon authored and 5chdn committed Feb 8, 2019
1 parent 046b8bb commit 3502b36
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 41 deletions.
2 changes: 1 addition & 1 deletion parity/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
let url = format!("{}:{}", conf.interface, conf.port);
let addr = url.parse().map_err(|_| format!("Invalid WebSockets listen host/port given: {}", url))?;

let full_handler = setup_apis(rpc_apis::ApiSet::SafeContext, deps);
let full_handler = setup_apis(rpc_apis::ApiSet::All, deps);
let handler = {
let mut handler = MetaIoHandler::with_middleware((
rpc::WsDispatcher::new(full_handler),
Expand Down
41 changes: 1 addition & 40 deletions parity/rpc_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ impl FromStr for Api {

#[derive(Debug, Clone)]
pub enum ApiSet {
// Safe context (like token-protected WS interface)
SafeContext,
// Unsafe context (like jsonrpc over http)
UnsafeContext,
// All possible APIs
// All possible APIs (safe context like token-protected WS interface)
All,
// Local "unsafe" context and accounts access
IpcContext,
Expand Down Expand Up @@ -723,16 +721,6 @@ impl ApiSet {
public_list.insert(Api::ParityAccounts);
public_list
}
ApiSet::SafeContext => {
public_list.insert(Api::Debug);
public_list.insert(Api::Traces);
public_list.insert(Api::ParityPubSub);
public_list.insert(Api::ParityAccounts);
public_list.insert(Api::ParitySet);
public_list.insert(Api::Signer);
public_list.insert(Api::SecretStore);
public_list
}
ApiSet::All => {
public_list.insert(Api::Debug);
public_list.insert(Api::Traces);
Expand Down Expand Up @@ -838,33 +826,6 @@ mod test {
assert_eq!(ApiSet::IpcContext.list_apis(), expected);
}

#[test]
fn test_api_set_safe_context() {
let expected = vec![
// safe
Api::Web3,
Api::Net,
Api::Eth,
Api::EthPubSub,
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Rpc,
Api::SecretStore,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
// semi-safe
Api::ParityAccounts,
// Unsafe
Api::ParitySet,
Api::Signer,
Api::Debug,
].into_iter()
.collect();
assert_eq!(ApiSet::SafeContext.list_apis(), expected);
}

#[test]
fn test_all_apis() {
assert_eq!(
Expand Down

0 comments on commit 3502b36

Please sign in to comment.