diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-12-16 09:16:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-16 09:16:41 +0100 |
| commit | 1296a46a68f7a63681f294c12fadc9ca5e0c6459 (patch) | |
| tree | 8b829389b78205d7dcc322c80fcef50fb8a0e669 /zellij-client/src/web_client/connection_manager.rs | |
| parent | HOTFIX: fix flaky macos test (diff) | |
| download | sl0ppij-1296a46a68f7a63681f294c12fadc9ca5e0c6459.tar.gz sl0ppij-1296a46a68f7a63681f294c12fadc9ca5e0c6459.tar.xz sl0ppij-1296a46a68f7a63681f294c12fadc9ca5e0c6459.zip | |
Read only web tokens (#4551)
* initial implementation
* fix race condition potentially allowing read-only clients to gain write access
* clear read only status on disconnect
* cleanups and formatting
* fix tests
* refactor first message + ipc pipe creation out of trait
* fix web tests
* fix web tests again
* refactor: move os_input connection establishment to session manager trait
* add read-only-token tests
* fix: identify watchers as web-clients when they are and enforce no-web-clients for them as well
* identify watcher web clients on the server
* fix tests
* cleanups and formatting
* add read-only-tokens to the plugin api
* update share plugin ui for read-only tokens
* cleanups and formatting
* docs(changelog): add PR
Diffstat (limited to 'zellij-client/src/web_client/connection_manager.rs')
| -rw-r--r-- | zellij-client/src/web_client/connection_manager.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/zellij-client/src/web_client/connection_manager.rs b/zellij-client/src/web_client/connection_manager.rs index 3999b060..5bdc6fab 100644 --- a/zellij-client/src/web_client/connection_manager.rs +++ b/zellij-client/src/web_client/connection_manager.rs @@ -6,9 +6,22 @@ use tokio::sync::mpsc::UnboundedSender; use tokio_util::sync::CancellationToken; impl ConnectionTable { - pub fn add_new_client(&mut self, client_id: String, client_os_api: Box<dyn ClientOsApi>) { + pub fn add_new_client( + &mut self, + client_id: String, + client_os_api: Box<dyn ClientOsApi>, + is_read_only: bool, + ) { self.client_id_to_channels - .insert(client_id, ClientChannels::new(client_os_api)); + .insert(client_id.clone(), ClientChannels::new(client_os_api)); + self.client_read_only_status.insert(client_id, is_read_only); + } + + pub fn is_client_read_only(&self, client_id: &str) -> bool { + self.client_read_only_status + .get(client_id) + .copied() + .unwrap_or(false) } pub fn add_client_control_tx( @@ -61,6 +74,7 @@ impl ConnectionTable { if let Some(mut client_channels) = self.client_id_to_channels.remove(client_id).take() { client_channels.cleanup(); } + self.client_read_only_status.remove(client_id); } } |
