diff options
| author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2021-04-12 04:15:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-12 11:15:43 +0900 |
| commit | fefe93c91b63e35bf88f5f432f0cca09948d0623 (patch) | |
| tree | bf8f3e031cf558161277e01e4ca2e2c7817ef6ab /op_crates | |
| parent | 8b49d948f58e0665e87e63f7e154ab53fa60a939 (diff) | |
feat(runtime/permissions): prompt fallback (#9376)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'op_crates')
| -rw-r--r-- | op_crates/fetch/lib.rs | 12 | ||||
| -rw-r--r-- | op_crates/websocket/lib.rs | 10 |
2 files changed, 11 insertions, 11 deletions
diff --git a/op_crates/fetch/lib.rs b/op_crates/fetch/lib.rs index 69c0c46ad..ae716af41 100644 --- a/op_crates/fetch/lib.rs +++ b/op_crates/fetch/lib.rs @@ -86,19 +86,19 @@ pub struct HttpClientDefaults { } pub trait FetchPermissions { - fn check_net_url(&self, _url: &Url) -> Result<(), AnyError>; - fn check_read(&self, _p: &Path) -> Result<(), AnyError>; + fn check_net_url(&mut self, _url: &Url) -> Result<(), AnyError>; + fn check_read(&mut self, _p: &Path) -> Result<(), AnyError>; } /// For use with `op_fetch` when the user does not want permissions. pub struct NoFetchPermissions; impl FetchPermissions for NoFetchPermissions { - fn check_net_url(&self, _url: &Url) -> Result<(), AnyError> { + fn check_net_url(&mut self, _url: &Url) -> Result<(), AnyError> { Ok(()) } - fn check_read(&self, _p: &Path) -> Result<(), AnyError> { + fn check_read(&mut self, _p: &Path) -> Result<(), AnyError> { Ok(()) } } @@ -161,7 +161,7 @@ where let scheme = url.scheme(); let (request_rid, request_body_rid) = match scheme { "http" | "https" => { - let permissions = state.borrow::<FP>(); + let permissions = state.borrow_mut::<FP>(); permissions.check_net_url(&url)?; let mut request = client.request(method, url); @@ -442,7 +442,7 @@ where FP: FetchPermissions + 'static, { if let Some(ca_file) = args.ca_file.clone() { - let permissions = state.borrow::<FP>(); + let permissions = state.borrow_mut::<FP>(); permissions.check_read(&PathBuf::from(ca_file))?; } diff --git a/op_crates/websocket/lib.rs b/op_crates/websocket/lib.rs index 59fa5acdb..930424aab 100644 --- a/op_crates/websocket/lib.rs +++ b/op_crates/websocket/lib.rs @@ -49,14 +49,14 @@ pub struct WsCaData(pub Vec<u8>); pub struct WsUserAgent(pub String); pub trait WebSocketPermissions { - fn check_net_url(&self, _url: &url::Url) -> Result<(), AnyError>; + fn check_net_url(&mut self, _url: &url::Url) -> Result<(), AnyError>; } /// For use with `op_websocket_*` when the user does not want permissions. pub struct NoWebSocketPermissions; impl WebSocketPermissions for NoWebSocketPermissions { - fn check_net_url(&self, _url: &url::Url) -> Result<(), AnyError> { + fn check_net_url(&mut self, _url: &url::Url) -> Result<(), AnyError> { Ok(()) } } @@ -91,7 +91,7 @@ where WP: WebSocketPermissions + 'static, { state - .borrow::<WP>() + .borrow_mut::<WP>() .check_net_url(&url::Url::parse(&url)?)?; Ok(()) @@ -113,8 +113,8 @@ where WP: WebSocketPermissions + 'static, { { - let s = state.borrow(); - s.borrow::<WP>() + let mut s = state.borrow_mut(); + s.borrow_mut::<WP>() .check_net_url(&url::Url::parse(&args.url)?) .expect( "Permission check should have been done in op_ws_check_permission", |
