Skip to main content

Keeper PAM WebRTC for Python - A secure, stable, and high-performance Tube API for Python, providing WebRTC-based secure tunneling with enterprise-grade security and reliability optimizations.

Project description

Keeper PAM WebRTC for Python

A secure, stable, and high-performance Tube API for Python, providing WebRTC-based secure tunneling with enterprise-grade security and reliability optimizations.

Core Values

Security • Stability • Performance - Built for Keeper Security's mission-critical applications:

  • 🔒 Security First: Memory-safe Rust implementation with comprehensive bounds checking
  • 🛡️ Enterprise Stability: Lock-free architecture eliminates race conditions and deadlocks
  • ⚡ Optimized Performance: Advanced optimizations deliver exceptional speed when you need it
  • 🔧 Production Ready: Zero-configuration reliability for demanding security applications

Description

keeper-pam-webrtc-rs provides Python bindings to a Rust-based Tube API for secure communication, designed for:

  • Secure tunneling via WebRTC data channels with memory-safe operations
  • Multi-connection management through tube abstractions
  • Reliable peer connection handling with comprehensive error handling
  • Efficient channel management for different communication patterns
  • Cross-platform compatibility (Linux, macOS, Windows, Alpine)
  • Mission-critical reliability for security-focused applications

This package is designed to be used with Keeper Gateway and Keeper Commander. It provides a secure, reliable tube-based communication system built on WebRTC, specifically tailored for Keeper Security's internal products and security-critical tunneling use cases.

Note: This package is intended for internal Keeper Security products and is not being actively advertised for general use.

Installation

pip install keeper-pam-webrtc-rs

Usage

import keeper_pam_webrtc_rs

# Create a tube registry
registry = keeper_pam_webrtc_rs.PyTubeRegistry()

# Define a signal callback for WebRTC events
def on_signal(signal_dict):
    print(f"Received signal: {signal_dict}")
    # Handle ICE candidates, connection state changes, etc.

# Create a server-side tube for tunneling
server_result = registry.create_tube(
    conversation_id="tunnel-session-123",
    settings={
        "conversationType": "tunnel",
        "target_host": "127.0.0.1", 
        "target_port": "22"  # SSH tunnel example
    },
    trickle_ice=True,
    callback_token="server-token",
    ksm_config="server-config",
    signal_callback=on_signal
)

# Get the offer SDP to send to the client
# NOTE: All SDP (offers, answers) are base64-encoded - use them directly, don't decode!
server_offer = server_result['offer']  # Base64-encoded WebRTC offer
server_tube_id = server_result['tube_id']

# Create a client-side tube with the offer
client_result = registry.create_tube(
    conversation_id="tunnel-client-123",
    settings={
        "conversationType": "tunnel",
        "target_host": "192.168.1.100",
        "target_port": "22"
    },
    trickle_ice=True,
    callback_token="client-token",
    ksm_config="client-config",
    offer=server_offer,  # Pass base64-encoded offer directly (don't decode!)
    signal_callback=on_signal
)

# Get the answer SDP to send back to server
client_answer = client_result['answer']  # Base64-encoded WebRTC answer
client_tube_id = client_result['tube_id']

# Set the remote description on the server
# NOTE: Pass base64-encoded answer directly
registry.set_remote_description(server_tube_id, client_answer, is_answer=True)

# Check connection state
state = registry.get_connection_state(server_tube_id)
print(f"Connection state: {state}")

# Close when done
registry.close_tube(server_tube_id)
registry.close_tube(client_tube_id)

Server Mode with TCP Listener

For server tubes that listen for external TCP connections:

# Create server tube with TCP listener (dynamic port)
server_result = registry.create_tube(
    conversation_id="tcp-tunnel",
    settings={
        "conversationType": "tunnel",
        "local_listen_addr": "127.0.0.1:0"  # 0 = dynamic port assignment
    },
    trickle_ice=True,
    callback_token="token",
    ksm_config="config",
    signal_callback=on_signal
)

# Get actual listening address (port assigned by OS)
listen_addr = server_result['actual_local_listen_addr']  # "127.0.0.1:59194"
host, port = listen_addr.split(':')

# External clients can now connect to this address
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((host, int(port)))
# Data flows: TCP → WebRTC → Remote tube → Remote target

API Documentation: See docs/PYTHON_API_CONTRACT.md for complete API reference including:

  • Base64 SDP encoding requirements
  • Return value specifications
  • Migration guides and common pitfalls

Features

  • 🔒 Memory Safety: Rust-powered implementation prevents buffer overflows and memory corruption
  • 🛡️ Reliable Architecture: Lock-free design eliminates race conditions and ensures stability
  • ⚡ Efficient Performance: Optimized for speed without compromising security or stability
  • 🌊 Tube Abstraction: High-level API for managing WebRTC-based secure tunnels
  • 🌍 Cross-Platform: Secure, consistent behavior across Linux, macOS, Windows, Alpine
  • 🐍 Python Integration: Built with abi3 for maximum compatibility (Python 3.7+)
  • 🔧 Production Hardened: Comprehensive error handling and graceful degradation

Tube API Architecture

This implementation provides a Tube-based abstraction over WebRTC:

Security Features

  • Memory-Safe Operations: Rust's ownership system prevents common security vulnerabilities
  • Bounds Checking: Comprehensive validation prevents buffer overflows and data corruption
  • Zero Unsafe Code: Hot paths use only verified, safe Rust code (except vetted SIMD intrinsics)
  • Graceful Error Handling: Robust error recovery prevents crashes and data leaks

