identity-plan-kit 1.0.3__tar.gz → 1.3.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 (258) hide show
  1. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/PKG-INFO +8 -9
  2. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/README.md +1 -1
  3. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/pyproject.toml +11 -8
  4. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/admin/auth.py +1 -1
  5. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/admin/views.py +19 -27
  6. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/models/user.py +1 -1
  7. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/services/oauth_service.py +15 -15
  8. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/config.py +5 -3
  9. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/constants.py +1 -1
  10. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/security.py +11 -5
  11. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_oauth_service_resilience.py +6 -6
  12. identity_plan_kit-1.3.0/tests/integration/test_admin_permissions.py +126 -0
  13. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_e2e_endpoints.py +1 -1
  14. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_redis_stale_write_prevention.py +6 -3
  15. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_config_validation.py +14 -3
  16. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/uv.lock +1544 -1496
  17. identity_plan_kit-1.0.3/.claude/CLAUDE.MD +0 -63
  18. identity_plan_kit-1.0.3/.claude/agents/Architect.md +0 -44
  19. identity_plan_kit-1.0.3/.claude/agents/Reviewer.md +0 -40
  20. identity_plan_kit-1.0.3/.claude/rules/cache-standards.md +0 -38
  21. identity_plan_kit-1.0.3/.claude/rules/crud-operations.md +0 -52
  22. identity_plan_kit-1.0.3/.claude/rules/database-patterns.md +0 -46
  23. identity_plan_kit-1.0.3/.claude/rules/error-handling.md +0 -43
  24. identity_plan_kit-1.0.3/.claude/rules/feature-structure.md +0 -70
  25. identity_plan_kit-1.0.3/.claude/rules/layer-standards.md +0 -75
  26. identity_plan_kit-1.0.3/.claude/rules/no-speculative-changes.md +0 -45
  27. identity_plan_kit-1.0.3/.claude/rules/serena-tool-selection.md +0 -53
  28. identity_plan_kit-1.0.3/.claude/settings.local.json +0 -88
  29. identity_plan_kit-1.0.3/.claude/skills/architect-review/SKILL.MD +0 -57
  30. identity_plan_kit-1.0.3/.claude/skills/code-review/SKILL.MD +0 -76
  31. identity_plan_kit-1.0.3/.claude/skills/pattern-review/SKILL.MD +0 -73
  32. identity_plan_kit-1.0.3/.claude/skills/production-readiness-review/SKILL.MD +0 -76
  33. identity_plan_kit-1.0.3/.claude/skills/real-optimization-test/SKILL.md +0 -222
  34. identity_plan_kit-1.0.3/.claude/skills/security-review/SKILL.MD +0 -78
  35. identity_plan_kit-1.0.3/.claude/skills/system-design/SKILL.MD +0 -88
  36. identity_plan_kit-1.0.3/.claude/skills/task-creator/SKILL.MD +0 -78
  37. identity_plan_kit-1.0.3/.claude/skills/testing-review/SKILL.md +0 -268
  38. identity_plan_kit-1.0.3/.mcp.json +0 -19
  39. identity_plan_kit-1.0.3/.serena/.gitignore +0 -2
  40. identity_plan_kit-1.0.3/.serena/cache/python/document_symbols.pkl +0 -0
  41. identity_plan_kit-1.0.3/.serena/cache/python/raw_document_symbols.pkl +0 -0
  42. identity_plan_kit-1.0.3/.serena/memories/memory_maintenance.md +0 -33
  43. identity_plan_kit-1.0.3/.serena/project.local.yml +0 -5
  44. identity_plan_kit-1.0.3/.serena/project.yml +0 -133
  45. identity_plan_kit-1.0.3/AUDIT_REPORT.md +0 -284
  46. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/.gitignore +0 -0
  47. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/Makefile +0 -0
  48. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/env.py +0 -0
  49. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/script.py.mako +0 -0
  50. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20250124_000000_initial_schema.py +0 -0
  51. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20250127_000000_add_password_hash.py +0 -0
  52. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20250130_000000_add_display_name_picture.py +0 -0
  53. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20250214_000000_add_user_metadata.py +0 -0
  54. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20260506_000000_add_plan_timestamps.py +0 -0
  55. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20260515_000000_add_auth_timestamps.py +0 -0
  56. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic/versions/20260610_000000_add_rbac_timestamps.py +0 -0
  57. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/alembic.ini +0 -0
  58. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/extending_models.py +0 -0
  59. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/integration/__init__.py +0 -0
  60. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/integration/fastapi_integration.py +0 -0
  61. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/integration/sample_alembic_env.py +0 -0
  62. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/integration/webhook_integration.py +0 -0
  63. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/playing/admin_usage.py +0 -0
  64. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/playing/basic_usage.py +0 -0
  65. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/playing/custom_error_formats.py +0 -0
  66. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/playing/user_metadata.py +0 -0
  67. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/prod/.env.production.example +0 -0
  68. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/prod/Dockerfile +0 -0
  69. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/prod/docker-compose.yml +0 -0
  70. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/prod/nginx.conf +0 -0
  71. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/prod/production_setup.py +0 -0
  72. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/examples/prod/prometheus.yml +0 -0
  73. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/README.md +0 -0
  74. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/__init__.py +0 -0
  75. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/config.py +0 -0
  76. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/locustfile.py +0 -0
  77. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/test_auth.py +0 -0
  78. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/test_database_stress.py +0 -0
  79. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/test_mixed_scenarios.py +0 -0
  80. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/test_plans_quota.py +0 -0
  81. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/test_quota_direct.py +0 -0
  82. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/test_rbac_cache.py +0 -0
  83. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/loadtests/utils.py +0 -0
  84. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/pyrightconfig.json +0 -0
  85. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/__init__.py +0 -0
  86. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/admin/__init__.py +0 -0
  87. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/__init__.py +0 -0
  88. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/cache/__init__.py +0 -0
  89. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/cache/auth_cache.py +0 -0
  90. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/dependencies.py +0 -0
  91. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/domain/__init__.py +0 -0
  92. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/domain/entities.py +0 -0
  93. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/domain/exceptions.py +0 -0
  94. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/dto/__init__.py +0 -0
  95. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/dto/requests.py +0 -0
  96. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/dto/responses.py +0 -0
  97. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/handlers/__init__.py +0 -0
  98. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/handlers/oauth_routes.py +0 -0
  99. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/models/__init__.py +0 -0
  100. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/models/refresh_token.py +0 -0
  101. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/models/user_provider.py +0 -0
  102. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/repositories/__init__.py +0 -0
  103. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/repositories/token_repo.py +0 -0
  104. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/repositories/user_repo.py +0 -0
  105. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/services/__init__.py +0 -0
  106. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/services/auth_service.py +0 -0
  107. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/auth/uow.py +0 -0
  108. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/cli.py +0 -0
  109. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/exception_handlers.py +0 -0
  110. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/kit.py +0 -0
  111. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/migrations.py +0 -0
  112. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/__init__.py +0 -0
  113. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/cache/__init__.py +0 -0
  114. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/cache/exceptions.py +0 -0
  115. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/cache/plan_cache.py +0 -0
  116. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/cache/serializers.py +0 -0
  117. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/cache/user_plan_cache.py +0 -0
  118. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/dependencies.py +0 -0
  119. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/domain/__init__.py +0 -0
  120. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/domain/entities.py +0 -0
  121. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/domain/exceptions.py +0 -0
  122. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/dto/__init__.py +0 -0
  123. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/dto/responses.py +0 -0
  124. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/dto/usage.py +0 -0
  125. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/handlers/__init__.py +0 -0
  126. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/handlers/plan_routes.py +0 -0
  127. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/__init__.py +0 -0
  128. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/feature.py +0 -0
  129. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/feature_usage.py +0 -0
  130. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/plan.py +0 -0
  131. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/plan_limit.py +0 -0
  132. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/plan_permission.py +0 -0
  133. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/models/user_plan.py +0 -0
  134. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/repositories/__init__.py +0 -0
  135. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/repositories/plan_repo.py +0 -0
  136. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/repositories/usage_repo.py +0 -0
  137. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/services/__init__.py +0 -0
  138. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/services/plan_service.py +0 -0
  139. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/plans/uow.py +0 -0
  140. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/py.typed +0 -0
  141. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/__init__.py +0 -0
  142. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/cache/__init__.py +0 -0
  143. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/cache/permission_cache.py +0 -0
  144. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/dependencies.py +0 -0
  145. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/domain/__init__.py +0 -0
  146. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/domain/entities.py +0 -0
  147. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/domain/exceptions.py +0 -0
  148. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/models/__init__.py +0 -0
  149. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/models/permission.py +0 -0
  150. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/models/role.py +0 -0
  151. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/models/role_permission.py +0 -0
  152. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/repositories/__init__.py +0 -0
  153. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/repositories/rbac_repo.py +0 -0
  154. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/services/__init__.py +0 -0
  155. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/services/rbac_service.py +0 -0
  156. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/rbac/uow.py +0 -0
  157. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/registry.py +0 -0
  158. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/README.md +0 -0
  159. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/__init__.py +0 -0
  160. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/audit.py +0 -0
  161. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/circuit_breaker.py +0 -0
  162. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/cleanup_scheduler.py +0 -0
  163. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/database.py +0 -0
  164. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/error_formatter.py +0 -0
  165. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/exception_handlers.py +0 -0
  166. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/exceptions.py +0 -0
  167. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/graceful_shutdown.py +0 -0
  168. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/health.py +0 -0
  169. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/http_utils.py +0 -0
  170. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/lockout.py +0 -0
  171. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/logging.py +0 -0
  172. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/metrics.py +0 -0
  173. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/models.py +0 -0
  174. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/protocols.py +0 -0
  175. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/rate_limiter.py +0 -0
  176. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/registry.py +0 -0
  177. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/repository.py +0 -0
  178. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/request_id.py +0 -0
  179. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/schemas.py +0 -0
  180. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/state_store.py +0 -0
  181. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/uow.py +0 -0
  182. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/src/identity_plan_kit/shared/uuid7.py +0 -0
  183. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/test_app.py +0 -0
  184. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/__init__.py +0 -0
  185. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/admin/__init__.py +0 -0
  186. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/__init__.py +0 -0
  187. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_audit_regressions_2026_06.py +0 -0
  188. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_auth_cache.py +0 -0
  189. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_auth_cache_concurrent.py +0 -0
  190. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_auth_service.py +0 -0
  191. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_circuit_breaker.py +0 -0
  192. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_csrf_state.py +0 -0
  193. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_dependencies.py +0 -0
  194. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_domain_entities.py +0 -0
  195. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_http_utils.py +0 -0
  196. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_lockout.py +0 -0
  197. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_lockout_concurrent.py +0 -0
  198. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_oauth_semaphore_timeout.py +0 -0
  199. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_redis_auth_cache_lua.py +0 -0
  200. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_review_regressions_2026_05.py +0 -0
  201. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_security_comprehensive.py +0 -0
  202. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/auth/test_token_security.py +0 -0
  203. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/conftest.py +0 -0
  204. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/extension/__init__.py +0 -0
  205. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/extension/conftest.py +0 -0
  206. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/extension/test_model_extension.py +0 -0
  207. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/__init__.py +0 -0
  208. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/conftest.py +0 -0
  209. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_concurrent_limit_merge.py +0 -0
  210. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_concurrent_plan_operations.py +0 -0
  211. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_concurrent_service_races.py +0 -0
  212. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_concurrent_token_operations.py +0 -0
  213. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_concurrent_user_creation.py +0 -0
  214. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_concurrent_user_deactivation.py +0 -0
  215. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_limit_boundaries.py +0 -0
  216. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_plan_cache_race.py +0 -0
  217. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_quota_concurrency.py +0 -0
  218. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_token_cleanup.py +0 -0
  219. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_token_repository.py +0 -0
  220. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_usage_periods.py +0 -0
  221. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/integration/test_user_repository.py +0 -0
  222. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/__init__.py +0 -0
  223. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_circuit_breaker_behavior.py +0 -0
  224. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_dependencies.py +0 -0
  225. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_domain_entities.py +0 -0
  226. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_period_edge_cases.py +0 -0
  227. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_plan_cache_bounded_invalidation.py +0 -0
  228. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_plan_cache_concurrent.py +0 -0
  229. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_plan_cache_interleave.py +0 -0
  230. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_plan_service.py +0 -0
  231. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_plan_service_cache_ordering.py +0 -0
  232. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_plan_service_stampede.py +0 -0
  233. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_quota_idempotency_concurrent.py +0 -0
  234. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_redis_plan_cache_set_all.py +0 -0
  235. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_review_regression_2026_05.py +0 -0
  236. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_review_regression_2026_05_06.py +0 -0
  237. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/plans/test_user_plan_cache_concurrent.py +0 -0
  238. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/__init__.py +0 -0
  239. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_permission_cache.py +0 -0
  240. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_permission_cache_concurrent.py +0 -0
  241. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_rbac_cache_stampede.py +0 -0
  242. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_rbac_service.py +0 -0
  243. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_rbac_service_stampede_real.py +0 -0
  244. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_review_2026_05_06_regressions.py +0 -0
  245. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/rbac/test_review_regressions.py +0 -0
  246. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_audit_pii_masking.py +0 -0
  247. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_circuit_breaker_concurrent.py +0 -0
  248. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_cleanup_scheduler_concurrent.py +0 -0
  249. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_constants.py +0 -0
  250. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_exception_handlers.py +0 -0
  251. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_http_utils_security.py +0 -0
  252. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_rate_limiter.py +0 -0
  253. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_rate_limiter_concurrent.py +0 -0
  254. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_review_regressions.py +0 -0
  255. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_state_store_concurrent.py +0 -0
  256. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_state_store_resilience.py +0 -0
  257. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/shared/test_uow.py +0 -0
  258. {identity_plan_kit-1.0.3 → identity_plan_kit-1.3.0}/tests/test_kit_wiring.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: identity-plan-kit
