🔒 API Security, Multi-Tenant Isolation & Abuse Prevention

The RBOS (Raj Astrology Operating System) implements defense-in-depth security architectures to guarantee tenant isolation, prevent API key abuse, protect proprietary astrological algorithms, and ensure data integrity.


1. User Roles & Permission Matrix

RBOS enforces a strict role-based access control (RBAC) and subscription tier model:

Role / Tier Identifier Daily UI Calculations API Call Limit 20-Section Life Report Developer Tools Access
Guest / Public guest 0 (Must register) 0 (Must register) No Access Blocked
Free Registered Tier normal 5 Free Calls / Day Included with key Masked Preview (Locks sensitive chapters) Blocked (403 Forbidden)
1-Year Premium normal_yearly Unlimited Unlimited Full Unmasked Access Blocked (403 Forbidden)
Astrologer Pack astrologer_pack 1,000 Credits 1,000 Credits Full Unmasked Access Blocked (403 Forbidden)
Pay-As-You-Go single_* Per-Report Purchase Per-Report Purchase Full Access for Purchased Types Blocked (403 Forbidden)
Developer / Admin developer Unlimited Unlimited Full Unmasked Access Full Access (engine-analysis.php, knowledge_curator.php)

2. API Key Architecture & Anti-Theft Whitelisting

Team Key Provisioning

Every registered user can generate multiple API keys (e.g. for development, staging, production, or mobile applications):

Anti-Theft Domain Whitelisting

To prevent client-side API key theft from web browser applications, each API key can be restricted to specific domain origins:

When a request arrives, ApiMiddleware::validateDomain() inspects the HTTP_ORIGIN and HTTP_REFERER headers. If the origin is not whitelisted, the request is terminated with:

{
  "status": "error",
  "code": 403,
  "error": "Domain Unauthorized: Origin 'https://unauthorized-origin.com' is not in the allowed domains list for this API Key. Update allowed domains in your dashboard."
}

3. Threat Vector Analysis & Backend Defenses

                        [ Incoming Request ]
                                 │
                 ┌───────────────┴───────────────┐
                 ▼                               ▼
       [ Web UI Request ]              [ REST API Request ]
                 │                               │
        CSRF Token Validation            API Key Hash Verification
                 │                               │
        Session Authenticated?           Domain Whitelist Verification
                 │                               │
       Role / Privilege Check            Sliding Window Rate Limiter
                 │                               │
       Daily Usage / Mask Check          Tier Endpoint Permission Check
                 │                               │
                 └───────────────┬───────────────┘
                                 ▼
                     [ Core Engine Execution ]

1. Denial of Service & Rate Limiting (APCu Sliding Window)

2. Insecure Direct Object References (IDOR)

3. Cross-Site Request Forgery (CSRF)

4. Cross-Site Scripting (XSS)

5. SQL Injection (SQLi)

6. Privilege Escalation & Developer Tool Barriers

7. Proprietary Report Content Protection (Masking)

8. Immediate Revocation Enforcement

9. Client-Side Account History Isolation


4. Automated Security Test Coverage

The RBOS test architecture includes dedicated automated test suites validating security controls:

PHPUnit Security Test Suite

Path: engine/tests/Security/Santhoshr96SecurityAndAbuseTest.php

./engine/vendor/bin/phpunit engine/tests/Security/Santhoshr96SecurityAndAbuseTest.php

Playwright UI & Browser Attack Suite

Path: testing/e2e/santhoshr96_attacks.spec.js

npx playwright test testing/e2e/santhoshr96_attacks.spec.js --reporter=list

5. Security Best Practices for API Consumers

  1. Keep Secret Keys Private: Never commit raw API keys to public source code repositories or client-side bundles without domain whitelists.
  2. Restrict Allowed Domains: For browser-based applications, always configure specific origin domains in your dashboard rather than using the open wildcard (*).
  3. Use Dedicated Keys per Environment: Generate separate API keys for Development, Staging, and Production so compromised staging credentials can be revoked without disrupting production systems.
  4. Implement Client-Side Backoff: Handle HTTP 429 status codes with exponential backoff if executing burst calculations.