Rename product to OrbitWard
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
script_location = alembic
|
||||
prepend_sys_path = .
|
||||
|
||||
sqlalchemy.url = postgresql+psycopg://orbitalward:orbitalward@postgres:5432/orbitalward
|
||||
sqlalchemy.url = postgresql+psycopg://orbitward:orbitward@postgres:5432/orbitward
|
||||
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Initial OrbitalWard schema.
|
||||
"""Initial OrbitWard schema.
|
||||
|
||||
Revision ID: 20260522_0001
|
||||
Revises:
|
||||
|
||||
@@ -1 +1 @@
|
||||
"""OrbitalWard backend package."""
|
||||
"""OrbitWard backend package."""
|
||||
|
||||
@@ -5,4 +5,4 @@ router = APIRouter(tags=["health"])
|
||||
|
||||
@router.get("/health")
|
||||
def health() -> dict[str, str]:
|
||||
return {"status": "ok", "service": "orbitalward-backend"}
|
||||
return {"status": "ok", "service": "orbitward-backend"}
|
||||
|
||||
@@ -14,7 +14,7 @@ router = APIRouter(prefix="/notifications/channels", tags=["notifications"])
|
||||
|
||||
def _channel_to_read(channel: NotificationChannel) -> NotificationChannelRead:
|
||||
settings = dict(channel.settings or {})
|
||||
settings.setdefault("username", "OrbitalWard")
|
||||
settings.setdefault("username", "OrbitWard")
|
||||
return NotificationChannelRead(
|
||||
id=channel.id,
|
||||
name=channel.name,
|
||||
@@ -40,7 +40,7 @@ def create_channel(
|
||||
db: Session = Depends(get_db),
|
||||
) -> NotificationChannelRead:
|
||||
channel_settings = dict(payload.settings or {})
|
||||
channel_settings.setdefault("username", "OrbitalWard")
|
||||
channel_settings.setdefault("username", "OrbitWard")
|
||||
channel = NotificationChannel(
|
||||
name=payload.name,
|
||||
channel_type=payload.channel_type,
|
||||
@@ -70,8 +70,8 @@ def test_channel(
|
||||
response = httpx.post(
|
||||
url,
|
||||
json={
|
||||
"username": (channel.settings or {}).get("username") or "OrbitalWard",
|
||||
"text": f"OrbitalWard test notification for {channel.name}",
|
||||
"username": (channel.settings or {}).get("username") or "OrbitWard",
|
||||
"text": f"OrbitWard test notification for {channel.name}",
|
||||
},
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
@@ -20,12 +20,12 @@ def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
def create_access_token(subject: str) -> str:
|
||||
expires_at = datetime.now(UTC) + timedelta(minutes=settings.access_token_expire_minutes)
|
||||
payload = {"sub": subject, "exp": expires_at}
|
||||
return jwt.encode(payload, settings.orbitalward_secret_key, algorithm=ALGORITHM)
|
||||
return jwt.encode(payload, settings.orbitward_secret_key, algorithm=ALGORITHM)
|
||||
|
||||
|
||||
def decode_access_token(token: str) -> str | None:
|
||||
try:
|
||||
payload = jwt.decode(token, settings.orbitalward_secret_key, algorithms=[ALGORITHM])
|
||||
payload = jwt.decode(token, settings.orbitward_secret_key, algorithms=[ALGORITHM])
|
||||
return payload.get("sub")
|
||||
except JWTError:
|
||||
return None
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic import AnyHttpUrl, Field
|
||||
from pydantic import AliasChoices, AnyHttpUrl, Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||||
|
||||
orbitalward_env: str = "development"
|
||||
orbitalward_secret_key: str = Field(default="change-me", min_length=8)
|
||||
database_url: str = "postgresql+psycopg://orbitalward:orbitalward@postgres:5432/orbitalward"
|
||||
orbitward_env: str = Field(default="development", validation_alias=AliasChoices("ORBITWARD_ENV", "ORBITALWARD_ENV"))
|
||||
orbitward_secret_key: str = Field(
|
||||
default="change-me",
|
||||
min_length=8,
|
||||
validation_alias=AliasChoices("ORBITWARD_SECRET_KEY", "ORBITALWARD_SECRET_KEY"),
|
||||
)
|
||||
database_url: str = "postgresql+psycopg://orbitward:orbitward@postgres:5432/orbitward"
|
||||
redis_url: str = "redis://redis:6379/0"
|
||||
frontend_url: AnyHttpUrl | str = "http://localhost:5173"
|
||||
backend_url: AnyHttpUrl | str = "http://localhost:8000"
|
||||
|
||||
@@ -7,7 +7,7 @@ from app.core.config import settings
|
||||
|
||||
|
||||
def _fernet() -> Fernet:
|
||||
digest = hashlib.sha256(settings.orbitalward_secret_key.encode("utf-8")).digest()
|
||||
digest = hashlib.sha256(settings.orbitward_secret_key.encode("utf-8")).digest()
|
||||
return Fernet(base64.urlsafe_b64encode(digest))
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ async def lifespan(_: FastAPI) -> AsyncIterator[None]:
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="OrbitalWard API",
|
||||
title="OrbitWard API",
|
||||
version="0.1.0",
|
||||
description="Self-hosted infrastructure monitoring API",
|
||||
lifespan=lifespan,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "orbitalward-backend"
|
||||
name = "orbitward-backend"
|
||||
version = "0.1.0"
|
||||
description = "OrbitalWard FastAPI backend"
|
||||
description = "OrbitWard FastAPI backend"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"alembic>=1.13.3",
|
||||
|
||||
@@ -11,8 +11,8 @@ def test_notification_channel_does_not_return_saved_secret(client: TestClient, d
|
||||
json={
|
||||
"name": "Operations Webhook",
|
||||
"channel_type": "generic_webhook",
|
||||
"settings": {"username": "OrbitalWard"},
|
||||
"secret": "https://hooks.example.test/orbitalward",
|
||||
"settings": {"username": "OrbitWard"},
|
||||
"secret": "https://hooks.example.test/orbitward",
|
||||
"is_enabled": True,
|
||||
},
|
||||
)
|
||||
@@ -25,8 +25,8 @@ def test_notification_channel_does_not_return_saved_secret(client: TestClient, d
|
||||
|
||||
channel = db_session.get(NotificationChannel, body["id"])
|
||||
assert channel is not None
|
||||
assert channel.encrypted_secret != "https://hooks.example.test/orbitalward"
|
||||
assert decrypt_secret(channel.encrypted_secret) == "https://hooks.example.test/orbitalward"
|
||||
assert channel.encrypted_secret != "https://hooks.example.test/orbitward"
|
||||
assert decrypt_secret(channel.encrypted_secret) == "https://hooks.example.test/orbitward"
|
||||
|
||||
list_response = client.get("/notifications/channels")
|
||||
assert list_response.status_code == 200
|
||||
@@ -42,7 +42,7 @@ def test_notification_channel_update_without_secret_preserves_existing_secret(cl
|
||||
json={
|
||||
"name": "Mattermost",
|
||||
"channel_type": "mattermost",
|
||||
"settings": {"username": "OrbitalWard"},
|
||||
"settings": {"username": "OrbitWard"},
|
||||
"secret": "https://hooks.example.test/mattermost",
|
||||
"is_enabled": True,
|
||||
},
|
||||
@@ -54,7 +54,7 @@ def test_notification_channel_update_without_secret_preserves_existing_secret(cl
|
||||
f"/notifications/channels/{channel_id}",
|
||||
json={
|
||||
"name": "Mattermost Alerts",
|
||||
"settings": {"username": "OrbitalWard Alerts"},
|
||||
"settings": {"username": "OrbitWard Alerts"},
|
||||
"is_enabled": False,
|
||||
},
|
||||
)
|
||||
@@ -62,7 +62,7 @@ def test_notification_channel_update_without_secret_preserves_existing_secret(cl
|
||||
assert update_response.status_code == 200
|
||||
body = update_response.json()
|
||||
assert body["name"] == "Mattermost Alerts"
|
||||
assert body["settings"]["username"] == "OrbitalWard Alerts"
|
||||
assert body["settings"]["username"] == "OrbitWard Alerts"
|
||||
assert body["is_enabled"] is False
|
||||
assert body["has_secret"] is True
|
||||
assert "secret" not in body
|
||||
|
||||
Reference in New Issue
Block a user