anonix-gateway 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. anonix_gateway-0.1.0/.dockerignore +18 -0
  2. anonix_gateway-0.1.0/.env.example +44 -0
  3. anonix_gateway-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +19 -0
  4. anonix_gateway-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +12 -0
  5. anonix_gateway-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +9 -0
  6. anonix_gateway-0.1.0/.github/workflows/ci.yml +52 -0
  7. anonix_gateway-0.1.0/.gitignore +21 -0
  8. anonix_gateway-0.1.0/CHANGELOG.md +15 -0
  9. anonix_gateway-0.1.0/CONTRIBUTING.md +37 -0
  10. anonix_gateway-0.1.0/Caddyfile +3 -0
  11. anonix_gateway-0.1.0/Dockerfile +33 -0
  12. anonix_gateway-0.1.0/LICENSE +183 -0
  13. anonix_gateway-0.1.0/PKG-INFO +142 -0
  14. anonix_gateway-0.1.0/README.md +99 -0
  15. anonix_gateway-0.1.0/SECURITY.md +17 -0
  16. anonix_gateway-0.1.0/alembic/env.py +70 -0
  17. anonix_gateway-0.1.0/alembic/script.py.mako +25 -0
  18. anonix_gateway-0.1.0/alembic/versions/0001_initial.py +252 -0
  19. anonix_gateway-0.1.0/alembic.ini +38 -0
  20. anonix_gateway-0.1.0/console/index.html +12 -0
  21. anonix_gateway-0.1.0/console/package-lock.json +1747 -0
  22. anonix_gateway-0.1.0/console/package.json +21 -0
  23. anonix_gateway-0.1.0/console/src/App.tsx +1086 -0
  24. anonix_gateway-0.1.0/console/src/main.tsx +10 -0
  25. anonix_gateway-0.1.0/console/src/styles.css +185 -0
  26. anonix_gateway-0.1.0/console/vite.config.ts +14 -0
  27. anonix_gateway-0.1.0/demo_upstream/Dockerfile +8 -0
  28. anonix_gateway-0.1.0/demo_upstream/app.py +49 -0
  29. anonix_gateway-0.1.0/docker-compose.byod.yml +26 -0
  30. anonix_gateway-0.1.0/docker-compose.yml +88 -0
  31. anonix_gateway-0.1.0/docs/api-reference.md +77 -0
  32. anonix_gateway-0.1.0/docs/architecture.md +47 -0
  33. anonix_gateway-0.1.0/docs/authentication.md +49 -0
  34. anonix_gateway-0.1.0/docs/demo-guide.md +70 -0
  35. anonix_gateway-0.1.0/docs/deployment.md +77 -0
  36. anonix_gateway-0.1.0/pyproject.toml +98 -0
  37. anonix_gateway-0.1.0/scripts/demo_walkthrough.py +179 -0
  38. anonix_gateway-0.1.0/src/anonix_gateway/__init__.py +3 -0
  39. anonix_gateway-0.1.0/src/anonix_gateway/audit/__init__.py +1 -0
  40. anonix_gateway-0.1.0/src/anonix_gateway/audit/ledger.py +47 -0
  41. anonix_gateway-0.1.0/src/anonix_gateway/auth/__init__.py +1 -0
  42. anonix_gateway-0.1.0/src/anonix_gateway/auth/admin.py +90 -0
  43. anonix_gateway-0.1.0/src/anonix_gateway/auth/caller.py +239 -0
  44. anonix_gateway-0.1.0/src/anonix_gateway/auth/oidc.py +109 -0
  45. anonix_gateway-0.1.0/src/anonix_gateway/auth/trusted_proxy.py +69 -0
  46. anonix_gateway-0.1.0/src/anonix_gateway/cache/__init__.py +1 -0
  47. anonix_gateway-0.1.0/src/anonix_gateway/cache/rate_limit.py +77 -0
  48. anonix_gateway-0.1.0/src/anonix_gateway/cli.py +118 -0
  49. anonix_gateway-0.1.0/src/anonix_gateway/config.py +127 -0
  50. anonix_gateway-0.1.0/src/anonix_gateway/db/__init__.py +41 -0
  51. anonix_gateway-0.1.0/src/anonix_gateway/db/base.py +22 -0
  52. anonix_gateway-0.1.0/src/anonix_gateway/db/bootstrap.py +70 -0
  53. anonix_gateway-0.1.0/src/anonix_gateway/db/models.py +265 -0
  54. anonix_gateway-0.1.0/src/anonix_gateway/db/session.py +70 -0
  55. anonix_gateway-0.1.0/src/anonix_gateway/main.py +101 -0
  56. anonix_gateway-0.1.0/src/anonix_gateway/masking/__init__.py +1 -0
  57. anonix_gateway-0.1.0/src/anonix_gateway/masking/engine_cache.py +47 -0
  58. anonix_gateway-0.1.0/src/anonix_gateway/proxy/__init__.py +1 -0
  59. anonix_gateway-0.1.0/src/anonix_gateway/proxy/ssrf.py +73 -0
  60. anonix_gateway-0.1.0/src/anonix_gateway/routes/__init__.py +1 -0
  61. anonix_gateway-0.1.0/src/anonix_gateway/routes/admin.py +1179 -0
  62. anonix_gateway-0.1.0/src/anonix_gateway/routes/health.py +31 -0
  63. anonix_gateway-0.1.0/src/anonix_gateway/routes/mask.py +250 -0
  64. anonix_gateway-0.1.0/src/anonix_gateway/routes/proxy.py +316 -0
  65. anonix_gateway-0.1.0/src/anonix_gateway/routes/setup.py +131 -0
  66. anonix_gateway-0.1.0/src/anonix_gateway/security/__init__.py +24 -0
  67. anonix_gateway-0.1.0/src/anonix_gateway/security/crypto.py +64 -0
  68. anonix_gateway-0.1.0/src/anonix_gateway/security/tokens.py +44 -0
  69. anonix_gateway-0.1.0/src/anonix_gateway/static/assets/index-CvNlZY6p.css +1 -0
  70. anonix_gateway-0.1.0/src/anonix_gateway/static/assets/index-DS6Sk6zE.js +55 -0
  71. anonix_gateway-0.1.0/src/anonix_gateway/static/index.html +13 -0
  72. anonix_gateway-0.1.0/tests/conftest.py +75 -0
  73. anonix_gateway-0.1.0/tests/test_bootstrap_and_admin.py +330 -0
  74. anonix_gateway-0.1.0/tests/test_mask_and_auth.py +290 -0
  75. anonix_gateway-0.1.0/tests/test_reverse_proxy.py +204 -0
