mcp-security-framework 0.1.0__py3-none-any.whl → 1.1.1__py3-none-any.whl
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.
- mcp_security_framework/__init__.py +26 -15
- mcp_security_framework/cli/__init__.py +1 -1
- mcp_security_framework/cli/cert_cli.py +233 -197
- mcp_security_framework/cli/security_cli.py +324 -234
- mcp_security_framework/constants.py +21 -27
- mcp_security_framework/core/auth_manager.py +49 -20
- mcp_security_framework/core/cert_manager.py +398 -104
- mcp_security_framework/core/permission_manager.py +13 -9
- mcp_security_framework/core/rate_limiter.py +10 -0
- mcp_security_framework/core/security_manager.py +286 -229
- mcp_security_framework/examples/__init__.py +6 -0
- mcp_security_framework/examples/comprehensive_example.py +954 -0
- mcp_security_framework/examples/django_example.py +276 -202
- mcp_security_framework/examples/fastapi_example.py +897 -393
- mcp_security_framework/examples/flask_example.py +311 -200
- mcp_security_framework/examples/gateway_example.py +373 -214
- mcp_security_framework/examples/microservice_example.py +337 -172
- mcp_security_framework/examples/standalone_example.py +719 -478
- mcp_security_framework/examples/test_all_examples.py +572 -0
- mcp_security_framework/middleware/__init__.py +46 -55
- mcp_security_framework/middleware/auth_middleware.py +62 -63
- mcp_security_framework/middleware/fastapi_auth_middleware.py +179 -110
- mcp_security_framework/middleware/fastapi_middleware.py +156 -148
- mcp_security_framework/middleware/flask_auth_middleware.py +267 -107
- mcp_security_framework/middleware/flask_middleware.py +183 -157
- mcp_security_framework/middleware/mtls_middleware.py +106 -117
- mcp_security_framework/middleware/rate_limit_middleware.py +105 -101
- mcp_security_framework/middleware/security_middleware.py +109 -124
- mcp_security_framework/schemas/config.py +2 -1
- mcp_security_framework/schemas/models.py +19 -6
- mcp_security_framework/utils/cert_utils.py +14 -8
- mcp_security_framework/utils/datetime_compat.py +116 -0
- {mcp_security_framework-0.1.0.dist-info → mcp_security_framework-1.1.1.dist-info}/METADATA +2 -1
- mcp_security_framework-1.1.1.dist-info/RECORD +84 -0
- tests/conftest.py +303 -0
- tests/test_cli/test_cert_cli.py +194 -174
- tests/test_cli/test_security_cli.py +274 -247
- tests/test_core/test_cert_manager.py +33 -19
- tests/test_core/test_security_manager.py +2 -2
- tests/test_examples/test_comprehensive_example.py +613 -0
- tests/test_examples/test_fastapi_example.py +290 -169
- tests/test_examples/test_flask_example.py +304 -162
- tests/test_examples/test_standalone_example.py +106 -168
- tests/test_integration/test_auth_flow.py +214 -198
- tests/test_integration/test_certificate_flow.py +181 -150
- tests/test_integration/test_fastapi_integration.py +140 -149
- tests/test_integration/test_flask_integration.py +144 -141
- tests/test_integration/test_standalone_integration.py +331 -300
- tests/test_middleware/test_fastapi_auth_middleware.py +745 -0
- tests/test_middleware/test_fastapi_middleware.py +147 -132
- tests/test_middleware/test_flask_auth_middleware.py +696 -0
- tests/test_middleware/test_flask_middleware.py +201 -179
- tests/test_middleware/test_security_middleware.py +151 -130
- tests/test_utils/test_datetime_compat.py +147 -0
- mcp_security_framework-0.1.0.dist-info/RECORD +0 -76
- {mcp_security_framework-0.1.0.dist-info → mcp_security_framework-1.1.1.dist-info}/WHEEL +0 -0
- {mcp_security_framework-0.1.0.dist-info → mcp_security_framework-1.1.1.dist-info}/entry_points.txt +0 -0
- {mcp_security_framework-0.1.0.dist-info → mcp_security_framework-1.1.1.dist-info}/top_level.txt +0 -0
@@ -182,10 +182,10 @@ class PermissionManager:
|
|
182
182
|
|
183
183
|
if is_valid:
|
184
184
|
return ValidationResult(
|
185
|
-
is_valid=True,
|
185
|
+
is_valid=True,
|
186
186
|
status=ValidationStatus.VALID,
|
187
187
|
granted_permissions=list(effective_permissions),
|
188
|
-
denied_permissions=[]
|
188
|
+
denied_permissions=[],
|
189
189
|
)
|
190
190
|
else:
|
191
191
|
return ValidationResult(
|
@@ -194,7 +194,7 @@ class PermissionManager:
|
|
194
194
|
error_code=-32003,
|
195
195
|
error_message=f"Missing permissions: {missing_permissions}",
|
196
196
|
granted_permissions=list(effective_permissions),
|
197
|
-
denied_permissions=list(missing_permissions)
|
197
|
+
denied_permissions=list(missing_permissions),
|
198
198
|
)
|
199
199
|
|
200
200
|
except Exception as e:
|
@@ -516,7 +516,7 @@ class PermissionManager:
|
|
516
516
|
exported_config = {
|
517
517
|
"roles": {},
|
518
518
|
"permissions": {},
|
519
|
-
"hierarchy": self._hierarchy.copy()
|
519
|
+
"hierarchy": self._hierarchy.copy(),
|
520
520
|
}
|
521
521
|
|
522
522
|
# Export roles with their permissions
|
@@ -524,7 +524,7 @@ class PermissionManager:
|
|
524
524
|
exported_config["roles"][role_name] = {
|
525
525
|
"description": role_data.get("description", ""),
|
526
526
|
"permissions": role_data.get("permissions", []),
|
527
|
-
"parent_roles": self._hierarchy.get(role_name, [])
|
527
|
+
"parent_roles": self._hierarchy.get(role_name, []),
|
528
528
|
}
|
529
529
|
|
530
530
|
# Collect all unique permissions
|
@@ -544,8 +544,8 @@ class PermissionManager:
|
|
544
544
|
"Roles configuration exported",
|
545
545
|
extra={
|
546
546
|
"roles_count": len(exported_config["roles"]),
|
547
|
-
"permissions_count": len(exported_config["permissions"])
|
548
|
-
}
|
547
|
+
"permissions_count": len(exported_config["permissions"]),
|
548
|
+
},
|
549
549
|
)
|
550
550
|
|
551
551
|
return exported_config
|
@@ -660,6 +660,10 @@ class PermissionManager:
|
|
660
660
|
if required_perm in available_permissions:
|
661
661
|
return True
|
662
662
|
|
663
|
+
# Check for universal permission "*" (all permissions)
|
664
|
+
if "*" in available_permissions:
|
665
|
+
return True
|
666
|
+
|
663
667
|
# Wildcard match
|
664
668
|
if "*" in required_perm:
|
665
669
|
perm_parts = required_perm.split(":")
|
@@ -696,11 +700,11 @@ class PermissionManager:
|
|
696
700
|
def _load_external_permissions(self) -> Dict[str, List[str]]:
|
697
701
|
"""
|
698
702
|
Load permissions from external systems.
|
699
|
-
|
703
|
+
|
700
704
|
This is a placeholder method for external permission loading.
|
701
705
|
In a real implementation, this would connect to external systems
|
702
706
|
like LDAP, Active Directory, or other identity providers.
|
703
|
-
|
707
|
+
|
704
708
|
Returns:
|
705
709
|
Dict[str, List[str]]: Dictionary mapping role names to permission lists
|
706
710
|
"""
|
@@ -183,6 +183,16 @@ class RateLimiter:
|
|
183
183
|
},
|
184
184
|
)
|
185
185
|
|
186
|
+
@property
|
187
|
+
def is_rate_limiting_enabled(self) -> bool:
|
188
|
+
"""
|
189
|
+
Check if rate limiting is enabled.
|
190
|
+
|
191
|
+
Returns:
|
192
|
+
bool: True if rate limiting is enabled, False otherwise
|
193
|
+
"""
|
194
|
+
return self.config.enabled
|
195
|
+
|
186
196
|
def check_rate_limit(self, identifier: str, limit: Optional[int] = None) -> bool:
|
187
197
|
"""
|
188
198
|
Check if rate limit is exceeded for the given identifier.
|