infrasynth-backend-kit/infrasynth/security/urls.py
jcv-dev 551b42eab5 feat: production-hardening pass across the kit
Close the gaps between the documented contract (API-STANDARD, TENANCY,
ENTITLEMENTS) and the implementation, and remove committed build artifacts.

Security:
- verify + process inbound webhooks (HMAC/handler verify, size limit,
  timestamp tolerance, idempotency via InboundEvent.external_id)
- real 2FA login flow (pre-auth challenge; tokens only after verify/recovery)
- wire HybridPermission into security/audit views; add API-key rotate and
  users/<id>/permissions|roles endpoints
- tenant-scoped throttling on by default; webhook replay protection
- verify MercadoPago webhook signatures
- login brute-force guard, configurable password policy, real ALTCHA PoW

Correctness:
- apply verified billing webhooks idempotently (subscription/entitlement/
  invoice/PaymentTransaction); scheduled payment lifecycle jobs
- capture audit update diffs automatically; add audit retention purge
- working notification retries, per-channel rate limits, log retention
- pluggable virus scanner, upload-size limit, pipeline toggle
- feature rollout %/environment targeting; settings-driven registrations
- workflow guards (instance cap, route depth, self-assignment, clone on re-entry)
- wire every previously-dead INFRASYNTH_* setting; drop truly dead ones

Delivery:
- README + CHANGELOG; CI format check + coverage gate
- keep test media out of the tree; untrack .coverage, __pycache__,
  egg-info, docs/ and invoice artifacts
2026-09-24 10:41:21 -05:00

82 lines
2.3 KiB
Python

from django.urls import include, path
from rest_framework.routers import DefaultRouter
from .views import (
ALTCHAViewSet,
APIKeyViewSet,
AuthViewSet,
GrantViewSet,
RevokeViewSet,
RoleViewSet,
TwoFactorViewSet,
UserPermissionViewSet,
)
router = DefaultRouter()
router.register(r"api-keys", APIKeyViewSet, basename="api-keys")
router.register(r"roles", RoleViewSet, basename="roles")
router.register(r"grants", GrantViewSet, basename="grants")
router.register(r"revokes", RevokeViewSet, basename="revokes")
urlpatterns = [
path("login/", AuthViewSet.as_view({"post": "login"}), name="auth-login"),
path("logout/", AuthViewSet.as_view({"post": "logout"}), name="auth-logout"),
path("refresh/", AuthViewSet.as_view({"post": "refresh"}), name="auth-refresh"),
path("check/", AuthViewSet.as_view({"get": "check"}), name="auth-check"),
path(
"select-workspace/",
AuthViewSet.as_view({"post": "select_workspace"}),
name="auth-select-workspace",
),
path(
"switch-workspace/",
AuthViewSet.as_view({"post": "switch_workspace"}),
name="auth-switch-workspace",
),
path(
"2fa/setup/",
TwoFactorViewSet.as_view({"post": "setup"}),
name="2fa-setup",
),
path(
"2fa/verify-setup/",
TwoFactorViewSet.as_view({"post": "verify_setup"}),
name="2fa-verify-setup",
),
path(
"2fa/verify/",
TwoFactorViewSet.as_view({"post": "verify"}),
name="2fa-verify",
),
path(
"2fa/disable/",
TwoFactorViewSet.as_view({"post": "disable"}),
name="2fa-disable",
),
path(
"2fa/recovery/",
TwoFactorViewSet.as_view({"post": "recovery"}),
name="2fa-recovery",
),
path(
"altcha/challenge/",
ALTCHAViewSet.as_view({"post": "challenge"}),
name="altcha-challenge",
),
path(
"altcha/verify/",
ALTCHAViewSet.as_view({"post": "verify"}),
name="altcha-verify",
),
path(
"users/<int:pk>/permissions/",
UserPermissionViewSet.as_view({"get": "permissions"}),
name="user-permissions",
),
path(
"users/<int:pk>/roles/",
UserPermissionViewSet.as_view({"get": "roles", "put": "roles"}),
name="user-roles",
),
path("", include(router.urls)),
]