api-foundry 0.1.30__tar.gz → 0.8.1__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.
- {api_foundry-0.1.30 → api_foundry-0.8.1}/PKG-INFO +1 -1
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/iac/pulumi/api_foundry.py +8 -5
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/utils/model_factory.py +15 -66
- {api_foundry-0.1.30 → api_foundry-0.8.1}/pyproject.toml +1 -1
- {api_foundry-0.1.30 → api_foundry-0.8.1}/.gitignore +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/LICENSE +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/__init__.py +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/iac/gateway_spec.py +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/scripts/install_secret.py +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/scripts/postgres_to_openapi.py +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/utils/app_exception.py +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/utils/logger.py +0 -0
- {api_foundry-0.1.30 → api_foundry-0.8.1}/api_foundry/utils/schema_validator.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: api-foundry
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.8.1
|
|
4
4
|
Summary: The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs
|
|
5
5
|
Project-URL: Documentation, https://github.com/DanRepik/api-foundry
|
|
6
6
|
Project-URL: Source, https://github.com/DanRepik/api-foundry
|
|
@@ -149,6 +149,7 @@ class APIFoundry(ComponentResource):
|
|
|
149
149
|
vpc_config = vpc_config or config_defaults.get("vpc_config", {})
|
|
150
150
|
|
|
151
151
|
env_vars["SECRETS"] = secrets
|
|
152
|
+
requirements = []
|
|
152
153
|
|
|
153
154
|
# Grant read access to referenced secrets (single broad stmt)
|
|
154
155
|
if json.loads(secrets):
|
|
@@ -160,6 +161,12 @@ class APIFoundry(ComponentResource):
|
|
|
160
161
|
}
|
|
161
162
|
)
|
|
162
163
|
|
|
164
|
+
requirements.extend(
|
|
165
|
+
["psycopg2-binary", "pyyaml", "../api_foundry_query_engine"]
|
|
166
|
+
)
|
|
167
|
+
if env_vars.get("JWKS_HOST"):
|
|
168
|
+
requirements.extend(["PyJWT", "cryptography", "requests"])
|
|
169
|
+
|
|
163
170
|
self.api_function = cloud_foundry.python_function(
|
|
164
171
|
name=name,
|
|
165
172
|
environment=env_vars,
|
|
@@ -169,11 +176,7 @@ class APIFoundry(ComponentResource):
|
|
|
169
176
|
ModelFactory(api_spec_dict).get_config_output()
|
|
170
177
|
),
|
|
171
178
|
},
|
|
172
|
-
requirements=
|
|
173
|
-
"psycopg2-binary",
|
|
174
|
-
"pyyaml",
|
|
175
|
-
"api_foundry_query_engine",
|
|
176
|
-
],
|
|
179
|
+
requirements=requirements,
|
|
177
180
|
policy_statements=policy_statements,
|
|
178
181
|
vpc_config=vpc_config,
|
|
179
182
|
)
|
|
@@ -355,6 +355,7 @@ class SchemaObject(OpenAPIElement):
|
|
|
355
355
|
def _get_permissions(self, schema_object: dict) -> dict:
|
|
356
356
|
"""Extract permissions from schema using x-af-permissions only.
|
|
357
357
|
|
|
358
|
+
Expects provider -> action -> role -> rule format.
|
|
358
359
|
Also normalizes action names so 'create'/'update' map to 'write'.
|
|
359
360
|
"""
|
|
360
361
|
raw_permissions = schema_object.get("x-af-permissions") or {}
|
|
@@ -366,42 +367,14 @@ class SchemaObject(OpenAPIElement):
|
|
|
366
367
|
result[key] = value
|
|
367
368
|
return result
|
|
368
369
|
|
|
369
|
-
def is_legacy_role_form(obj: Dict[str, Any]) -> bool:
|
|
370
|
-
# Legacy: role -> { action: rule }
|
|
371
|
-
if not isinstance(obj, dict):
|
|
372
|
-
return False
|
|
373
|
-
for v in obj.values():
|
|
374
|
-
if isinstance(v, dict):
|
|
375
|
-
# Any dict that looks like action->rule (value not dict)
|
|
376
|
-
for k2, v2 in v.items():
|
|
377
|
-
if k2 in {
|
|
378
|
-
"read",
|
|
379
|
-
"write",
|
|
380
|
-
"delete",
|
|
381
|
-
"create",
|
|
382
|
-
"update",
|
|
383
|
-
} and not isinstance(v2, dict):
|
|
384
|
-
return True
|
|
385
|
-
return False
|
|
386
|
-
|
|
387
370
|
normalized: Dict[str, Any] = {}
|
|
388
371
|
if isinstance(raw_permissions, dict):
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
normalized[role] = actions
|
|
396
|
-
else:
|
|
397
|
-
# New form: provider -> action -> role
|
|
398
|
-
for provider, actions in raw_permissions.items():
|
|
399
|
-
if isinstance(actions, dict):
|
|
400
|
-
normalized[provider] = normalize_actions(actions)
|
|
401
|
-
else:
|
|
402
|
-
normalized[provider] = actions
|
|
403
|
-
else:
|
|
404
|
-
normalized = {}
|
|
372
|
+
# Expected format: provider -> action -> role -> rule
|
|
373
|
+
for provider, actions in raw_permissions.items():
|
|
374
|
+
if isinstance(actions, dict):
|
|
375
|
+
normalized[provider] = normalize_actions(actions)
|
|
376
|
+
else:
|
|
377
|
+
normalized[provider] = actions
|
|
405
378
|
|
|
406
379
|
if normalized:
|
|
407
380
|
validate_permissions(normalized)
|
|
@@ -483,8 +456,8 @@ class PathOperation(OpenAPIElement):
|
|
|
483
456
|
def _get_permissions(self, path_operation: dict) -> dict:
|
|
484
457
|
"""
|
|
485
458
|
Extract permissions from a path operation using x-af-permissions
|
|
486
|
-
only.
|
|
487
|
-
'write'.
|
|
459
|
+
only. Expects provider -> action -> role -> rule format.
|
|
460
|
+
Also normalizes action names so 'create'/'update' map to 'write'.
|
|
488
461
|
"""
|
|
489
462
|
raw_permissions = path_operation.get("x-af-permissions") or {}
|
|
490
463
|
|
|
@@ -495,38 +468,14 @@ class PathOperation(OpenAPIElement):
|
|
|
495
468
|
result[key] = value
|
|
496
469
|
return result
|
|
497
470
|
|
|
498
|
-
def is_legacy_role_form(obj: Dict[str, Any]) -> bool:
|
|
499
|
-
if not isinstance(obj, dict):
|
|
500
|
-
return False
|
|
501
|
-
for v in obj.values():
|
|
502
|
-
if isinstance(v, dict):
|
|
503
|
-
for k2, v2 in v.items():
|
|
504
|
-
if k2 in {
|
|
505
|
-
"read",
|
|
506
|
-
"write",
|
|
507
|
-
"delete",
|
|
508
|
-
"create",
|
|
509
|
-
"update",
|
|
510
|
-
} and not isinstance(v2, dict):
|
|
511
|
-
return True
|
|
512
|
-
return False
|
|
513
|
-
|
|
514
471
|
normalized: Dict[str, Any] = {}
|
|
515
472
|
if isinstance(raw_permissions, dict):
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
else:
|
|
523
|
-
for provider, actions in raw_permissions.items():
|
|
524
|
-
if isinstance(actions, dict):
|
|
525
|
-
normalized[provider] = normalize_actions(actions)
|
|
526
|
-
else:
|
|
527
|
-
normalized[provider] = actions
|
|
528
|
-
else:
|
|
529
|
-
normalized = {}
|
|
473
|
+
# Expected format: provider -> action -> role -> rule
|
|
474
|
+
for provider, actions in raw_permissions.items():
|
|
475
|
+
if isinstance(actions, dict):
|
|
476
|
+
normalized[provider] = normalize_actions(actions)
|
|
477
|
+
else:
|
|
478
|
+
normalized[provider] = actions
|
|
530
479
|
|
|
531
480
|
if normalized:
|
|
532
481
|
validate_permissions(normalized)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|