api_keys.py 379 B

123456789101112
  1. from gpustack.security import API_KEY_PREFIX
  2. def get_masked_api_key_value(value: str, is_custom: bool = False) -> str:
  3. """Return masked API key value with partial access key visible."""
  4. if is_custom:
  5. return "Custom API Key"
  6. masked_value = "***"
  7. if len(value) >= 8:
  8. masked_value = f"{value[:4]}***"
  9. return f"{API_KEY_PREFIX}_{masked_value}"