Allow CORS requests in Secret Store API (#10584)
* allow CORS requests for Secret Store API (#10582) * secretstore CORS: fix error with unit tests * secretstore CORS: removed debug log * secretstore CORS: add missing response's header * secretstore CORS: switched to jsonrpc-server-utils for CORS validation
This commit is contained in:
committed by
Wei Tang
parent
c5fa7aab43
commit
4cc274e75f
@@ -638,6 +638,7 @@ impl Configuration {
|
||||
http_port: self.args.arg_ports_shift + self.args.arg_secretstore_http_port,
|
||||
data_path: self.directories().secretstore,
|
||||
admin_public: self.secretstore_admin_public()?,
|
||||
cors: self.secretstore_cors()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1058,6 +1059,10 @@ impl Configuration {
|
||||
self.interface(&self.args.arg_secretstore_http_interface)
|
||||
}
|
||||
|
||||
fn secretstore_cors(&self) -> Option<Vec<String>> {
|
||||
Self::cors(self.args.arg_secretstore_http_cors.as_ref())
|
||||
}
|
||||
|
||||
fn secretstore_self_secret(&self) -> Result<Option<NodeSecretKey>, String> {
|
||||
match self.args.arg_secretstore_secret {
|
||||
Some(ref s) if s.len() == 64 => Ok(Some(NodeSecretKey::Plain(s.parse()
|
||||
@@ -1969,4 +1974,19 @@ mod tests {
|
||||
_ => panic!("Should be Cmd::Run"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_parse_secretstore_cors() {
|
||||
// given
|
||||
|
||||
// when
|
||||
let conf0 = parse(&["parity"]);
|
||||
let conf1 = parse(&["parity", "--secretstore-http-cors", "*"]);
|
||||
let conf2 = parse(&["parity", "--secretstore-http-cors", "http://parity.io,http://something.io"]);
|
||||
|
||||
// then
|
||||
assert_eq!(conf0.secretstore_cors(), Some(vec![]));
|
||||
assert_eq!(conf1.secretstore_cors(), None);
|
||||
assert_eq!(conf2.secretstore_cors(), Some(vec!["http://parity.io".into(),"http://something.io".into()]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user