mcp-security-framework 1.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 +41 -22
- mcp_security_framework/core/cert_manager.py +210 -147
- mcp_security_framework/core/permission_manager.py +9 -9
- mcp_security_framework/core/rate_limiter.py +2 -2
- mcp_security_framework/core/security_manager.py +284 -229
- mcp_security_framework/examples/__init__.py +6 -0
- mcp_security_framework/examples/comprehensive_example.py +349 -279
- mcp_security_framework/examples/django_example.py +247 -206
- mcp_security_framework/examples/fastapi_example.py +315 -283
- mcp_security_framework/examples/flask_example.py +274 -203
- mcp_security_framework/examples/gateway_example.py +304 -237
- mcp_security_framework/examples/microservice_example.py +258 -189
- mcp_security_framework/examples/standalone_example.py +255 -230
- mcp_security_framework/examples/test_all_examples.py +151 -135
- 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 +119 -118
- mcp_security_framework/middleware/fastapi_middleware.py +156 -148
- mcp_security_framework/middleware/flask_auth_middleware.py +160 -147
- 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 +18 -6
- mcp_security_framework/utils/cert_utils.py +14 -8
- mcp_security_framework/utils/datetime_compat.py +116 -0
- {mcp_security_framework-1.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 +63 -66
- tests/test_cli/test_cert_cli.py +184 -146
- tests/test_cli/test_security_cli.py +274 -247
- tests/test_core/test_cert_manager.py +24 -10
- tests/test_core/test_security_manager.py +2 -2
- tests/test_examples/test_comprehensive_example.py +190 -137
- tests/test_examples/test_fastapi_example.py +124 -101
- tests/test_examples/test_flask_example.py +124 -101
- tests/test_examples/test_standalone_example.py +73 -80
- tests/test_integration/test_auth_flow.py +213 -197
- tests/test_integration/test_certificate_flow.py +180 -149
- tests/test_integration/test_fastapi_integration.py +108 -111
- tests/test_integration/test_flask_integration.py +141 -140
- tests/test_integration/test_standalone_integration.py +290 -259
- tests/test_middleware/test_fastapi_auth_middleware.py +195 -174
- tests/test_middleware/test_fastapi_middleware.py +147 -132
- tests/test_middleware/test_flask_auth_middleware.py +260 -202
- tests/test_middleware/test_flask_middleware.py +201 -179
- tests/test_middleware/test_security_middleware.py +145 -130
- tests/test_utils/test_datetime_compat.py +147 -0
- mcp_security_framework-1.1.0.dist-info/RECORD +0 -82
- {mcp_security_framework-1.1.0.dist-info → mcp_security_framework-1.1.1.dist-info}/WHEEL +0 -0
- {mcp_security_framework-1.1.0.dist-info → mcp_security_framework-1.1.1.dist-info}/entry_points.txt +0 -0
- {mcp_security_framework-1.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
|
@@ -700,11 +700,11 @@ class PermissionManager:
|
|
700
700
|
def _load_external_permissions(self) -> Dict[str, List[str]]:
|
701
701
|
"""
|
702
702
|
Load permissions from external systems.
|
703
|
-
|
703
|
+
|
704
704
|
This is a placeholder method for external permission loading.
|
705
705
|
In a real implementation, this would connect to external systems
|
706
706
|
like LDAP, Active Directory, or other identity providers.
|
707
|
-
|
707
|
+
|
708
708
|
Returns:
|
709
709
|
Dict[str, List[str]]: Dictionary mapping role names to permission lists
|
710
710
|
"""
|
@@ -182,12 +182,12 @@ class RateLimiter:
|
|
182
182
|
"storage_backend": config.storage_backend,
|
183
183
|
},
|
184
184
|
)
|
185
|
-
|
185
|
+
|
186
186
|
@property
|
187
187
|
def is_rate_limiting_enabled(self) -> bool:
|
188
188
|
"""
|
189
189
|
Check if rate limiting is enabled.
|
190
|
-
|
190
|
+
|
191
191
|
Returns:
|
192
192
|
bool: True if rate limiting is enabled, False otherwise
|
193
193
|
"""
|