@@ -0,0 +1,18 @@
1
+ .git/
2
+ .venv/
3
+ venv/
4
+ __pycache__/
5
+ *.py[cod]
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ data/
10
+ *.db
11
+ *.sqlite
12
+ *.sqlite3
13
+ .env
14
+ console/node_modules/
15
+ console/dist/
16
+ src/anonix_gateway/static/
17
+ dist/
18
+ build/
@@ -0,0 +1,44 @@
1
+ # Anonix Gateway Configuration Template
2
+ # Copy to .env for local or Docker Compose deployments.
3
+
4
+ # Environment: "development" (single-node convenience) or "production" (strict fail-closed startup)
5
+ ANONIX_ENV=development
6
+
7
+ # Server bind address and port
8
+ ANONIX_HOST=0.0.0.0
9
+ ANONIX_PORT=8000
10
+ ANONIX_LOG_LEVEL=INFO
11
+
12
+ # Tenancy mode: "single_org" (default) or "multi_tenant"
13
+ ANONIX_TENANCY_MODE=single_org
14
+
15
+ # Database URL (leave blank for automatic local SQLite: sqlite+aiosqlite:///./data/anonix.db)
16
+ # For bundled Docker Postgres: postgresql+asyncpg://anonix:anonix@postgres:5432/anonix
17
+ # For BYOD Enterprise Postgres: postgresql+asyncpg://user:password@db.company.internal:5432/anonix
18
+ # ANONIX_DATABASE_URL=
19
+
20
+ # Redis URL (optional; leave blank for built-in in-memory rate limiting & JWKS cache)
21
+ # ANONIX_REDIS_URL=redis://redis:6379/0
22
+
23
+ # Cryptographic secrets (generate with: anonix-gateway keygen)
24
+ # Required in ANONIX_ENV=production. In development, auto-generated & persisted in ANONIX_DATA_DIR.
25
+ # ANONIX_MASTER_KEY=
26
+ # ANONIX_ADMIN_JWT_SECRET=
27
+
28
+ # Local data directory for SQLite and auto-generated development secrets
29
+ ANONIX_DATA_DIR=./data
30
+
31
+ # Optional headless first-run bootstrap (leave blank to use Web /setup or `anonix-gateway init`)
32
+ # ANONIX_BOOTSTRAP_ADMIN_EMAIL=
33
+ # ANONIX_BOOTSTRAP_ADMIN_PASSWORD=
34
+ # ANONIX_BOOTSTRAP_ORG_NAME=Default Organization
35
+
36
+ # Optional CORS origins (comma-separated) for standalone frontend dev
37
+ # ANONIX_CORS_ORIGINS=http://localhost:5173
38
+
39
+ # Optional native HTTPS/TLS (provide both to serve HTTPS directly without an external proxy)
40
+ # ANONIX_SSL_CERTFILE=/certs/fullchain.pem
41
+ # ANONIX_SSL_KEYFILE=/certs/privkey.pem
42
+
43
+ # Optional domain for automatic Let's Encrypt HTTPS with `docker compose --profile tls up -d`
44
+ # ANONIX_DOMAIN=mask.example.com
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Report a bug or unexpected behavior in Anonix Gateway
4
+ title: "[Bug]: "
5
+ labels: bug
6
+ ---
7
+
8
+ ## Description
9
+ A clear description of what happened.
10
+
11
+ ## Steps to Reproduce
12
+ 1. Deployment mode (Docker Compose / BYOD Postgres / Single-node CLI):
13
+ 2. Steps or request made:
14
+ 3. Expected vs. actual behavior:
15
+
16
+ ## Environment
17
+ - `anonix-gateway` version:
18
+ - Python / Docker version:
19
+ - Database backend (PostgreSQL / SQLite):
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Suggest an improvement or new capability for Anonix Gateway
4
+ title: "[Feature]: "
5
+ labels: enhancement
6
+ ---
7
+
8
+ ## Problem Statement
9
+ What use case or enterprise requirement does this address?
10
+
11
+ ## Proposed Solution
12
+ Describe the expected behavior or configuration option.
@@ -0,0 +1,9 @@
1
+ ## Summary
2
+ Briefly describe the change and why it is needed.
3
+
4
+ ## Checklist
5
+ - [ ] `ruff check src tests` passes with zero errors
6
+ - [ ] `mypy src` passes under `--strict`
7
+ - [ ] `pytest -v` passes with tests covering new/changed behavior
8
+ - [ ] If UI files changed: `cd console && npm run build` succeeds
9
+ - [ ] Documentation updated where applicable
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ jobs:
10
+ backend:
11
+ name: Backend Lint, Typecheck & Tests
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.11"
19
+ cache: "pip"
20
+
21
+ - name: Install dependencies
22
+ run: pip install -e ".[dev]"
23
+
24
+ - name: Ruff lint
25
+ run: ruff check src tests
26
+
27
+ - name: Mypy strict typecheck
28
+ run: mypy src
29
+
30
+ - name: Pytest suite
31
+ run: pytest -v
32
+
33
+ console:
34
+ name: Admin Console Build
35
+ runs-on: ubuntu-latest
36
+ defaults:
37
+ run:
38
+ working-directory: console
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+
42
+ - uses: actions/setup-node@v4
43
+ with:
44
+ node-version: "20"
45
+ cache: "npm"
46
+ cache-dependency-path: console/package-lock.json
47
+
48
+ - name: Install dependencies
49
+ run: npm ci
50
+
51
+ - name: Build production bundle
52
+ run: npm run build
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ .venv/
5
+ venv/
6
+ dist/
7
+ build/
8
+ *.egg-info/
9
+ .pytest_cache/
10
+ .mypy_cache/
11
+ .ruff_cache/
12
+ .coverage
13
+ htmlcov/
14
+ .env
15
+ *.db
16
+ *.sqlite
17
+ *.sqlite3
18
+ data/
19
+ console/node_modules/
20
+ console/dist/
21
+ src/anonix_gateway/static/
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to **Anonix Gateway** are documented in this file.
4
+
5
+ ## [0.1.0] - 2026-11-25
6
+
7
+ ### Added
8
+ - Self-hosted FastAPI gateway powered by `anonix>=0.1.0,<0.2.0` (`JSON`, `XML`, `YAML`, `CSV`).
9
+ - Reverse-proxy masking (`/proxy/{prefix}/*`) with longest-prefix routing, method/subpath restrictions, SSRF guard, and encrypted outbound upstream credentials.
10
+ - Direct on-the-fly masking endpoint (`POST /v1/mask`).
11
+ - Multi-mode inbound authentication: OIDC/JWT (JWKS + configurable claims), scoped API Keys, and Trusted-Proxy headers (CIDR allowlist + encrypted shared secret).
12
+ - Policy-required `GroupMapping` resolution (`external_group -> policy_id + optional policy_role`) with priority tie-breaking and cross-policy blocking.
13
+ - Control-plane RBAC (`platform_admin`, `policy_author`, `auditor`), full CRUD, policy versioning/rollback, and zero-PII `AuditEvent` ledger.
14
+ - Bundled React 18 + Vite Admin Console with first-run `/setup` wizard and Live Policy Playground.
15
+ - Deployment support for Docker Compose (Postgres + Redis), Enterprise BYOD Postgres (`docker-compose.byod.yml`), and single-node CLI (`anonix-gateway init` / `serve`).
@@ -0,0 +1,37 @@
1
+ # Contributing to Anonix Gateway
2
+
3
+ Thank you for contributing to **Anonix Gateway**!
4
+
5
+ ## Development Setup
6
+
7
+ ### Backend
8
+ ```bash
9
+ python -m venv .venv
10
+ # Linux/macOS:
11
+ source .venv/bin/activate
12
+ # Windows PowerShell:
13
+ .\.venv\Scripts\Activate.ps1
14
+
15
+ pip install -e ".[dev]"
16
+ ```
17
+
18
+ ### Admin Console
19
+ ```bash
20
+ cd console
21
+ npm install
22
+ npm run build
23
+ ```
24
+
25
+ ## Quality Checks
26
+ Before opening a pull request, run all checks:
27
+
28
+ ```bash
29
+ ruff check src tests
30
+ mypy src
31
+ pytest -v
32
+ ```
33
+
34
+ ## Design Principles
35
+ - **Fail closed:** Missing or invalid authentication (`401`), unauthorized groups/policies (`403`), and masking/format errors (`502` on proxy) must never leak raw payloads.
36
+ - **Zero-PII persistence:** Never log or store raw or masked payload field values in databases or audit tables.
37
+ - **No hardcoded policies or credentials:** Every masking rule comes from explicit `MaskingPolicy` definitions; every secret is generated or injected per deployment.
@@ -0,0 +1,3 @@
1
+ {$ANONIX_DOMAIN:localhost} {
2
+ reverse_proxy gateway:8000
3
+ }
@@ -0,0 +1,33 @@
1
+ # Stage 1: Build the React Admin Console
2
+ FROM node:20-alpine AS console-builder
3
+ WORKDIR /console
4
+ COPY console/package*.json ./
5
+ RUN npm ci --no-audit --no-fund
6
+ COPY console/ ./
7
+ RUN npm run build
8
+
9
+ # Stage 2: Build the Python Gateway image with bundled Admin Console static UI
10
+ FROM python:3.11-slim AS runtime
11
+ WORKDIR /app
12
+
13
+ ENV PYTHONDONTWRITEBYTECODE=1 \
14
+ PYTHONUNBUFFERED=1 \
15
+ ANONIX_HOST=0.0.0.0 \
16
+ ANONIX_PORT=8000 \
17
+ ANONIX_DATA_DIR=/data
18
+
19
+ RUN useradd --create-home --uid 10001 anonix && mkdir -p /data && chown -R anonix:anonix /data /app
20
+
21
+ COPY pyproject.toml README.md LICENSE ./
22
+ COPY alembic.ini ./
23
+ COPY alembic ./alembic
24
+ COPY src ./src
25
+ COPY --from=console-builder /console/dist ./src/anonix_gateway/static
26
+
27
+ RUN pip install --no-cache-dir .
28
+
29
+ USER anonix
30
+ VOLUME ["/data"]
31
+ EXPOSE 8000
32
+
33
+ CMD ["anonix-gateway", "serve"]
@@ -0,0 +1,183 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the Licensor as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated into the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the NOTICE file contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE file, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+ Notwithstanding the above, nothing herein shall supersede or modify
128
+ the terms of any separate license agreement you may have executed
129
+ with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor,
133
+ except as required for reasonable and customary use in describing the
134
+ origin of the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
140
+ implied, including, either express or implied, including, without limitation, any warranties or conditions
141
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
142
+ PARTICULAR PURPOSE. You are solely responsible for determining the
143
+ appropriateness of using or redistributing the Work and assume any
144
+ risks associated with Your exercise of permissions under this License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort (including negligence), contract, or otherwise,
148
+ unless required by applicable law (such as deliberate artificial
149
+ intelligence) or agreed to in writing, shall any Contributor be
150
+ liable to You for damages, including any direct, indirect, special,
151
+ incidental, or consequential damages of any character arising as a
152
+ result of this License or out of the use or inability to use the
153
+ Work (including but not limited to damages for loss of goodwill,
154
+ work stoppage, computer failure or malfunction, or any and all
155
+ other commercial damages or losses), even if such Contributor
156
+ has been advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Additional Liability. While redistributing
159
+ the Work or Derivative Works thereof, You may choose to offer,
160
+ and charge a fee for, acceptance of support, warranty, indemnity,
161
+ or other liability obligations and/or rights consistent with this
162
+ License. However, in accepting such obligations, You may act only
163
+ on Your own behalf and on Your sole responsibility, not on behalf
164
+ of any other Contributor, and only if You agree to indemnify,
165
+ defend, and hold each Contributor harmless for any liability
166
+ incurred by, or claims asserted against, such Contributor by reason
167
+ of your accepting any such warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ Copyright 2026 Adithya Nangarath and Nikhilesh Kalahasti
172
+
173
+ Licensed under the Apache License, Version 2.0 (the "License");
174
+ you may not use this file except in compliance with the License.
175
+ You may obtain a copy of the License at
176
+
177
+ http://www.apache.org/licenses/LICENSE-2.0
178
+
179
+ Unless required by applicable law or agreed to in writing, software
180
+ distributed under the License is distributed on an "AS IS" BASIS,
181
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
+ See the License for the specific language governing permissions and
183
+ limitations under the License.
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.5
2
+ Name: anonix-gateway
3
+ Version: 0.1.0
4
+ Summary: Self-hosted on-the-fly data masking reverse proxy, API gateway, and admin control plane powered by anonix.
5
+ Author: Adithya Nangarath, Nikhilesh Kalahasti
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: anonix,api-gateway,data-masking,pii,privacy,reverse-proxy,self-hosted
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Information Technology
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Security
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: aiosqlite<1.0.0,>=0.20.0
19
+ Requires-Dist: alembic<2.0.0,>=1.13.0
20
+ Requires-Dist: anonix<0.2.0,>=0.1.0
21
+ Requires-Dist: argon2-cffi<25.0.0,>=23.1.0
22
+ Requires-Dist: asyncpg<1.0.0,>=0.29.0
23
+ Requires-Dist: cryptography<45.0.0,>=42.0.0
24
+ Requires-Dist: fastapi<1.0.0,>=0.115.0
25
+ Requires-Dist: httpx<1.0.0,>=0.27.0
26
+ Requires-Dist: pydantic-settings<3.0.0,>=2.3.0
27
+ Requires-Dist: pydantic<3.0.0,>=2.7.0
28
+ Requires-Dist: pyjwt[crypto]<3.0.0,>=2.8.0
29
+ Requires-Dist: python-multipart<1.0.0,>=0.0.9
30
+ Requires-Dist: pyyaml<7.0,>=6.0
31
+ Requires-Dist: redis<6.0.0,>=5.0.0
32
+ Requires-Dist: sqlalchemy[asyncio]<3.0.0,>=2.0.30
33
+ Requires-Dist: typer<1.0.0,>=0.12.0
34
+ Requires-Dist: uvicorn[standard]<1.0.0,>=0.30.0
35
+ Provides-Extra: dev
36
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
37
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
38
+ Requires-Dist: pytest>=8.2.0; extra == 'dev'
39
+ Requires-Dist: respx>=0.21.0; extra == 'dev'
40
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
41
+ Requires-Dist: types-pyyaml>=6.0.12; extra == 'dev'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # Anonix Gateway
45
+
46
+ Self-hosted, fail-closed, on-the-fly data masking reverse proxy, API gateway, and web control plane powered by [`anonix`](https://pypi.org/project/anonix/).
47
+
48
+ Anonix Gateway lets any organization—universities, hospitals, SaaS platforms, or enterprises—deploy their own centralized data-masking layer in minutes. It protects **non-relational data** (`JSON`, `XML`, `YAML`, `CSV`) **in memory on the fly** without modifying existing backend databases or application code.
49
+
50
+ ---
51
+
52
+ ## Why Anonix Gateway?
53
+
54
+ While [`anonix`](https://github.com/lovepop1/Datamasking-Core) provides the pure Python in-memory masking library and CLI, enterprises need a complete self-hosted platform:
55
+
56
+ 1. **Zero-Code API Protection (`/proxy/{prefix}/*`):** Sit Anonix in front of existing internal REST APIs. External consumers call Anonix; Anonix fetches raw responses from the internal upstream, masks them in RAM for the caller's role, and returns only safe data.
57
+ 2. **Language-Agnostic Masking Service (`POST /v1/mask`):** Java, Node.js, Go, PHP, ETL, and AI/LLM pipelines send raw payloads and receive masked output on the fly.
58
+ 3. **Self-Hosted Web Admin Console:** First-run `/setup` wizard (zero hardcoded default passwords), versioned policy editor, Live Policy Playground, Auth Providers, Group Mappings, API Keys, Upstreams, Proxy Routes, and a Zero-PII Audit Log.
59
+ 4. **Full Infrastructure & Auth Autonomy:** Run with bundled Docker PostgreSQL + Redis, **BYOD PostgreSQL** (`ANONIX_DATABASE_URL`), or zero-setup local SQLite; authenticate callers via **OIDC/JWT**, **API Keys**, and/or **Trusted-Proxy Headers**.
60
+
61
+ ---
62
+
63
+ ## Architecture Overview
64
+
65
+ ```text
66
+ Consumer Apps / Partner Services / ETL
67
+ │
68
+ │ Bearer OIDC JWT │ X-API-Key │ Trusted-Proxy Headers
69
+ ▼
70
+ ┌──────────────────────────────────────────────────────────────────────┐
71
+ │ ANONIX GATEWAY │
72
+ │ │
73
+ │ 1. Inbound Auth Chain (Fail-closed 401) │
74
+ │ 2. GroupMapping -> (Policy + Optional Role) (Fail-closed 403) │
75
+ │ 3. /proxy/* (httpx + SSRF Guard) OR POST /v1/mask │
76
+ │ 4. anonix MaskingEngine in RAM (Fail-closed 502 on error) │
77
+ │ 5. Zero-PII Audit Logger + Web Admin Console │
78
+ └───────────────┬──────────────────────────────────┬───────────────────┘
79
+ │ Outbound Service Creds │ Metadata & Policies
80
+ ▼ ▼
81
+ Enterprise Internal APIs Gateway DB (Zero PII)
82
+ (Private VPC / Firewall) Postgres (Bundled/BYOD) or SQLite
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Quick Start
88
+
89
+ ### Option 1: Docker Compose (Recommended)
90
+ ```bash
91
+ cp .env.example .env
92
+ docker compose up -d
93
+ ```
94
+ Open **`http://localhost:8000`** to complete the first-run administrator setup.
95
+
96
+ To include the optional mock Student/Hospital upstream API for an instant live demo:
97
+ ```bash
98
+ docker compose --profile demo up -d
99
+ ```
100
+
101
+ ### Option 2: Enterprise BYOD (Bring Your Own PostgreSQL / Redis)
102
+ ```bash
103
+ anonix-gateway keygen >> .env
104
+ # Edit .env and set ANONIX_DATABASE_URL (and optionally ANONIX_REDIS_URL)
105
+ docker compose -f docker-compose.byod.yml up -d
106
+ ```
107
+
108
+ ### Option 3: Single-Node CLI (No Docker)
109
+ ```bash
110
+ pip install anonix-gateway
111
+ anonix-gateway init
112
+ anonix-gateway serve
113
+ ```
114
+ *(If `ANONIX_DATABASE_URL` is omitted, a local SQLite database is created automatically in `./data/anonix.db`.)*
115
+
116
+ ---
117
+
118
+ ## Documentation
119
+
120
+ * [**Architecture & Security Model**](docs/architecture.md) — Control Plane vs. Data Plane, `GroupMapping` resolution, fail-closed guarantees, and zero-PII audit design.
121
+ * [**Deployment & BYOD Guide**](docs/deployment.md) — Docker Compose, Enterprise BYOD PostgreSQL/Redis, single-node CLI, secrets management, and TLS setup.
122
+ * [**Authentication & Authorization Guide**](docs/authentication.md) — OIDC/JWT (Google, Okta, Entra ID, Keycloak), API Keys, Trusted-Proxy headers (with NGINX example), and Admin RBAC.
123
+ * [**API Reference**](docs/api-reference.md) — Complete endpoint reference with `curl` and PowerShell examples.
124
+ * [**5-Minute Live Demo Guide**](docs/demo-guide.md) — Step-by-step walkthrough for evaluating or presenting Anonix Gateway end-to-end.
125
+
126
+ ---
127
+
128
+ ## Development & Verification
129
+
130
+ ```bash
131
+ python -m venv .venv
132
+ source .venv/bin/activate # Windows: .\.venv\Scripts\Activate.ps1
133
+ pip install -e ".[dev]"
134
+
135
+ ruff check src tests
136
+ mypy src
137
+ pytest -v
138
+ ```
139
+
140
+ ## License
141
+
142
+ Apache License 2.0 — Copyright 2026 Adithya Nangarath and Nikhilesh Kalahasti. See [LICENSE](LICENSE).