3
- Version: 1.0.3
3
+ Version: 1.3.0
4
4
  Summary: Modern FastAPI library for authentication, RBAC, subscription plans, and usage tracking
5
5
  Author-email: harut <harut.avetisyan2002@gmail.com>
6
6
  License: MIT
@@ -19,13 +19,12 @@ Classifier: Typing :: Typed
19
19
  Requires-Python: >=3.11
20
20
  Requires-Dist: alembic>=1.14.0
21
21
  Requires-Dist: asyncpg>=0.30.0
22
- Requires-Dist: authlib>=1.4.0
23
- Requires-Dist: bcrypt<5.0.0,>=4.0.0
22
+ Requires-Dist: authlib>=1.9.10
23
+ Requires-Dist: bcrypt>=5.0.0
24
24
  Requires-Dist: fastapi>=0.115.0
25
- Requires-Dist: httpx>=0.28.0
25
+ Requires-Dist: httpx2>=2.16.2
26
26
  Requires-Dist: itsdangerous>=2.2.0
27
27
  Requires-Dist: orjson>=3.10.0
28
- Requires-Dist: passlib[bcrypt]>=1.7.4
29
28
  Requires-Dist: psycopg2-binary<3.0,>=2.9
30
29
  Requires-Dist: pydantic-settings>=2.0.0