Tube Management

  • Multi-Connection Support: Each tube can manage multiple WebRTC connections
  • Channel Abstraction: High-level channel management for different protocols
  • State Management: Comprehensive connection state tracking and reporting
  • Signal Handling: Event-driven architecture for ICE candidates and state changes

Performance Features

  • SIMD Optimization: Hardware-accelerated frame parsing with safe fallbacks
  • Zero-Copy Pipelines: Efficient data handling minimizes memory overhead
  • Event-Driven Design: Native WebRTC events provide responsive communication
  • Always Optimized: Maximum efficiency by default, no configuration required

Tube API Reference

Core Methods

  • create_tube(conversation_id, settings, ...) - Create a new secure tube or add conversation to existing tube
  • set_remote_description(tube_id, sdp, is_answer) - Set remote SDP description
  • add_ice_candidate(tube_id, candidate) - Add ICE candidate for connection
  • get_connection_state(tube_id) - Get current connection state
  • close_connection(connection_id) - Close specific connection
  • close_tube(tube_id) - Close entire tube

Conversation Types

The tube API supports different communication patterns:

  • tunnel - Secure TCP tunneling through WebRTC
  • guacd - Apache Guacamole protocol tunneling
  • socks5 - SOCKS5 proxy tunneling

Build & Verification

To build and verify the implementation:

# Standard build (all optimizations enabled)
cargo build --release

# Run comprehensive test suite
cargo test --release

# Optional: Enable debug logging for troubleshooting
cargo build --release --features production_debug

Why This Implementation?

Built specifically for Keeper Security's tunneling requirements:

  • Security-First Design: Memory safety and comprehensive validation prevent vulnerabilities
  • Mission-Critical Reliability: Lock-free architecture ensures stable operation under load
  • Optimized for Security Applications: Performance optimizations that don't compromise security
  • Tube Abstraction: High-level API designed specifically for secure tunneling use cases

The secure, stable, high-performance tube communication system for enterprise security applications.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keeper_pam_webrtc_rs-1.1.3.tar.gz (381.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

keeper_pam_webrtc_rs-1.1.3-cp37-abi3-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.7+Windows x86-64

keeper_pam_webrtc_rs-1.1.3-cp37-abi3-musllinux_1_2_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ x86-64

keeper_pam_webrtc_rs-1.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

keeper_pam_webrtc_rs-1.1.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

keeper_pam_webrtc_rs-1.1.3-cp37-abi3-macosx_11_0_arm64.whl (7.2 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

keeper_pam_webrtc_rs-1.1.3-cp37-abi3-macosx_10_12_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file keeper_pam_webrtc_rs-1.1.3.tar.gz.

File metadata

  • Download URL: keeper_pam_webrtc_rs-1.1.3.tar.gz
  • Upload date:
  • Size: 381.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3.tar.gz
Algorithm Hash digest
SHA256 af0220fce1c02cd95f283adb60bba1d9000eb6d83c5b7e18bc15a1fd260a764f
MD5 e909300c296cb8719c6a901151d016f7
BLAKE2b-256 4a9212e1f87f67c1aca5a69a5fc97fb1702145c37a310fd65b3b06fb806e1f6a

See more details on using hashes here.

File details

Details for the file keeper_pam_webrtc_rs-1.1.3-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 aa0a5d2163a8d7746c211169c348dfedf2889c1b04537a00e96f81785059fb5e
MD5 a17cf0b5c487ddaf7fab33edf077c976
BLAKE2b-256 2f1d4d9a5c030bddc1b262a0b6648f9d1732b0c54ae487a0088486a6bf842301

See more details on using hashes here.

File details

Details for the file keeper_pam_webrtc_rs-1.1.3-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f3808148a46185635addeee6f11c36105b76ddfe8263a206ad5908f99f150f72
MD5 01808f6520f7b6787adf658dec9e9f1f
BLAKE2b-256 53b41e5cbfd82c9b34702eb890e39e8f98788272ba7e9e6b6b5a52cce391fee6

See more details on using hashes here.

File details

Details for the file keeper_pam_webrtc_rs-1.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d2047eafc0b09cb97b3119f18c67998a5b2f746fb3a7c3bbf7566e78a325b91
MD5 5d2d706a0a8e2331dff294defc3f647b
BLAKE2b-256 f9c94fc130874b772c7206830295a09713d12f644a56002adec14a222368380c

See more details on using hashes here.

File details

Details for the file keeper_pam_webrtc_rs-1.1.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f9925c2b7b6e93fa9998d4650cac7e27dd48fce8e8d38c82710b056874564bb7
MD5 de608d044656925bcce57d1c21c84aed
BLAKE2b-256 440603f8d20740ed48544a730480ce7f4094af383e2fc167623cabb369f21f17

See more details on using hashes here.

File details

Details for the file keeper_pam_webrtc_rs-1.1.3-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c9f001c1dc3a7cb730a2607b45242a69c5c0c74809840ba93954aa93581b350
MD5 616a5e3f78682a254f07ee82d456e913
BLAKE2b-256 37622be6aa26879c142cb5d63ef75fde4422290b2449702f4764fc5c16da5e0a

See more details on using hashes here.

File details

Details for the file keeper_pam_webrtc_rs-1.1.3-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for keeper_pam_webrtc_rs-1.1.3-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a7cb0e3ca4f46c57d62b736b1a177b865615e7a4181703ad2439fcc3708c39f7
MD5 b5ff9f2ea14d51ad033e769f0e1b93f4
BLAKE2b-256 e90a2dec4737945fc15bf6bd2c8212acabb8941e49e09cd3f3f36558fd8a054c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page