This document provides comprehensive security guidelines for deploying and operating DeepWiki-Open in production environments. Follow these best practices to ensure your deployment is secure and protects sensitive data.
DeepWiki-Open processes source code repositories and requires access to various APIs and services. This guide covers all security aspects from API key management to network security and vulnerability handling.
Never hardcode API keys in your source code. Always use environment variables:
Copy
# .env file (never commit this to version control)GOOGLE_API_KEY=your_google_api_keyOPENAI_API_KEY=your_openai_api_keyOPENROUTER_API_KEY=your_openrouter_api_keyAZURE_OPENAI_API_KEY=your_azure_api_key
Add .env to your .gitignore file immediately after creation
2
Use Secret Management Systems
For production deployments, use dedicated secret management:
# Minimum required permissions for GitHub tokens:- repo (for private repositories)- read:org (for organization repositories)- read:user (for user information)# Create fine-grained personal access tokens when possible# Set expiration dates (maximum 90 days recommended)
Copy
# Required scopes for GitLab tokens:- read_api (for API access)- read_repository (for repository access)- read_user (for user information)# Use project or group tokens instead of personal tokens# Enable token expiration
Copy
# Required permissions for Bitbucket:- repository:read- account:read- team:read (for team repositories)# Use app passwords with minimal scopes# Regularly audit token usage
DeepWiki-Open supports optional authentication for the wiki interface:
Copy
# Enable authentication in environment variablesDEEPWIKI_AUTH_MODE=trueDEEPWIKI_AUTH_CODE=your_secure_auth_code# The auth code should be:# - At least 20 characters long# - Randomly generated# - Changed regularly
Copy
import secretsimport stringdef generate_auth_code(length=32): alphabet = string.ascii_letters + string.digits + string.punctuation return ''.join(secrets.choice(alphabet) for _ in range(length))# Generate a secure codeauth_code = generate_auth_code()print(f"DEEPWIKI_AUTH_CODE={auth_code}")
Right to Erasure: Provide cache clearing endpoints
Data Portability: Export processed wiki data
Privacy by Design: Default to secure configurations
Copy
# Example GDPR compliance endpoints@app.delete("/api/user-data/{user_id}")async def delete_user_data(user_id: str): """Implement right to erasure""" # Clear user's cached data # Remove from vector database # Delete processing history@app.get("/api/user-data/{user_id}/export")async def export_user_data(user_id: str): """Implement data portability""" # Export all user-related data
# Use specific versions, not latestFROM python:3.11-slim# Run as non-root userRUN useradd -m -u 1000 deepwikiUSER deepwiki# Use multi-stage buildsFROM node:18-alpine AS builder# Build stage...FROM node:18-alpine# Copy only necessary files