31
30
  Requires-Dist: pydantic[email]>=2.0.0
@@ -38,12 +37,12 @@ Requires-Dist: tenacity>=9.0.0
38
37
  Requires-Dist: typer>=0.12.0
39
38
  Requires-Dist: uuid-utils>=0.10.0
40
39
  Provides-Extra: admin
41
- Requires-Dist: sqladmin>=0.20.0; extra == 'admin'
40
+ Requires-Dist: sqladmin>=0.32.0; extra == 'admin'
42
41
  Provides-Extra: cli
43
42
  Requires-Dist: python-dotenv>=1.0.0; extra == 'cli'
44
43
  Provides-Extra: dev
45
44
  Requires-Dist: bump-my-version>=0.26.0; extra == 'dev'
46
- Requires-Dist: httpx>=0.28.0; extra == 'dev'
45
+ Requires-Dist: httpx2>=2.16.2; extra == 'dev'
47
46
  Requires-Dist: pre-commit>=4.0.0; extra == 'dev'
48
47
  Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
49
48
  Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
@@ -624,7 +623,7 @@ All configuration is via environment variables or `IdentityPlanKitConfig`:
624
623
  | `IPK_ENABLE_AUTO_CLEANUP` | Auto cleanup expired tokens | `true` |
625
624
  | `IPK_CLEANUP_INTERVAL_HOURS` | Cleanup interval in hours | `6.0` |
626
625
  | `IPK_DATABASE_STATEMENT_TIMEOUT_MS` | PostgreSQL statement timeout | `30000` |
627
- | `IPK_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS` | Token refresh idempotency window | `30` |
626
+ | `IPK_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS` | Token refresh idempotency / reuse-detection grace window (5-600) | `300` |
628
627
  | `IPK_QUOTA_IDEMPOTENCY_TTL_SECONDS` | Quota consumption idempotency window | `60` |
