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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: api-foundry
3
- Version: 0.1.30
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
- if is_legacy_role_form(raw_permissions):
390
- # Keep legacy shape, just normalize action names
391
- for role, actions in raw_permissions.items():
392
- if isinstance(actions, dict):
393
- normalized[role] = normalize_actions(actions)
394
- else:
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. Also normalizes action names so 'create'/'update' map to
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
- if is_legacy_role_form(raw_permissions):
517
- for role, actions in raw_permissions.items():
518
- if isinstance(actions, dict):
519
- normalized[role] = normalize_actions(actions)
520
- else:
521
- normalized[role] = actions
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)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "api-foundry"
7
- version = "0.1.30"
7
+ version = "0.8.1"
8
8
  authors = [
9
9
  { name="Daniel Repik", email="danrepik@icloud.com" },
10
10
  ]
File without changes
File without changes