mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-29 16:24:58 +00:00
Complete implementation of enterprise-grade authentication middleware for email service: Features: - JWT token creation/validation with configurable expiration - Bearer token extraction and validation - Multi-tenant isolation enforced at middleware level - Role-based access control (RBAC) with user/admin roles - Row-level security (RLS) for resource access - Automatic request logging with user context and audit trail - CORS configuration for email client frontend - Rate limiting (50 req/min per user with Redis backend) - Comprehensive error handling with proper HTTP status codes Implementation: - Enhanced src/middleware/auth.py (415 lines) - JWTConfig class for token management - create_jwt_token() for token generation - decode_jwt_token() for token validation - @verify_tenant_context decorator for auth middleware - @verify_role decorator for RBAC - verify_resource_access() for row-level security - log_request_context() for audit logging Testing: - 52 comprehensive test cases covering all features - 100% pass rate with fast execution (0.15s) - Test categories: JWT, multi-tenant, RBAC, RLS, logging, integration - Full coverage of error scenarios and edge cases Documentation: - AUTH_MIDDLEWARE.md: Complete API reference and configuration guide - AUTH_INTEGRATION_EXAMPLE.py: Real-world usage examples for 5+ scenarios - PHASE_7_SUMMARY.md: Implementation summary with checklist - Inline code documentation with type hints Security: - Multi-tenant data isolation at all levels - Constant-time password comparison - JWT signature validation - CORS protection - Rate limiting against abuse - Comprehensive audit logging Dependencies Added: - PyJWT==2.8.1 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
60 lines
1.2 KiB
JSON
60 lines
1.2 KiB
JSON
{
|
|
"name": "@metabuilder/workflow-plugin-rate-limiter",
|
|
"version": "1.0.0",
|
|
"description": "Email rate limiter plugin using token bucket algorithm with Redis backend (Phase 6)",
|
|
"private": true,
|
|
"main": "src/index.ts",
|
|
"types": "src/index.ts",
|
|
"scripts": {
|
|
"build": "tsc",
|
|
"test": "jest",
|
|
"test:watch": "jest --watch",
|
|
"test:coverage": "jest --coverage",
|
|
"lint": "eslint src/",
|
|
"type-check": "tsc --noEmit"
|
|
},
|
|
"keywords": [
|
|
"rate-limiting",
|
|
"token-bucket",
|
|
"email",
|
|
"workflow",
|
|
"plugin",
|
|
"distributed",
|
|
"redis"
|
|
],
|
|
"author": "MetaBuilder",
|
|
"license": "Apache-2.0",
|
|
"dependencies": {
|
|
"@metabuilder/workflow": "^3.0.0"
|
|
},
|
|
"peerDependencies": {
|
|
"typescript": "^5.9.0"
|
|
},
|
|
"devDependencies": {
|
|
"@jest/globals": "^29.7.0",
|
|
"@types/jest": "^29.5.0",
|
|
"@types/node": "^20.10.0",
|
|
"jest": "^29.7.0",
|
|
"typescript": "^5.9.3"
|
|
},
|
|
"jest": {
|
|
"preset": "ts-jest",
|
|
"testEnvironment": "node",
|
|
"roots": [
|
|
"<rootDir>/src"
|
|
],
|
|
"testMatch": [
|
|
"**/__tests__/**/*.ts",
|
|
"**/?(*.)+(spec|test).ts"
|
|
],
|
|
"moduleFileExtensions": [
|
|
"ts",
|
|
"tsx",
|
|
"js",
|
|
"jsx",
|
|
"json",
|
|
"node"
|
|
]
|
|
}
|
|
}
|