629
628
  | `IPK_REQUIRE_REDIS` | Fail if Redis unavailable | Auto (true in prod) |
630
629
 
@@ -560,7 +560,7 @@ All configuration is via environment variables or `IdentityPlanKitConfig`:
560
560
  | `IPK_ENABLE_AUTO_CLEANUP` | Auto cleanup expired tokens | `true` |
561
561
  | `IPK_CLEANUP_INTERVAL_HOURS` | Cleanup interval in hours | `6.0` |
562
562
  | `IPK_DATABASE_STATEMENT_TIMEOUT_MS` | PostgreSQL statement timeout | `30000` |
563
- | `IPK_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS` | Token refresh idempotency window | `30` |
563
+ | `IPK_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS` | Token refresh idempotency / reuse-detection grace window (5-600) | `300` |
564
564
  | `IPK_QUOTA_IDEMPOTENCY_TTL_SECONDS` | Quota consumption idempotency window | `60` |
565
565
  | `IPK_REQUIRE_REDIS` | Fail if Redis unavailable | Auto (true in prod) |
566
566
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "identity-plan-kit"
3
- version = "1.0.3"
3
+ version = "1.3.0"
4
4
  description = "Modern FastAPI library for authentication, RBAC, subscription plans, and usage tracking"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -30,10 +30,9 @@ dependencies = [
30
30
  "sqlalchemy[asyncio]>=2.0.0",
31
31
  "asyncpg>=0.30.0",
32
32
  "alembic>=1.14.0",
33
- "httpx>=0.28.0",
34
- "authlib>=1.4.0",
35
- "passlib[bcrypt]>=1.7.4",
36
- "bcrypt>=4.0.0,<5.0.0", # Pin bcrypt <5 for passlib compatibility
33
+ "httpx2>=2.16.2",
34
+ "authlib>=1.9.10",
35
+ "bcrypt>=5.0.0",
37
36
  "uuid-utils>=0.10.0",
38
37
  "structlog>=24.0.0",
39
38
  "orjson>=3.10.0",
@@ -51,7 +50,7 @@ dev = [
51
50
  "pytest>=8.0.0",
52
51
  "pytest-asyncio>=0.24.0",
53
52
  "pytest-cov>=6.0.0",
54
- "httpx>=0.28.0",
53
+ "httpx2>=2.16.2",
55
54
  "ruff>=0.8.0",
56
55
  "ty>=0.0.47",
57
56
  "pre-commit>=4.0.0",
@@ -69,7 +68,7 @@ metrics = [
69
68
  "prometheus-client>=0.20.0",
70
69
  ]
71
70
  admin = [
72
- "sqladmin>=0.20.0",
71
+ "sqladmin>=0.32.0",
73
72
  ]
74
73
  redis = [
75
74
  "redis[hiredis]>=5.0.0",
@@ -88,6 +87,10 @@ build-backend = "hatchling.build"
88
87
  [tool.hatch.build.targets.wheel]
89
88
  packages = ["src/identity_plan_kit"]
90
89
 
90
+ # Internal files stay out of the public sdist (security audit, agent configs).
91
+ [tool.hatch.build.targets.sdist]
92
+ exclude = [".claude", ".serena", ".mcp.json", "AUDIT_REPORT.md"]
93
+
91
94
  # Ship alembic migrations and config INSIDE the installed package, not at
92
95
  # site-packages root. The previous mapping ("alembic" -> "alembic") collided
93
96
  # with the Alembic library directory and made `ipk db upgrade` unable to
@@ -158,7 +161,7 @@ testpaths = ["tests"]
158
161
  addopts = "-v --tb=short"
159
162
 
160
163
  [tool.bumpversion]
161
- current_version = "1.0.3"
164
+ current_version = "1.3.0"
162
165
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
163
166
  serialize = ["{major}.{minor}.{patch}"]
164
167
  tag = true
@@ -286,7 +286,7 @@ class AdminAuthBackend(AuthenticationBackend):
286
286
  )
287
287
  return False
288
288
 
289
- # Verify password using shared security utilities (bcrypt via passlib)
289
+ # Verify password using shared security utilities (bcrypt)
290
290
  return verify_password(password, user.password_hash)
291
291
 
292
292
  except Exception as e:
@@ -10,11 +10,11 @@ Provides pre-configured admin views for all models:
10
10
  from __future__ import annotations
11
11
 
12
12
  import os
13
- from pathlib import Path
14
13
  from typing import TYPE_CHECKING, Any
15
14
  from uuid import UUID
16
15
 
17
16
  from sqladmin import Admin, ModelView
17
+ from sqladmin.authorization import Action
18
18
  from sqlalchemy.exc import IntegrityError
19
19
  from starlette.requests import Request
20
20
  from wtforms import validators
@@ -38,6 +38,9 @@ from identity_plan_kit.shared.logging import get_logger
38
38
 
39
39
  logger = get_logger(__name__)
40
40
 
41
+ # SQLAdmin actions restricted to superadmin; list/details/export stay open to admins.
42
+ _WRITE_ACTIONS = frozenset({Action.CREATE, Action.EDIT, Action.DELETE, Action.IMPORT})
43
+
41
44
  if TYPE_CHECKING:
42
45
  from fastapi import FastAPI
43
46
  from sqlalchemy.ext.asyncio import AsyncEngine
@@ -117,8 +120,9 @@ class BaseAdminView(ModelView):
117
120
  The permission checking uses the AdminAuthBackend from the request's
118
121
  app state when available.
119
122
 
120
- Note: UI button visibility is controlled via custom templates that check
121
- request.session['admin_role']. This is thread-safe because SQLAdmin
123
+ UI button visibility is controlled per request via ``has_permission``,
124
+ which SQLAdmin consults for every create/edit/delete/import button and
125
+ route. It reads the session on each call, so it is safe even though
122
126
  ModelView instances are singletons shared across requests.
123
127
  """
124
128
 
@@ -159,11 +163,17 @@ class BaseAdminView(ModelView):
159
163
 
160
164
  Requires an authenticated session. Both superadmin and admin can view;
161
165
  write actions are gated by insert_model/update_model/delete_model
162
- which call _is_superadmin directly. Templates additionally hide write
163
- buttons via is_superadmin_user(request).
166
+ which call _is_superadmin directly. has_permission additionally hides
167
+ write buttons and blocks write routes for non-superadmins.
164
168
  """
165
169
  return bool(request.session.get("admin_authenticated"))
166
170
 
171
+ def has_permission(self, request: Request, action: str, obj: Any | None = None) -> bool:
172
+ """Only superadmin may create, edit, delete, or import records."""
173
+ if action in _WRITE_ACTIONS and not self._is_superadmin(request):
174
+ return False
175
+ return super().has_permission(request, action, obj)
176
+
167
177
  async def on_model_change(
168
178
  self, data: dict[str, Any], model: Any, is_created: bool, request: Request
169
179
  ) -> None:
@@ -1130,19 +1140,16 @@ def setup_admin(
1130
1140
  base_url=base_url,
1131
1141
  )
1132
1142
 
1133
- # Use bundled templates for role-based permission UI if no custom templates_dir provided.
1134
- # These templates check is_superadmin_user(request) to hide edit/delete buttons for non-superadmin.
1135
- if templates_dir is None:
1136
- templates_dir = str(Path(__file__).parent / "templates")
1137
-
1138
- # Build kwargs
1143
+ # Build kwargs. Role-based button visibility comes from
1144
+ # BaseAdminView.has_permission, so SQLAdmin's stock templates suffice.
1139
1145
  admin_kwargs: dict[str, Any] = {
1140
1146
  "app": app,
1141
1147
  "engine": engine,
1142
1148
  "title": title,
1143
1149
  "base_url": base_url,
1144
- "templates_dir": templates_dir,
1145
1150
  }
1151
+ if templates_dir is not None:
1152
+ admin_kwargs["templates_dir"] = templates_dir
1146
1153
  if authentication_backend is not None:
1147
1154
  admin_kwargs["authentication_backend"] = authentication_backend
1148
1155
 
@@ -1164,21 +1171,6 @@ def setup_admin(
1164
1171
  "user_plan": user_plan_cache,
1165
1172
  }
1166
1173
 
1167
- # Add Jinja2 global function for role-based permission checking in templates.
1168
- # This is thread-safe because it checks request.session on each call,
1169
- # unlike modifying ModelView instance attributes which are shared.
1170
- def is_superadmin_user(request: Request) -> bool:
1171
- """Check if current user is superadmin (for use in templates)."""
1172
- if authentication_backend and hasattr(authentication_backend, "is_superadmin"):
1173
- return authentication_backend.is_superadmin(request)
1174
- # SECURITY: Deny by default when no auth backend is configured
1175
- return False
1176
-
1177
- # Jinja2's Environment.globals is an untyped dict; widen so the checker
1178
- # accepts adding our template helper.
1179
- template_globals: dict[str, Any] = admin.templates.env.globals
1180
- template_globals["is_superadmin_user"] = is_superadmin_user
1181
-
1182
1174
  for view in get_all_admin_views():
1183
1175
  admin.add_view(view)
1184
1176
 
@@ -39,7 +39,7 @@ class UserModel(BaseModel):
39
39
  )
40
40
  # Password hash for optional password authentication (e.g., admin users).
41
41
  # Nullable because OAuth-only users don't have passwords.
42
- # Uses bcrypt via passlib - hash is ~60 chars but we use 255 for safety.
42
+ # Uses bcrypt - hash is ~60 chars but we use 255 for safety.
43
43
  password_hash: Mapped[str | None] = mapped_column(
44
44
  String(255),
45
45
  nullable=True,
@@ -5,7 +5,7 @@ import secrets
5
5
  from dataclasses import dataclass
6
6
  from typing import Any, cast
7
7
 
8
- import httpx
8
+ import httpx2
9
9
  from authlib.integrations.httpx_client import AsyncOAuth2Client
10
10
  from tenacity import (
11
11
  before_sleep_log,
@@ -34,7 +34,7 @@ GOOGLE_USERINFO_URL = "https://www.googleapis.com/oauth2/v3/userinfo"
34
34
 
35
35
  # HTTP timeout configuration. Connect/pool kept tight; read/write longer to
36
36
  # accommodate occasional Google latency on userinfo.
37
- HTTP_TIMEOUT = httpx.Timeout(
37
+ HTTP_TIMEOUT = httpx2.Timeout(
38
38
  connect=5.0,
39
39
  read=10.0,
40
40
  write=10.0,
@@ -43,11 +43,11 @@ HTTP_TIMEOUT = httpx.Timeout(
43
43
 
44
44
  # Retry only on transient network errors. HTTP 4xx (bad request) is never retried.
45
45
  RETRYABLE_EXCEPTIONS = (
46
- httpx.ConnectError,
47
- httpx.ConnectTimeout,
48
- httpx.ReadTimeout,
49
- httpx.WriteTimeout,
50
- httpx.PoolTimeout,
46
+ httpx2.ConnectError,
47
+ httpx2.ConnectTimeout,
48
+ httpx2.ReadTimeout,
49
+ httpx2.WriteTimeout,
50
+ httpx2.PoolTimeout,
51
51
  OSError,
52
52
  ConnectionError,
53
53
  )
@@ -259,7 +259,7 @@ class GoogleOAuthService:
259
259
  try:
260
260
  await self._acquire_semaphore()
261
261
  acquired = True
262
- # authlib's AsyncOAuth2Client subclasses httpx.AsyncClient (a real
262
+ # authlib's AsyncOAuth2Client subclasses httpx2.AsyncClient (a real
263
263
  # async context manager), but its stubs omit __aenter__/__aexit__,
264
264
  # so type checkers misread the `async with` form — manage the
265
265
  # client lifecycle explicitly instead.
@@ -277,13 +277,13 @@ class GoogleOAuthService:
277
277
  )
278
278
  logger.debug("oauth_code_exchanged", provider="google")
279
279
  return dict(token)
280
- except httpx.TimeoutException:
280
+ except httpx2.TimeoutException:
281
281
  logger.warning(
282
282
  "oauth_code_exchange_timeout",
283
283
  provider="google",
284
284
  )
285
285
  raise
286
- except httpx.HTTPStatusError as e:
286
+ except httpx2.HTTPStatusError as e:
287
287
  if HTTP_CLIENT_ERROR_MIN <= e.response.status_code < HTTP_CLIENT_ERROR_MAX:
288
288
  logger.exception(
289
289
  "oauth_code_exchange_client_error",
@@ -311,9 +311,9 @@ class GoogleOAuthService:
311
311
  provider="google",
312
312
  ) from e
313
313
  finally:
314
- # cast: authlib's stubs omit the httpx.AsyncClient base
314
+ # cast: authlib's stubs omit the httpx2.AsyncClient base
315
315
  # surface entirely (aclose, __aenter__, ...).
316
- await cast("httpx.AsyncClient", client).aclose()
316
+ await cast("httpx2.AsyncClient", client).aclose()
317
317
  finally:
318
318
  if acquired:
319
319
  self._semaphore.release()
@@ -372,7 +372,7 @@ class GoogleOAuthService:
372
372
  try:
373
373
  await self._acquire_semaphore()
374
374
  acquired = True
375
- async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
375
+ async with httpx2.AsyncClient(timeout=HTTP_TIMEOUT) as client:
376
376
  try:
377
377
  response = await client.get(
378
378
  GOOGLE_USERINFO_URL,
@@ -396,14 +396,14 @@ class GoogleOAuthService:
396
396
  family_name=data.get("family_name"),
397
397
  picture=data.get("picture"),
398
398
  )
399
- except httpx.TimeoutException:
399
+ except httpx2.TimeoutException:
400
400
  logger.warning(
401
401
  "oauth_user_info_timeout",
402
402
  provider="google",
403
403
  )
404
404
  # Re-raise for retry
405
405
  raise
406
- except httpx.HTTPStatusError as e:
406
+ except httpx2.HTTPStatusError as e:
407
407
  # HTTP errors - don't retry 4xx
408
408
  if HTTP_CLIENT_ERROR_MIN <= e.response.status_code < HTTP_CLIENT_ERROR_MAX:
409
409
  logger.exception(
@@ -442,11 +442,13 @@ class IdentityPlanKitConfig(BaseSettings):
442
442
 
443
443
  # Token refresh idempotency
444
444
  token_refresh_idempotency_ttl_seconds: int = Field(
445
- default=30,
445
+ default=300,
446
446
  ge=5,
447
- le=120,
447
+ le=600,
448
448
  description="TTL for token refresh idempotency cache in seconds. "
449
- "Allows clients to safely retry refresh requests within this window.",
449
+ "Allows clients to safely retry refresh requests within this window; "
450
+ "a rotated refresh token replayed within it is rejected without "
451
+ "triggering reuse detection (session revoke + account deactivation).",
450
452
  )
451
453
 
452
454
  # Quota consumption idempotency
@@ -132,7 +132,7 @@ DEFAULT_ACCESS_TOKEN_EXPIRE_MINUTES = 15
132
132
  DEFAULT_REFRESH_TOKEN_EXPIRE_DAYS = 7
133
133
 
134
134
  # Token refresh idempotency TTL in seconds
135
- DEFAULT_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS = 10
135
+ DEFAULT_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS = 300
136
136
 
137
137
  # Quota idempotency TTL in seconds
138
138
  DEFAULT_QUOTA_IDEMPOTENCY_TTL_SECONDS = 60
@@ -7,18 +7,20 @@ from datetime import UTC, datetime, timedelta
7
7
  from functools import lru_cache
8
8
  from typing import Any
9
9
 
10
+ import bcrypt
10
11
  import jwt
11
12
  from cryptography.fernet import Fernet, InvalidToken
12
13
  from cryptography.hazmat.primitives import hashes
13
14
  from cryptography.hazmat.primitives.kdf.hkdf import HKDF
14
- from passlib.context import CryptContext
15
15
 
16
16
  from identity_plan_kit.shared.logging import get_logger
17
17
 
18
18
  logger = get_logger(__name__)
19
19
 
20
- # Password hashing context (for future password auth support)
21
- pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
20
+ # bcrypt reads only the first 72 bytes of a password. passlib (used before 1.3.0)
21
+ # truncated silently; bcrypt>=5 raises instead. Truncating here keeps hashes stored
22
+ # by earlier releases verifiable.
23
+ _BCRYPT_MAX_PASSWORD_BYTES = 72
22
24
 
23
25
 
24
26
  # Minimum secret key length for security
@@ -232,7 +234,7 @@ def hash_password(password: str) -> str:
232
234
  Returns:
233
235
  Hashed password string
234
236
  """
235
- return pwd_context.hash(password)
237
+ return bcrypt.hashpw(_bcrypt_input(password), bcrypt.gensalt()).decode("ascii")
236
238
 
237
239
 
238
240
  def verify_password(plain_password: str, hashed_password: str) -> bool:
@@ -246,7 +248,11 @@ def verify_password(plain_password: str, hashed_password: str) -> bool:
246
248
  Returns:
247
249
  True if password matches
248
250
  """
249
- return pwd_context.verify(plain_password, hashed_password)
251
+ return bcrypt.checkpw(_bcrypt_input(plain_password), hashed_password.encode("utf-8"))
252
+
253
+
254
+ def _bcrypt_input(password: str) -> bytes:
255
+ return password.encode("utf-8")[:_BCRYPT_MAX_PASSWORD_BYTES]
250
256
 
251
257
 
252
258
  # =============================================================================
@@ -196,14 +196,14 @@ class TestRetryableExceptions:
196
196
 
197
197
  def test_network_errors_are_retryable(self):
198
198
  """Network-related exceptions should be retryable."""
199
- import httpx
199
+ import httpx2
200
200
 
201
201
  expected_retryable = {
202
- httpx.ConnectError,
203
- httpx.ConnectTimeout,
204
- httpx.ReadTimeout,
205
- httpx.WriteTimeout,
206
- httpx.PoolTimeout,
202
+ httpx2.ConnectError,
203
+ httpx2.ConnectTimeout,
204
+ httpx2.ReadTimeout,
205
+ httpx2.WriteTimeout,
206
+ httpx2.PoolTimeout,
207
207
  OSError,
208
208
  ConnectionError,
209
209
  }
@@ -0,0 +1,126 @@
1
+ """SQLAdmin role gating against a real admin app.
2
+
3
+ Superadmin (env credentials) gets create/edit/delete; DB admins are view-only.
4
+ Button visibility and the write routes both come from
5
+ ``BaseAdminView.has_permission`` — no template overrides involved.
6
+ """
7
+
8
+ from collections.abc import AsyncGenerator
9
+ from http import HTTPStatus
10
+ from typing import Any
11
+ from uuid import uuid4
12
+
13
+ import pytest
14
+ from fastapi import FastAPI
15
+ from httpx2 import ASGITransport, AsyncClient
16
+ from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
17
+
18
+ from identity_plan_kit.admin.auth import AdminAuthBackend
19
+ from identity_plan_kit.admin.views import RoleAdmin, setup_admin
20
+ from identity_plan_kit.rbac.models.role import RoleModel
21
+
22
+ SUPERADMIN_EMAIL = "root@example.com"
23
+ SUPERADMIN_PASSWORD = "root-password-123" # noqa: S105
24
+ DB_ADMIN_EMAIL = "viewer@example.com"
25
+ DB_ADMIN_PASSWORD = "viewer-password-123" # noqa: S105
26
+
27
+
28
+ @pytest.fixture
29
+ async def role(session_factory: async_sessionmaker[AsyncSession]) -> RoleModel:
30
+ async with session_factory() as session:
31
+ role = RoleModel(code=f"perm_test_{uuid4().hex[:8]}", name="Admin Perm Test")
32
+ session.add(role)
33
+ await session.commit()
34
+ return role
35
+
36
+
37
+ @pytest.fixture
38
+ def role_id(role: RoleModel) -> str:
39
+ return str(role.id)
40
+
41
+
42
+ @pytest.fixture
43
+ async def admin_client(
44
+ db_engine: AsyncEngine,
45
+ session_factory: async_sessionmaker[AsyncSession],
46
+ monkeypatch: pytest.MonkeyPatch,
47
+ ) -> AsyncGenerator[AsyncClient, None]:
48
+ backend = AdminAuthBackend(
49
+ secret_key="s" * 32,
50
+ admin_email=SUPERADMIN_EMAIL,
51
+ admin_password=SUPERADMIN_PASSWORD,
52
+ session_factory=session_factory,
53
+ )
54
+
55
+ # DB-admin lookup is covered elsewhere; here we only need a session that
56
+ # carries the view-only "admin" role.
57
+ async def _fake_db_admin(_self: Any, email: str, password: str) -> bool:
58
+ return email == DB_ADMIN_EMAIL and password == DB_ADMIN_PASSWORD
59
+
60
+ monkeypatch.setattr(AdminAuthBackend, "_authenticate_db_admin", _fake_db_admin)
61
+
62
+ app = FastAPI()
63
+ setup_admin(app, db_engine, authentication_backend=backend)
64
+ async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
65
+ yield client
66
+
67
+
68
+ async def _login(client: AsyncClient, email: str, password: str) -> None:
69
+ resp = await client.post("/admin/login", data={"username": email, "password": password})
70
+ assert resp.status_code in (302, 303), resp.text
71
+
72
+
73
+ IDENTITY = RoleAdmin.identity
74
+
75
+
76
+ class TestSuperadmin:
77
+ async def test_sees_and_reaches_write_actions(
78
+ self, admin_client: AsyncClient, role_id: str
79
+ ) -> None:
80
+ await _login(admin_client, SUPERADMIN_EMAIL, SUPERADMIN_PASSWORD)
81
+
82
+ listing = await admin_client.get(f"/admin/{IDENTITY}/list")
83
+ assert listing.status_code == HTTPStatus.OK
84
+ assert f"/admin/{IDENTITY}/create" in listing.text
85
+ assert f"/admin/{IDENTITY}/edit/{role_id}" in listing.text
86
+ assert f"/admin/{IDENTITY}/delete" in listing.text
87
+
88
+ assert (await admin_client.get(f"/admin/{IDENTITY}/create")).status_code == HTTPStatus.OK
89
+ assert (
90
+ await admin_client.get(f"/admin/{IDENTITY}/edit/{role_id}")
91
+ ).status_code == HTTPStatus.OK
92
+
93
+
94
+ class TestDbAdminIsViewOnly:
95
+ async def test_can_list_and_view_details(
96
+ self, admin_client: AsyncClient, role: RoleModel, role_id: str
97
+ ) -> None:
98
+ await _login(admin_client, DB_ADMIN_EMAIL, DB_ADMIN_PASSWORD)
99
+
100
+ listing = await admin_client.get(f"/admin/{IDENTITY}/list")
101
+ assert listing.status_code == HTTPStatus.OK
102
+ assert role.code in listing.text
103
+
104
+ details = await admin_client.get(f"/admin/{IDENTITY}/details/{role_id}")
105
+ assert details.status_code == HTTPStatus.OK
106
+ assert f"/admin/{IDENTITY}/edit/{role_id}" not in details.text
107
+
108
+ async def test_write_buttons_hidden(self, admin_client: AsyncClient, role_id: str) -> None:
109
+ await _login(admin_client, DB_ADMIN_EMAIL, DB_ADMIN_PASSWORD)
110
+
111
+ listing = await admin_client.get(f"/admin/{IDENTITY}/list")
112
+ assert f"/admin/{IDENTITY}/create" not in listing.text
113
+ assert f"/admin/{IDENTITY}/edit/{role_id}" not in listing.text
114
+ assert f"/admin/{IDENTITY}/delete" not in listing.text
115
+
116
+ async def test_write_routes_forbidden(self, admin_client: AsyncClient, role_id: str) -> None:
117
+ await _login(admin_client, DB_ADMIN_EMAIL, DB_ADMIN_PASSWORD)
118
+
119
+ assert (
120
+ await admin_client.get(f"/admin/{IDENTITY}/create")
121
+ ).status_code == HTTPStatus.FORBIDDEN
122
+ assert (
123
+ await admin_client.get(f"/admin/{IDENTITY}/edit/{role_id}")
124
+ ).status_code == HTTPStatus.FORBIDDEN
125
+ delete = await admin_client.delete(f"/admin/{IDENTITY}/delete", params={"pks": role_id})
126
+ assert delete.status_code == HTTPStatus.FORBIDDEN
@@ -17,7 +17,7 @@ from datetime import date, timedelta
17
17
  from uuid import UUID, uuid4
18
18
 
19
19
  import pytest
20
- from httpx import ASGITransport, AsyncClient
20
+ from httpx2 import ASGITransport, AsyncClient
21
21
  from sqlalchemy import text
22
22
  from sqlalchemy.ext.asyncio import (
23
23
  AsyncEngine,
@@ -72,7 +72,8 @@ class TestRedisStaleWritePrevention:
72
72
  async def test_stale_write_rejected_after_key_invalidation(self, redis_cache, sample_plan):
73
73
  """Test that stale writes are rejected after key-specific invalidation."""
74
74
  # Get timestamp before invalidation
75
- old_ts = time.time()
75
+ # Strictly earlier: back-to-back time.time() calls can return the same value.
76
+ old_ts = time.time() - 1.0
76
77
 
77
78
  # Invalidate the plan
78
79
  await redis_cache.invalidate("test")
@@ -112,7 +113,8 @@ class TestRedisStaleWritePrevention:
112
113
  async def test_stale_write_rejected_after_global_invalidation(self, redis_cache, sample_plan):
113
114
  """Test that stale writes are rejected after invalidate_all()."""
114
115
  # Get timestamp before global invalidation
115
- old_ts = time.time()
116
+ # Strictly earlier: back-to-back time.time() calls can return the same value.
117
+ old_ts = time.time() - 1.0
116
118
 
117
119
  # Global invalidation
118
120
  await redis_cache.invalidate_all()
@@ -152,7 +154,8 @@ class TestRedisStaleWritePrevention:
152
154
  async def test_key_specific_vs_global_invalidation_precedence(self, redis_cache, sample_plan):
153
155
  """Test that both key-specific and global invalidation are checked."""
154
156
  # Get old timestamp
155
- old_ts = time.time()
157
+ # Strictly earlier: back-to-back time.time() calls can return the same value.
158
+ old_ts = time.time() - 1.0
156
159
 
157
160
  # Key-specific invalidation
158
161
  await redis_cache.invalidate("test")
@@ -452,15 +452,26 @@ class TestGracefulShutdownValidation:
452
452
  class TestIdempotencyValidation:
453
453
  """Test token refresh idempotency configuration."""
454
454
 
455
+ def test_idempotency_ttl_default_is_five_minutes(self, monkeypatch):
456
+ """Default grace window is 5 minutes."""
457
+ monkeypatch.delenv("IPK_TOKEN_REFRESH_IDEMPOTENCY_TTL_SECONDS", raising=False)
458
+ config = create_minimal_config(_env_file=None)
459
+ assert config.token_refresh_idempotency_ttl_seconds == 300
460
+
455
461
  def test_idempotency_ttl_range(self):
456
- """Idempotency TTL must be 5-120 seconds."""
462
+ """Idempotency TTL must be 5-600 seconds."""
457
463
  # Minimum
458
464
  config_min = create_minimal_config(token_refresh_idempotency_ttl_seconds=5)
459
465
  assert config_min.token_refresh_idempotency_ttl_seconds == 5
460
466
 
461
467
  # Maximum
462
- config_max = create_minimal_config(token_refresh_idempotency_ttl_seconds=120)
463
- assert config_max.token_refresh_idempotency_ttl_seconds == 120
468
+ config_max = create_minimal_config(token_refresh_idempotency_ttl_seconds=600)
469
+ assert config_max.token_refresh_idempotency_ttl_seconds == 600
470
+
471
+ def test_idempotency_ttl_too_high_rejected(self):
472
+ """Idempotency TTL over 600 seconds is rejected."""
473
+ with pytest.raises(ValidationError):
474
+ create_minimal_config(token_refresh_idempotency_ttl_seconds=601)
464
475
 
465
476
  def test_idempotency_ttl_too_low_rejected(self):
466
477
  """Idempotency TTL under 5 seconds is rejected."""