Skip to content

armgit / ARES

Public Imported from GitHub
0

ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.

refactor(auth): standardize all SSO messages, docstrings, and docs to English

Mafifrizi6a41622ec363
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e308153..7850b8a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,6 +14,8 @@ env:
ARES_SECRET_KEY: "ci-secret-key-placeholder-min32chars!!"
ARES_ENCRYPTION_KEY: "ci-encryption-key-placeholder-32chars"
ARES_DEFAULT_ADMIN_PASSWORD: "CiAdmin1!-placeholder-secret99"
+ ARES_DEBUG: "true"
+ ARES_BROWSER_ORIGIN: "http://127.0.0.1:5173"
jobs:
backend:
diff --git a/ares/api/server.py b/ares/api/server.py
index 5d737a4..3b5efb5 100644
--- a/ares/api/server.py
+++ b/ares/api/server.py
@@ -1428,14 +1428,14 @@ async def sso_initiate(
if not organization or not organization.get("is_active"):
raise HTTPException(
400,
- detail="SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.",
+ detail="SSO is not configured for this organization. Contact your administrator.",
)
sso_config = await db.get_sso_config(organization["id"])
if not sso_config or not sso_config.get("is_enabled"):
raise HTTPException(
400,
- detail="SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.",
+ detail="SSO is not configured for this organization. Contact your administrator.",
)
base_url = str(request.base_url).rstrip("/")
@@ -1450,7 +1450,7 @@ async def sso_initiate(
redirect_url, request_id = build_saml_auth_request(sso_config, base_url, settings)
except Exception as exc:
logger.warning("sso_saml_init_failed", error=str(exc))
- raise HTTPException(400, detail="SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.") from None
+ raise HTTPException(400, detail="SSO is not configured for this organization. Contact your administrator.") from None
await db.create_sso_flow_state(organization["id"], "saml", request_id, ttl_minutes=10)
return {
@@ -1466,7 +1466,7 @@ async def sso_initiate(
redirect_url, state, nonce = build_oidc_auth_request(sso_config, redirect_uri)
except Exception as exc:
logger.warning("sso_oidc_init_failed", error=str(exc))
- raise HTTPException(400, detail="SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.") from None
+ raise HTTPException(400, detail="SSO is not configured for this organization. Contact your administrator.") from None
await db.create_sso_flow_state(organization["id"], "oidc", state, nonce=nonce, ttl_minutes=10)
return {
diff --git a/ares/db/database.py b/ares/db/database.py
index 5fd50d5..ca5b119 100644
--- a/ares/db/database.py
+++ b/ares/db/database.py
@@ -1939,7 +1939,7 @@ class AresDatabase:
return str(row["id"])
async def get_hosts(self, campaign_id: str) -> list[dict]:
- """FIX: method getter yang sebelumnya tidak ada."""
+ """Retrieve all hosts recorded for a campaign."""
async with self._conn.execute(
"SELECT * FROM hosts WHERE campaign_id=? ORDER BY first_seen", (campaign_id,)
) as cur:
@@ -2018,7 +2018,7 @@ class AresDatabase:
return [dict(r) for r in await cur.fetchall()]
async def get_credentials(self, campaign_id: str, decrypt: bool = False) -> list[dict]:
- """FIX: method getter yang sebelumnya tidak ada."""
+ """Retrieve all credentials captured for a campaign."""
async with self._conn.execute(
"SELECT * FROM credentials WHERE campaign_id=? ORDER BY captured_at", (campaign_id,)
) as cur:
@@ -2069,7 +2069,7 @@ class AresDatabase:
return ExecutionLifecycleStore(self._conn, "sqlite")
async def get_loot(self, campaign_id: str, decrypt: bool = False) -> list[dict]:
- """FIX: method getter yang sebelumnya tidak ada."""
+ """Retrieve all loot items captured for a campaign."""
async with self._conn.execute(
"SELECT * FROM loot WHERE campaign_id=? ORDER BY captured_at", (campaign_id,)
) as cur:
diff --git a/ares/modules/ai/autonomous_planner.py b/ares/modules/ai/autonomous_planner.py
index 2e4d972..5b38aa0 100644
--- a/ares/modules/ai/autonomous_planner.py
+++ b/ares/modules/ai/autonomous_planner.py
@@ -83,7 +83,7 @@ def _build_round_narrative(completed_rounds: list) -> str:
if not completed_rounds:
return "Round 1 — no prior history."
- lines = ["=== HISTORY ROUNDS SEBELUMNYA ==="]
+ lines = ["=== PREVIOUS ROUNDS HISTORY ==="]
for r in completed_rounds[-3:]: # max 3 rounds back
lines.append(
f"Round {r.round_num} "
diff --git a/docs/sso-setup.md b/docs/sso-setup.md
index b6f3aa4..b5242c9 100644
--- a/docs/sso-setup.md
+++ b/docs/sso-setup.md
@@ -16,11 +16,10 @@ This document provides a comprehensive guide for configuring and utilizing **Ent
> [!NOTE]
> **Federated Account Lockdown**: If your account has been provisioned or migrated to SSO (`auth_provider = 'saml'` or `'oidc'`), your account is **strictly prohibited** from authenticating with a local password. You must authenticate using the **"Or continue with SSO"** workflow.
-### Understanding: *"SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin."*
+### Understanding: *"SSO is not configured for this organization. Contact your administrator."*
If you click **"Or continue with SSO"** and an inline warning appears:
-> ⚠️ **SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.**
-> *(English translation: "SSO is not configured for this organization. Contact admin.")*
+> ⚠️ **SSO is not configured for this organization. Contact your administrator.**
**What this means:**
1. SSO federation (SAML 2.0 or OIDC) has not yet been registered for the target organization, or the configuration is currently disabled (`is_enabled = 0`).
diff --git a/frontend/src/features/auth/LoginPage.tsx b/frontend/src/features/auth/LoginPage.tsx
index ec716a9..df90bc2 100644
--- a/frontend/src/features/auth/LoginPage.tsx
+++ b/frontend/src/features/auth/LoginPage.tsx
@@ -57,10 +57,10 @@ export function LoginPage() {
if (res?.redirect_url) {
window.location.href = res.redirect_url;
} else {
- setSsoError("SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.");
+ setSsoError("SSO is not configured for this organization. Contact your administrator.");
}
} catch (exc) {
- setSsoError("SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin.");
+ setSsoError("SSO is not configured for this organization. Contact your administrator.");
} finally {
setIsSsoLoading(false);
}
diff --git a/tests/unit/test_sso_enterprise.py b/tests/unit/test_sso_enterprise.py
index 1e7d146..04dcdef 100644
--- a/tests/unit/test_sso_enterprise.py
+++ b/tests/unit/test_sso_enterprise.py
@@ -19,6 +19,13 @@ from unittest.mock import AsyncMock, patch
import pytest
from httpx import ASGITransport, AsyncClient
+# ── env bootstrap (before any ares import) ────────────────────────────────────
+os.environ.setdefault("ARES_SECRET_KEY", "test-sso-secret-key-min32-chars!!")
+os.environ.setdefault("ARES_ENCRYPTION_KEY", "test-enc-key-min32-chars-xxxxxxx")
+os.environ.setdefault("ARES_DEFAULT_ADMIN_PASSWORD", "TestSsoPass1!")
+os.environ.setdefault("ARES_DEBUG", "true")
+os.environ.setdefault("ARES_BROWSER_ORIGIN", "http://127.0.0.1:5173")
+
from ares.core.config import AresSettings, get_settings
from ares.core.security import DataEncryptor, hash_password
from ares.core.sso import (
@@ -188,7 +195,7 @@ async def test_sso_init_unconfigured_error(tmp_path):
resp = await client.get("/auth/sso/init?org=default")
assert resp.status_code == 400
data = resp.json()
- assert "SSO belum dikonfigurasi untuk organisasi ini. Hubungi admin." in data.get("detail", "")
+ assert "SSO is not configured for this organization. Contact your administrator." in data.get("detail", "")
finally:
app.dependency_overrides.pop(get_db, None)
await db.close()
@@ -240,7 +247,7 @@ async def test_sso_init_configured_success(tmp_path, test_settings):
@pytest.mark.asyncio
async def test_sso_user_blocked_at_auth_token_endpoint(tmp_path):
"""Verify /auth/token explicitly rejects login attempts for SSO users, even with bcrypt match."""
- from ares.api.server import app, get_db
+ from ares.api.server import app, get_db, get_settings
db_file = tmp_path / "test_auth_token_block.db"
db = AresDatabase(str(db_file))
@@ -257,6 +264,13 @@ async def test_sso_user_blocked_at_auth_token_endpoint(tmp_path):
)
app.dependency_overrides[get_db] = lambda: db
+ app.dependency_overrides[get_settings] = lambda: AresSettings(
+ ares_secret_key="test-sso-secret-key-min32-chars!!",
+ ares_encryption_key="test-enc-key-min32-chars-xxxxxxx",
+ ares_default_admin_password="TestSsoPass1!",
+ ares_debug=True,
+ ares_browser_origin="http://127.0.0.1:5173",
+ )
try:
transport = ASGITransport(app=app)
@@ -280,6 +294,7 @@ async def test_sso_user_blocked_at_auth_token_endpoint(tmp_path):
assert resp.json().get("detail") == "Invalid credentials"
finally:
app.dependency_overrides.pop(get_db, None)
+ app.dependency_overrides.pop(get_settings, None)
await db.close()