MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_ssh_forward_token

Function validate_ssh_forward_token

crates/openshell-server/src/grpc/sandbox.rs:1025–1049  ·  view source on GitHub ↗
(
    state: &Arc<ServerState>,
    token: &str,
    sandbox_id: &str,
)

Source from the content-addressed store, hash-verified

1023}
1024
1025async fn validate_ssh_forward_token(
1026 state: &Arc<ServerState>,
1027 token: &str,
1028 sandbox_id: &str,
1029) -> Result<(), Status> {
1030 let session = state
1031 .store
1032 .get_message::<SshSession>(token)
1033 .await
1034 .map_err(|e| Status::internal(format!("fetch SSH session failed: {e}")))?
1035 .ok_or_else(|| Status::unauthenticated("SSH session token not found"))?;
1036
1037 if session.revoked || session.sandbox_id != sandbox_id {
1038 return Err(Status::unauthenticated("SSH session token is not valid"));
1039 }
1040
1041 if session.expires_at_ms > 0 {
1042 let now_ms = current_time_ms();
1043 if now_ms > session.expires_at_ms {
1044 return Err(Status::unauthenticated("SSH session token expired"));
1045 }
1046 }
1047
1048 Ok(())
1049}
1050
1051fn acquire_ssh_connection_slots(
1052 token_counts: &std::sync::Mutex<std::collections::HashMap<String, u32>>,

Callers 1

Calls 1

current_time_msFunction · 0.50

Tested by

no test coverage detected