diff --git a/README.md b/README.md index f0a3026..1e04373 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ LangMem uses a hybrid approach combining: - ๐ **Rich Metadata**: Flexible memory attributes - ๐ **Secure API**: Bearer token authentication - ๐ณ **Docker Ready**: Containerized deployment +- ๐ **Protected Documentation**: Basic auth-protected docs - ๐งช **Comprehensive Tests**: Unit and integration tests ## Quick Start @@ -278,6 +279,44 @@ For production deployment: 4. Set up monitoring and logging 5. Configure backup procedures +## Documentation + +The LangMem project includes comprehensive documentation with authentication protection. + +### Accessing Documentation + +Start the authenticated documentation server: + +```bash +# Start documentation server on port 8080 (default) +./start-docs-server.sh + +# Or specify a custom port +./start-docs-server.sh 8090 +``` + +**Access Credentials:** +- **Username:** `langmem` +- **Password:** `langmem2025` + +**Available Documentation:** +- ๐ **Main Docs**: System overview and features +- ๐๏ธ **Architecture**: Detailed system architecture +- ๐ก **API Reference**: Complete API documentation +- ๐ ๏ธ **Implementation**: Step-by-step setup guide + +### Direct Server Usage + +You can also run the documentation server directly: + +```bash +python3 docs_server.py [port] +``` + +Then visit: `http://localhost:8080` (or your specified port) + +Your browser will prompt for authentication credentials. + ## Contributing 1. Fork the repository diff --git a/docs_server.py b/docs_server.py new file mode 100755 index 0000000..cba47d4 --- /dev/null +++ b/docs_server.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +""" +Simple authenticated web server for LangMem documentation +""" + +import http.server +import socketserver +import base64 +import os +from urllib.parse import parse_qs + +# Authentication credentials +USERNAME = "langmem" +PASSWORD = "langmem2025" + +class AuthHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): + """HTTP handler with basic authentication""" + + def __init__(self, *args, **kwargs): + super().__init__(*args, directory="docs", **kwargs) + + def do_GET(self): + """Handle GET requests with authentication""" + if self.authenticate(): + super().do_GET() + else: + self.send_auth_request() + + def authenticate(self): + """Check if request has valid authentication""" + auth_header = self.headers.get('Authorization') + + if not auth_header: + return False + + try: + auth_type, credentials = auth_header.split(' ', 1) + if auth_type.lower() != 'basic': + return False + + decoded = base64.b64decode(credentials).decode('utf-8') + username, password = decoded.split(':', 1) + + return username == USERNAME and password == PASSWORD + + except Exception: + return False + + def send_auth_request(self): + """Send authentication request to client""" + self.send_response(401) + self.send_header('WWW-Authenticate', 'Basic realm="LangMem Documentation"') + self.send_header('Content-type', 'text/html') + self.end_headers() + + html = """ + + +
+Authentication required to access documentation.
+Username: langmem
+ Password: langmem2025
Please refresh the page and enter your credentials when prompted.
+