File size: 622 Bytes
40acccd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os

# Default password if not set in environment
DEFAULT_PASSWORD = "123456"

# Get password from environment variable or use default
API_KEY = os.environ.get("API_KEY", DEFAULT_PASSWORD)

# Function to validate API key
def validate_api_key(api_key: str) -> bool:
    """
    Validate the provided API key against the configured key
    
    Args:
        api_key: The API key to validate
        
    Returns:
        bool: True if the key is valid, False otherwise
    """
    if not API_KEY:
        # If no API key is configured, authentication is disabled
        return True
    
    return api_key == API_KEY