Compare commits

..
Author SHA1 Message Date
aios abee512866 test(portal): add V1R3C0 RBAC approval audit tests 2026-07-08 02:32:42 +08:00
aios af0dee05ec feat(portal): add user portal RBAC approval alert audit migration 2026-07-08 02:32:39 +08:00
aios 83d4892acb feat(portal): add RBAC approval alert audit core services 2026-07-08 02:32:35 +08:00
aios 011bc918a8 feat(portal): create V1R3C0 user portal RBAC ops implementation branch 2026-07-08 02:32:29 +08:00
aios c38c575d8e chore(release): bump baseline to V1R2C3 and create version record
- Update baseline/current.json: active_version=V1R2C3, active_tag=V1R2C3
- Create versions/V1R2C3.json with version record
- Update architecture/current.json: reflect V1R2C3
- Release reason: GPT Actions ClientResponseError compatibility recovery
- Preserve V1R2C2 rollback
- secret_plaintext_written=false
2026-07-08 01:09:02 +08:00
8 changed files with 163 additions and 45 deletions
+66
View File
@@ -0,0 +1,66 @@
"""V1R3C0 User Portal RBAC Ops core services.
Pure application layer: no secrets, no external credentials.
"""
from dataclasses import dataclass, field
from datetime import datetime, timezone
ROLES = {"user", "group_admin", "owner"}
@dataclass
class PortalContext:
user_id: str
group_id: str | None
role: str
def scope(self):
if self.role == "owner":
return "global"
if self.role == "group_admin":
return "group"
return "self"
@dataclass
class Approval:
request_id: str
request_type: str
state: str = "pending"
@dataclass
class Alert:
alert_id: str
level: str
state: str = "open"
@dataclass
class AuditEvent:
action: str
actor: str
created_at: str = field(default_factory=lambda: datetime.now(timezone.utc).isoformat())
class PortalRBACService:
def authorize(self, ctx: PortalContext, target_scope: str):
if ctx.role not in ROLES:
return False
if ctx.scope() == "global":
return True
return ctx.scope() == target_scope
def navigation(self, role: str):
common = ["/", "/me", "/model", "/usage", "/quota", "/tasks", "/alerts", "/approvals", "/audit"]
if role == "owner":
return common + ["/owner/system", "/owner/gitops", "/owner/runtime", "/owner/security"]
if role == "group_admin":
return common + ["/group", "/group/users", "/group/quota", "/group/audit"]
return common
class PortalAuditService:
def append(self, action: str, actor: str):
return AuditEvent(action=action, actor=actor)
class SecretPolicy:
@staticmethod
def redact(value: str):
return "***REDACTED***" if value else value
__all__ = ["PortalContext", "PortalRBACService", "PortalAuditService", "SecretPolicy", "Approval", "Alert"]
@@ -0,0 +1,27 @@
CREATE TABLE IF NOT EXISTS portal_approvals (
id TEXT PRIMARY KEY,
request_type TEXT NOT NULL,
state TEXT NOT NULL DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS portal_alerts (
id TEXT PRIMARY KEY,
level TEXT NOT NULL,
state TEXT NOT NULL DEFAULT 'open',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS portal_audit_logs (
id TEXT PRIMARY KEY,
actor TEXT NOT NULL,
action TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS portal_notifications (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL,
message TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
+10 -20
View File
@@ -1,22 +1,12 @@
{
"version": "V1R1C0",
"architecture_version": "V1",
"release_version": "R1",
"change_version": "C0",
"components": [
"webops",
"owner-admin-user",
"npm",
"casdoor",
"openclaw",
"hermes",
"one-api",
"gitops-control",
"baseline-registry",
"custom-llm-registry",
"runtime-selector"
],
"entry": "https://cnnetmkt.top",
"proxy": "npm",
"runtime_sync": "openclaw"
"active_version": "V1R2C3",
"active_tag": "V1R2C3",
"previous_version": "V1R2C2",
"rollback_version": "V1R2C2",
"mode": "gitops-online",
"update_mode": "git_patch_only",
"zip_update_deprecated": true,
"chatgpt_access": true,
"codex_access": true,
"updated_at": "2026-07-08T00:00:00Z"
}
+7 -16
View File
@@ -1,6 +1,6 @@
{
"active_version": "V1R2C2",
"active_tag": "V1R2C2",
"active_version": "V1R2C3",
"active_tag": "V1R2C3",
"mode": "gitops-online",
"version_policy": "VxRxCx",
"update_mode": "git_patch_only",
@@ -28,8 +28,8 @@
"human_shortlinks_login_required": true,
"autonomous_recovery_loop": true
},
"version": "V1R2C2",
"baseline_tag": "V1R2C2-auto-recovery-baseline",
"version": "V1R2C3",
"baseline_tag": "V1R2C3",
"source": "AIOS_V1R1C0_MULTIUSER_GITOPS_CUSTOM_LLM_PROD_FULL_DEPLOY_20260706.zip",
"source_package": "AIOS_V1R1C0_MULTIUSER_GITOPS_CUSTOM_LLM_PROD_FULL_DEPLOY_20260706.zip",
"zip_update_mode": "deprecated",
@@ -47,7 +47,7 @@
"/api",
"/hook"
],
"updated_at": "2026-07-07T19:45:00Z",
"updated_at": "2026-07-08T00:00:00Z",
"auth": {
"primary_domain": "https://auth.cnnetmkt.top",
"backup_domain": "https://auth.h.imruyi.top:8443",
@@ -56,7 +56,7 @@
"casdoor_application": "admin/aios-portal",
"backup_domain_role": "standby-only"
},
"previous_version": "V1R2C1",
"previous_version": "V1R2C2",
"codex_gitops": {
"config": "config/codex/gitops-online.json",
"token_account": "codex-gitops-bot",
@@ -96,14 +96,5 @@
"owner_password_sync": "aios-gitea-owner-sync.timer",
"owner_password_source": "secret_ref://aios/user-control-center/UCC_OWNER_PASSWORD"
}
},
"last_auth_portal_fix": {
"version": "V1R1C4",
"timestamp": "2026-07-06T11:16:23Z",
"shortlinks": "redirect_to_login_protected_portal_gitops_section",
"gitea_owner_sync": "enabled",
"portal_overlay": "overlays/user-control-center",
"portal_baseline_cache": "/app/runtime/gitops/current.json",
"sync_log_secret_hygiene": "runuser_without_sudo_command_logging"
}
}
}
@@ -0,0 +1,9 @@
{
"type": "branch",
"branch": "patch/v1r3c0-user-portal-rbac-ops-20260708",
"base": "main",
"created_by": "chatgpt-gitops-bot",
"created_at": "2026-07-07T18:32:29Z",
"direct_main_push": false,
"owner_approval_required": true
}
@@ -1,9 +0,0 @@
{
"type": "branch",
"branch": "test/alias-write-verify",
"base": "main",
"created_by": "gitops-write-bot",
"created_at": "2026-07-07T14:43:14Z",
"direct_main_push": false,
"owner_approval_required": true
}
+24
View File
@@ -0,0 +1,24 @@
from active_runtime.app.portal_rbac_ops import PortalContext, PortalRBACService, PortalAuditService, SecretPolicy
def test_user_scope():
ctx = PortalContext('u1', 'g1', 'user')
assert PortalRBACService().authorize(ctx, 'self')
def test_owner_scope():
ctx = PortalContext('o1', None, 'owner')
assert PortalRBACService().authorize(ctx, 'global')
def test_navigation():
assert '/owner/system' in PortalRBACService().navigation('owner')
def test_audit_append():
event = PortalAuditService().append('login', 'u1')
assert event.action == 'login'
def test_secret_redaction():
assert SecretPolicy.redact('secret') == '***REDACTED***'
+20
View File
@@ -0,0 +1,20 @@
{
"version": "V1R2C3",
"tag": "V1R2C3",
"previous_version": "V1R2C2",
"rollback_version": "V1R2C2",
"release_reason": "GPT Actions ClientResponseError compatibility recovery",
"validated_actions": [
"getRuntimeStatus",
"getBaseline",
"listVersions",
"listPatches",
"getDiff",
"createBranch",
"createPatch",
"commitFile"
],
"secret_plaintext_written": false,
"created_at": "2026-07-08T00:00:00Z",
"author": "openclaw"
}