Compare commits
66 Commits
0f16bab2b8
...
017-llm-an
| Author | SHA1 | Date | |
|---|---|---|---|
| 303d7272f8 | |||
| 0711ded532 | |||
| 495857bbee | |||
| df7582a8db | |||
| 3802b0af8c | |||
| 1702f3a5e9 | |||
| 83c24d4b85 | |||
| dd596698e5 | |||
| 0fee26a846 | |||
| 35096b5e23 | |||
| 0299728d72 | |||
| de6ff0d41b | |||
| 260a90aac5 | |||
| 56a1508b38 | |||
| 7c0a601499 | |||
| a5b1bba226 | |||
| 8f13ed3031 | |||
| 305b07bf8b | |||
| 4e1992f489 | |||
| ac7a6cfadc | |||
| 29daebd628 | |||
| 71873b7bb3 | |||
| 68b25c90a8 | |||
| e9b8794f1a | |||
| 6d94d26e40 | |||
| 598dd50d1d | |||
| eacb88a0e3 | |||
| 10676b7029 | |||
| 2023f6c211 | |||
| 2111c12d0a | |||
| b46133e4c1 | |||
| 6cc2fb4c9b | |||
| c406f71988 | |||
| 55bdd981b1 | |||
| 15843a4607 | |||
| 8b81bb9f1f | |||
| 7f244a8252 | |||
| c0505b4d4f | |||
| 1b863bea1b | |||
| 7c6c959774 | |||
| 554e1128b8 | |||
| 55ca476972 | |||
| 4b4d23e671 | |||
| e80369c8b5 | |||
| ffe942c9dd | |||
| 19744796e4 | |||
| a6bebe295c | |||
| e2ce346b7b | |||
| 789e5a90e3 | |||
| 163d03e6f5 | |||
| 169237b31b | |||
| 45bb8c5429 | |||
| 17c28433bd | |||
| 077daa0245 | |||
| d38cda09dd | |||
| 1a893c0bc0 | |||
| 40ed375aa4 | |||
| 5fdc92fcdf | |||
| e83328b4ff | |||
| 687f4ce565 | |||
| dc9e9e0588 | |||
| 2de3e53ab2 | |||
| 40ea0580d9 | |||
| 8da906738b | |||
| d5a1c0e091 | |||
| ef7a0fcf92 |
Binary file not shown.
@@ -19,7 +19,7 @@ import os
|
|||||||
class EncryptionManager:
|
class EncryptionManager:
|
||||||
# @INVARIANT: Uses a secret key from environment or a default one (fallback only for dev).
|
# @INVARIANT: Uses a secret key from environment or a default one (fallback only for dev).
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.key = os.getenv("ENCRYPTION_KEY", "ZcytYzi0iHIl4Ttr-GdAEk117aGRogkGvN3wiTxrPpE=").encode()
|
self.key = os.getenv("ENCRYPTION_KEY", "REMOVED_HISTORICAL_SECRET_DO_NOT_USE").encode()
|
||||||
self.fernet = Fernet(self.key)
|
self.fernet = Fernet(self.key)
|
||||||
|
|
||||||
def encrypt(self, data: str) -> str:
|
def encrypt(self, data: str) -> str:
|
||||||
|
|||||||
BIN
backend/tasks.db
BIN
backend/tasks.db
Binary file not shown.
@@ -1,78 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""Debug script to test Superset API authentication"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
from pprint import pprint
|
|
||||||
from src.core.superset_client import SupersetClient
|
|
||||||
from src.core.config_manager import ConfigManager
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
print("Debugging Superset API authentication...")
|
|
||||||
|
|
||||||
config = ConfigManager()
|
|
||||||
|
|
||||||
# Select first available environment
|
|
||||||
environments = config.get_environments()
|
|
||||||
|
|
||||||
if not environments:
|
|
||||||
print("No environments configured")
|
|
||||||
return
|
|
||||||
|
|
||||||
env = environments[0]
|
|
||||||
print(f"\nTesting environment: {env.name}")
|
|
||||||
print(f"URL: {env.url}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Test API client authentication
|
|
||||||
print("\n--- Testing API Authentication ---")
|
|
||||||
client = SupersetClient(env)
|
|
||||||
tokens = client.authenticate()
|
|
||||||
|
|
||||||
print("\nAPI Auth Success!")
|
|
||||||
print(f"Access Token: {tokens.get('access_token', 'N/A')}")
|
|
||||||
print(f"CSRF Token: {tokens.get('csrf_token', 'N/A')}")
|
|
||||||
|
|
||||||
# Debug cookies from session
|
|
||||||
print("\n--- Session Cookies ---")
|
|
||||||
for cookie in client.network.session.cookies:
|
|
||||||
print(f"{cookie.name}={cookie.value}")
|
|
||||||
|
|
||||||
# Test accessing UI via requests
|
|
||||||
print("\n--- Testing UI Access ---")
|
|
||||||
ui_url = env.url.rstrip('/').replace('/api/v1', '')
|
|
||||||
print(f"UI URL: {ui_url}")
|
|
||||||
|
|
||||||
# Try to access UI home page
|
|
||||||
ui_response = client.network.session.get(ui_url, timeout=30, allow_redirects=True)
|
|
||||||
print(f"Status Code: {ui_response.status_code}")
|
|
||||||
print(f"URL: {ui_response.url}")
|
|
||||||
|
|
||||||
# Check response headers
|
|
||||||
print("\n--- Response Headers ---")
|
|
||||||
pprint(dict(ui_response.headers))
|
|
||||||
|
|
||||||
print(f"\n--- Response Content Preview (200 chars) ---")
|
|
||||||
print(repr(ui_response.text[:200]))
|
|
||||||
|
|
||||||
if ui_response.status_code == 200:
|
|
||||||
print("\nUI Access: Success")
|
|
||||||
|
|
||||||
# Try to access a dashboard
|
|
||||||
# For testing, just use the home page
|
|
||||||
print("\n--- Checking if login is required ---")
|
|
||||||
if "login" in ui_response.url.lower() or "login" in ui_response.text.lower():
|
|
||||||
print("❌ Not logged in to UI")
|
|
||||||
else:
|
|
||||||
print("✅ Logged in to UI")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"\n❌ Error: {type(e).__name__}: {e}")
|
|
||||||
import traceback
|
|
||||||
print("\nStack Trace:")
|
|
||||||
print(traceback.format_exc())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""Test script to debug API key decryption issue."""
|
|
||||||
|
|
||||||
from src.core.database import SessionLocal
|
|
||||||
from src.models.llm import LLMProvider
|
|
||||||
from cryptography.fernet import Fernet
|
|
||||||
import os
|
|
||||||
|
|
||||||
# Get the encryption key
|
|
||||||
key = os.getenv("ENCRYPTION_KEY", "ZcytYzi0iHIl4Ttr-GdAEk117aGRogkGvN3wiTxrPpE=").encode()
|
|
||||||
print(f"Encryption key (first 20 chars): {key[:20]}")
|
|
||||||
print(f"Encryption key length: {len(key)}")
|
|
||||||
|
|
||||||
# Create Fernet instance
|
|
||||||
fernet = Fernet(key)
|
|
||||||
|
|
||||||
# Get provider from database
|
|
||||||
db = SessionLocal()
|
|
||||||
provider = db.query(LLMProvider).filter(LLMProvider.id == '6c899741-4108-4196-aea4-f38ad2f0150e').first()
|
|
||||||
|
|
||||||
if provider:
|
|
||||||
print(f"\nProvider found:")
|
|
||||||
print(f" ID: {provider.id}")
|
|
||||||
print(f" Name: {provider.name}")
|
|
||||||
print(f" Encrypted API Key (first 50 chars): {provider.api_key[:50]}")
|
|
||||||
print(f" Encrypted API Key Length: {len(provider.api_key)}")
|
|
||||||
|
|
||||||
# Test decryption
|
|
||||||
print(f"\nAttempting decryption...")
|
|
||||||
try:
|
|
||||||
decrypted = fernet.decrypt(provider.api_key.encode()).decode()
|
|
||||||
print(f"Decryption successful!")
|
|
||||||
print(f" Decrypted key length: {len(decrypted)}")
|
|
||||||
print(f" Decrypted key (first 8 chars): {decrypted[:8]}")
|
|
||||||
print(f" Decrypted key is empty: {len(decrypted) == 0}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Decryption failed with error: {e}")
|
|
||||||
print(f"Error type: {type(e).__name__}")
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
else:
|
|
||||||
print("Provider not found")
|
|
||||||
|
|
||||||
db.close()
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[{"key[": 20, ")\n\n# Create Fernet instance\nfernet = Fernet(key)\n\n# Test encrypting an empty string\nempty_encrypted = fernet.encrypt(b\"": ".", "print(f": "nEncrypted empty string: {empty_encrypted"}, {"test-api-key-12345\"\ntest_encrypted = fernet.encrypt(test_key.encode()).decode()\nprint(f": "nEncrypted test key: {test_encrypted"}, {"gAAAAABphhwSZie0OwXjJ78Fk-c4Uo6doNJXipX49AX7Bypzp4ohiRX3hXPXKb45R1vhNUOqbm6Ke3-eRwu_KdWMZ9chFBKmqw==\"\nprint(f": "nStored encrypted key: {stored_key"}, {"len(stored_key)}": "Check if stored key matches empty string encryption\nif stored_key == empty_encrypted:\n print(", "string!": "else:\n print(", "print(f": "mpty string encryption: {empty_encrypted"}, {"stored_key}": "Try to decrypt the stored key\ntry:\n decrypted = fernet.decrypt(stored_key.encode()).decode()\n print(f", "print(f": "ecrypted key length: {len(decrypted)"}, {")\nexcept Exception as e:\n print(f": "nDecryption failed with error: {e"}]
|
|
||||||
Reference in New Issue
Block a user