Compare commits

...

1 Commits

Author SHA1 Message Date
openhands
c7ac53eaac Change API key placeholder from ******** to <hidden> 2025-03-22 22:14:22 +00:00
10 changed files with 27 additions and 12 deletions

View File

@@ -74,7 +74,7 @@ export function SettingsForm({ settings, models, onClose }: SettingsFormProps) {
}
};
const isLLMKeySet = settings.LLM_API_KEY === "**********";
const isLLMKeySet = settings.LLM_API_KEY === "<hidden>";
return (
<div>

View File

@@ -73,7 +73,7 @@ function AccountSettings() {
const hasAppSlug = !!config?.APP_SLUG;
const isGitHubTokenSet = settings?.GITHUB_TOKEN_IS_SET;
const isLLMKeySet = settings?.LLM_API_KEY === "**********";
const isLLMKeySet = settings?.LLM_API_KEY === "<hidden>";
const isAnalyticsEnabled = settings?.USER_CONSENTS_TO_ANALYTICS;
const isAdvancedSettingsSet = determineWhetherToToggleAdvancedSettings();
@@ -288,7 +288,7 @@ function AccountSettings() {
startContent={
isLLMKeySet && <KeyStatusIcon isSet={isLLMKeySet} />
}
placeholder={isLLMKeySet ? "**********" : ""}
placeholder={isLLMKeySet ? "<hidden>" : ""}
/>
)}
@@ -407,7 +407,7 @@ function AccountSettings() {
<KeyStatusIcon isSet={!!isGitHubTokenSet} />
)
}
placeholder={isGitHubTokenSet ? "**********" : ""}
placeholder={isGitHubTokenSet ? "<hidden>" : ""}
/>
<p data-testId="github-token-help-anchor" className="text-xs">
{" "}

View File

@@ -3,7 +3,8 @@ from __future__ import annotations
import os
from typing import Any
from pydantic import BaseModel, Field, SecretStr, ValidationError
from pydantic import BaseModel, Field, ValidationError
from openhands.core.utils.secret_str import SecretStr
from openhands.core.logger import LOG_DIR
from openhands.core.logger import openhands_logger as logger

View File

@@ -0,0 +1 @@
# Core utilities package

View File

@@ -0,0 +1,11 @@
from __future__ import annotations
from pydantic import SecretStr as PydanticSecretStr
class SecretStr(PydanticSecretStr):
"""Custom SecretStr class that uses <hidden> instead of ******** for display."""
def _display(self) -> str:
"""Override the default display method to use <hidden> instead of ********."""
return "<hidden>"

View File

@@ -7,13 +7,14 @@ from typing import Any, Coroutine, Literal, overload
from pydantic import (
BaseModel,
Field,
SecretStr,
SerializationInfo,
field_serializer,
model_validator,
)
from pydantic.json import pydantic_encoder
from openhands.core.utils.secret_str import SecretStr
from openhands.events.action.action import Action
from openhands.events.action.commands import CmdRunAction
from openhands.events.stream import EventStream

View File

@@ -1,5 +1,5 @@
from fastapi import Request
from pydantic import SecretStr
from openhands.core.utils.secret_str import SecretStr
from openhands.integrations.provider import PROVIDER_TOKEN_TYPE, ProviderType

View File

@@ -1,6 +1,6 @@
from fastapi import APIRouter, Request, status
from fastapi.responses import JSONResponse
from pydantic import SecretStr
from openhands.core.utils.secret_str import SecretStr
from openhands.core.logger import openhands_logger as logger
from openhands.integrations.provider import ProviderToken, ProviderType, SecretStore

View File

@@ -3,13 +3,14 @@ from __future__ import annotations
from pydantic import (
BaseModel,
Field,
SecretStr,
SerializationInfo,
field_serializer,
model_validator,
)
from pydantic.json import pydantic_encoder
from openhands.core.utils.secret_str import SecretStr
from openhands.core.config.llm_config import LLMConfig
from openhands.core.config.utils import load_app_config
from openhands.integrations.provider import SecretStore

View File

@@ -1,6 +1,6 @@
from unittest.mock import patch
from pydantic import SecretStr
from openhands.core.utils.secret_str import SecretStr
from openhands.core.config.app_config import AppConfig
from openhands.core.config.llm_config import LLMConfig
@@ -91,10 +91,10 @@ def test_settings_handles_sensitive_data():
),
)
assert str(settings.llm_api_key) == '**********'
assert str(settings.llm_api_key) == '<hidden>'
assert (
str(settings.secrets_store.provider_tokens[ProviderType.GITHUB].token)
== '**********'
== '<hidden>'
)
assert settings.llm_api_key.get_secret_value() == 'test-key'