cloud-foundry 0.5.4__tar.gz → 0.5.5__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.
Files changed (44) hide show
  1. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/PKG-INFO +1 -1
  2. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/__init__.py +1 -1
  3. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/services/authorization_api/security_lambda.py +22 -4
  4. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/.gitignore +0 -0
  5. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/LICENSE +0 -0
  6. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/README.md +0 -0
  7. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/archive_builder.py +0 -0
  8. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/mail_publisher.py +0 -0
  9. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/migrations/__init__.py +0 -0
  10. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/migrations/forget_site_objects.py +0 -0
  11. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/__init__.py +0 -0
  12. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/api_waf.py +0 -0
  13. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/cdn.py +0 -0
  14. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/cdn_api_origin.py +0 -0
  15. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/cdn_site_origin.py +0 -0
  16. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/connection_store.py +0 -0
  17. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/custom_domain.py +0 -0
  18. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/document_repository.py +0 -0
  19. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/domain.py +0 -0
  20. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/function.py +0 -0
  21. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/idle_reaper.py +0 -0
  22. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/postgres_schema.py +0 -0
  23. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/publisher.py +0 -0
  24. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/python_function.py +0 -0
  25. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/queue.py +0 -0
  26. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/rest_api.py +0 -0
  27. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/schedule.py +0 -0
  28. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/site_bucket.py +0 -0
  29. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/topic.py +0 -0
  30. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/topic_subscription.py +0 -0
  31. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/ui_publisher.py +0 -0
  32. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/websocket_api.py +0 -0
  33. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/pulumi/websocket_function.py +0 -0
  34. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/python_archive_builder.py +0 -0
  35. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/services/mail_publisher.py +0 -0
  36. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/services/postgres_schema_bootstrap.py +0 -0
  37. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/aws_openapi_editor.py +0 -0
  38. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/hash_comparator.py +0 -0
  39. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/idle_reaper_client.py +0 -0
  40. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/logger.py +0 -0
  41. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/names.py +0 -0
  42. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/openapi_editor.py +0 -0
  43. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/cloud_foundry/utils/websocket_utils.py +0 -0
  44. {cloud_foundry-0.5.4 → cloud_foundry-0.5.5}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloud-foundry
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: cloud-foundry is a curated set of cloud components that can be used to assemble cloud-based applications.
5
5
  Project-URL: Documentation, https://github.com/DanRepik/cloud-foundry
6
6
  Project-URL: Source, https://github.com/DanRepik/cloud-foundry
@@ -35,4 +35,4 @@ from cloud_foundry.utils.idle_reaper_client import request_mapping_enable # noq
35
35
  from cloud_foundry.utils.names import resource_id # noqa: F401
36
36
  from cloud_foundry.utils.names import project_slug # noqa: F401
37
37
 
38
- version = "0.5.4"
38
+ version = "0.5.5"
@@ -59,15 +59,22 @@ class AuthorizationServices:
59
59
  self.user_pool_id = user_pool_id or os.getenv("USER_POOL_ID")
60
60
  self.client_id = client_id or os.getenv("CLIENT_ID")
61
61
  self.client_secret = client_secret or os.getenv("CLIENT_SECRET")
62
+ # Preferred over CLIENT_SECRET: a Lambda's environment is readable by
63
+ # anyone with lambda:GetFunctionConfiguration. Read on first use.
64
+ self.client_secret_arn = os.getenv("CLIENT_SECRET_ARN")
62
65
  self.user_admin_group = user_admin_group or os.getenv("USER_ADMIN_GROUP")
63
66
  self.user_default_group = user_default_group or os.getenv("USER_DEFAULT_GROUP")
64
67
  region = os.getenv("AWS_REGION")
65
68
  self.cognito_client = boto3.client("cognito-idp", region_name=region)
66
69
 
67
70
  def handler(self, event, context):
71
+ if not self.client_secret and self.client_secret_arn:
72
+ self.client_secret = boto3.client("secretsmanager").get_secret_value(
73
+ SecretId=self.client_secret_arn
74
+ )["SecretString"]
68
75
  assert (
69
76
  self.user_pool_id and self.client_id and self.client_secret
70
- ), "USER_POOL_ID, CLIENT_ID, and CLIENT_SECRET must be set"
77
+ ), "USER_POOL_ID, CLIENT_ID, and CLIENT_SECRET (or CLIENT_SECRET_ARN) must be set"
71
78
 
72
79
  path = event.get("resource", "")
73
80
  http_method = event.get("httpMethod", "").upper()
@@ -278,9 +285,18 @@ class AuthorizationServices:
278
285
  params = {"USERNAME": username, "PASSWORD": body["password"]}
279
286
  else:
280
287
  return bad_request("password or refresh_token is required")
281
- params["SECRET_HASH"] = self.calculate_secret_hash(username)
282
288
 
283
289
  try:
290
+ # A refresh's SECRET_HASH must use the user's Cognito username;
291
+ # in a pool that signs in by email that is the sub, not the email.
292
+ hash_name = (
293
+ cognito_client.admin_get_user(
294
+ UserPoolId=self.user_pool_id, Username=username
295
+ )["Username"]
296
+ if flow == "REFRESH_TOKEN_AUTH"
297
+ else username
298
+ )
299
+ params["SECRET_HASH"] = self.calculate_secret_hash(hash_name)
284
300
  response = cognito_client.initiate_auth(
285
301
  AuthFlow=flow, AuthParameters=params, ClientId=self.client_id
286
302
  )
@@ -409,8 +425,10 @@ class AuthorizationServices:
409
425
  Authorization header is missing, so callers' `if not access_token`
410
426
  checks behave correctly.
411
427
  """
412
- headers = event.get("headers", {})
413
- authorization_header = headers.get("Authorization")
428
+ # Header names arrive in whatever case the client (or CloudFront,
429
+ # or HTTP/2's lower case) sent.
430
+ headers = {k.lower(): v for k, v in (event.get("headers") or {}).items()}
431
+ authorization_header = headers.get("authorization")
414
432
 
415
433
  if not authorization_header:
416
434
  log.error("Authorization header is missing")
File without changes
File without changes
File without changes