jaaql-middleware-python 4.26.0__tar.gz → 4.26.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.
Files changed (76) hide show
  1. {jaaql-middleware-python-4.26.0/jaaql_middleware_python.egg-info → jaaql-middleware-python-4.26.1}/PKG-INFO +1 -1
  2. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/constants.py +2 -1
  3. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/documentation/documentation_internal.py +13 -9
  4. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/base_controller.py +9 -4
  5. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/controller.py +2 -2
  6. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/exception_queries.py +2 -2
  7. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/generated_queries.py +1 -1
  8. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/model.py +42 -25
  9. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/01.install_domains.generated.sql +1 -1
  10. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/02.install_super_user.exceptions.sql +4 -2
  11. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1/jaaql_middleware_python.egg-info}/PKG-INFO +1 -1
  12. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/LICENSE.txt +0 -0
  13. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/README.md +0 -0
  14. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/__init__.py +0 -0
  15. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/config/__init__.py +0 -0
  16. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/config/config-docker.ini +0 -0
  17. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/config/config-test.ini +0 -0
  18. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/config/config.ini +0 -0
  19. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/config_constants.py +0 -0
  20. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/db/__init__.py +0 -0
  21. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/db/db_interface.py +0 -0
  22. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/db/db_pg_interface.py +0 -0
  23. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/db/db_utils.py +0 -0
  24. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/db/db_utils_no_circ.py +0 -0
  25. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/documentation/__init__.py +0 -0
  26. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/documentation/documentation_public.py +0 -0
  27. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/documentation/documentation_shared.py +0 -0
  28. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/email/__init__.py +0 -0
  29. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/email/email_manager.py +0 -0
  30. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/email/email_manager_service.py +0 -0
  31. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/email/patch_ems.py +0 -0
  32. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/exceptions/__init__.py +0 -0
  33. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/exceptions/custom_http_status.py +0 -0
  34. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/exceptions/http_status_exception.py +0 -0
  35. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/exceptions/jaaql_interpretable_handled_errors.py +0 -0
  36. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/exceptions/not_yet_implement_exception.py +0 -0
  37. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/generated_constants.py +0 -0
  38. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/interpreter/__init__.py +0 -0
  39. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/interpreter/interpret_jaaql.py +0 -0
  40. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/jaaql.py +0 -0
  41. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/migrations/__init__.py +0 -0
  42. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/migrations/migrations.py +0 -0
  43. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/__init__.py +0 -0
  44. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/base_model.py +0 -0
  45. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/controller_interface.py +0 -0
  46. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/handmade_queries.py +0 -0
  47. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/model_interface.py +0 -0
  48. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/mvc/response.py +0 -0
  49. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/openapi/__init__.py +0 -0
  50. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/openapi/swagger_documentation.py +0 -0
  51. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/patch.py +0 -0
  52. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/03.install_super_user.handwritten.sql +0 -0
  53. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/04.install_jaaql_data_structures.generated.sql +0 -0
  54. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/05.install_static_data.generated.sql +0 -0
  55. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/06.install_jaaql.exceptions.sql +0 -0
  56. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/ZZZZ.generated_functions_views_and_permissions.sql +0 -0
  57. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/ZZZZ.reset_references.sql +0 -0
  58. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/scripts/swagger_template.html +0 -0
  59. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/services/__init__.py +0 -0
  60. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/services/cached_canned_query_service.py +0 -0
  61. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/services/migrations_manager_service.py +0 -0
  62. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/services/patch_mms.py +0 -0
  63. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/services/patch_shared_var_service.py +0 -0
  64. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/services/shared_var_service.py +0 -0
  65. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/utilities/__init__.py +0 -0
  66. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/utilities/crypt_utils.py +0 -0
  67. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/utilities/options.py +0 -0
  68. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/utilities/utils.py +0 -0
  69. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/utilities/utils_no_project_imports.py +0 -0
  70. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql/utilities/vault.py +0 -0
  71. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql_middleware_python.egg-info/SOURCES.txt +0 -0
  72. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql_middleware_python.egg-info/dependency_links.txt +0 -0
  73. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql_middleware_python.egg-info/requires.txt +0 -0
  74. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/jaaql_middleware_python.egg-info/top_level.txt +0 -0
  75. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/setup.cfg +0 -0
  76. {jaaql-middleware-python-4.26.0 → jaaql-middleware-python-4.26.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaaql-middleware-python
3
- Version: 4.26.0
3
+ Version: 4.26.1
4
4
  Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
5
5
  Home-page: https://github.com/JAAQL/JAAQL-middleware-python
6
6
  Author: Software Quality Measurement and Improvement bv
@@ -53,6 +53,7 @@ CRON_month = "month"
53
53
  CRON_dayOfWeek = "dayOfWeek"
54
54
 
55
55
  REGEX__dmbs_object_name = r'^[0-9a-zA-Z_]{1,63}$'
56
+ REGEX__dmbs_procedure_name = r'^[0-9a-zA-Z_$.]{1,63}$'
56
57
 
57
58
  SEPARATOR__comma_space = ", "
58
59
  SEPARATOR__comma = ","
@@ -181,5 +182,5 @@ ROLE__postgres = "postgres"
181
182
 
182
183
  PROTOCOL__postgres = "postgresql://"
183
184
 
184
- VERSION = "4.26.0"
185
+ VERSION = "4.26.1"
185
186
 
@@ -355,15 +355,19 @@ DOCUMENTATION__oidc_user_registries = SwaggerDocumentation(
355
355
  ],
356
356
  response=SwaggerResponse(
357
357
  description="Providers response",
358
- response=[
359
- ARG_RES__provider,
360
- SwaggerArgumentResponse(
361
- name=KG__identity_provider_service__logo_url,
362
- description="The logo url for the provider",
363
- arg_type=str,
364
- example=["/identity-logos/azure.png"]
358
+ response=SwaggerArgumentResponse(
359
+ name="providers",
360
+ description="A list of the providers",
361
+ arg_type=SwaggerList(
362
+ ARG_RES__provider,
363
+ SwaggerArgumentResponse(
364
+ name=KG__identity_provider_service__logo_url,
365
+ description="The logo url for the provider",
366
+ arg_type=str,
367
+ example=["/identity-logos/azure.png"]
368
+ )
365
369
  )
366
- ]
370
+ )
367
371
  )
368
372
  )
369
373
  )
@@ -400,7 +404,7 @@ DOCUMENTATION__oidc_exchange_code = SwaggerDocumentation(
400
404
  name="Fetch OIDC code",
401
405
  description="Exchanges OIDC auth code for auth token, returns the token",
402
406
  method=REST__POST,
403
- arguments=[
407
+ body=[
404
408
  SwaggerArgumentResponse(
405
409
  name=KEY__code,
406
410
  description="The OIDC Auth code",
@@ -364,18 +364,22 @@ class BaseJAAQLController:
364
364
  if method.arguments[0] == ARG_RESP__allow_all:
365
365
  was_allow_all = True
366
366
 
367
+ only_args = False
367
368
  if len(method.body) != 0 or was_allow_all:
368
369
  BaseJAAQLController.enforce_content_type_json()
369
370
  data = request.json
370
371
  else:
371
372
  content_type = request.headers.get('Content-Type', '')
372
373
  if 'charset=' not in content_type and len(kwargs) == 0:
373
- return {}
374
+ only_args = True
374
375
 
375
376
  if isinstance(data, list):
376
377
  combined_data = data
377
378
  else:
378
- combined_data = {**request.form, **request.args, **data, **kwargs}
379
+ if only_args:
380
+ combined_data = {**request.args}
381
+ else:
382
+ combined_data = {**request.form, **request.args, **data, **kwargs}
379
383
 
380
384
  if len(combined_data) != len(request.form) + len(request.args) + len(data) + len(kwargs):
381
385
  raise HttpStatusException(ERR__duplicated_field, HTTPStatus.BAD_REQUEST)
@@ -663,8 +667,9 @@ class BaseJAAQLController:
663
667
  if jaaql_resp.raw_response is not None:
664
668
  resp = jaaql_resp.raw_response
665
669
  resp = Response(resp, mimetype=jaaql_resp.response_type, status=jaaql_resp.response_code)
666
- for key, val in jaaql_resp.raw_headers.items():
667
- resp.headers.add(key, val)
670
+
671
+ for key, val in jaaql_resp.raw_headers.items():
672
+ resp.headers.add(key, val)
668
673
 
669
674
  if request.cookies.get(COOKIE_JAAQL_AUTH) is not None and COOKIE_JAAQL_AUTH not in jaaql_resp.cookies:
670
675
  resp.headers.add("Set-Cookie", format_cookie(COOKIE_JAAQL_AUTH, request.cookies.get(COOKIE_JAAQL_AUTH),
@@ -20,11 +20,11 @@ class JAAQLController(BaseJAAQLController):
20
20
 
21
21
  @self.publish_route('/oauth/token', DOCUMENTATION__oauth_token)
22
22
  def fetch_oauth_token(http_inputs: dict, ip_address: str, response: JAAQLResponse):
23
- return self.model.get_auth_token(**http_inputs, ip_address=ip_address, response=response)
23
+ return self.model.get_auth_token(**http_inputs, ip_address=ip_address, response=response, is_refresh=False)
24
24
 
25
25
  @self.publish_route('/oauth/cookie', DOCUMENTATION__oauth_cookie)
26
26
  def fetch_oauth_cookie(http_inputs: dict, ip_address: str, response: JAAQLResponse):
27
- self.model.get_auth_token(**http_inputs, ip_address=ip_address, response=response, cookie=True)
27
+ self.model.get_auth_token(**http_inputs, ip_address=ip_address, response=response, cookie=True, is_refresh=False)
28
28
 
29
29
  @self.publish_route('/logout-cookie', DOCUMENTATION__logout_cookie)
30
30
  def fetch_oauth_cookie(response: JAAQLResponse):
@@ -1,5 +1,5 @@
1
1
  """
2
- This script was generated from jaaql.exceptions.fxli at 2025-02-06, 06:08:49
2
+ This script was generated from jaaql.exceptions.fxli at 2025-02-06, 11:10:33
3
3
  """
4
4
 
5
5
  from jaaql.utilities.crypt_utils import get_repeatable_salt
@@ -72,7 +72,7 @@ QUERY__fetch_providers_from_tenant_and_database = """
72
72
  UR.discovery_url,
73
73
  DUR.federation_procedure,
74
74
  DUR.client_id,
75
- DUR.client_secret,
75
+ DUR.client_secret
76
76
  FROM identity_provider_service IPS
77
77
  INNER JOIN user_registry UR ON
78
78
  IPS.name = UR.provider
@@ -1,5 +1,5 @@
1
1
  """
2
- This script was generated from build_and_run.fxls at 2025-02-06, 06:08:49
2
+ This script was generated from build_and_run.fxls at 2025-02-06, 11:10:33
3
3
  """
4
4
 
5
5
  from jaaql.db.db_interface import DBInterface
@@ -460,19 +460,21 @@ WHERE
460
460
  def fetch_user_registries_for_tenant(self, inputs: dict):
461
461
  schema = inputs.get(KEY__schema, None)
462
462
  if not schema:
463
- schema = application__select(self.jaaql_lookup_connection, inputs[KEY__application])[KG__application_schema__name]
463
+ schema = application__select(self.jaaql_lookup_connection, inputs[KEY__application])[KG__application__default_schema]
464
464
 
465
465
  database = application_schema__select(self.jaaql_lookup_connection, inputs[KEY__application], schema)
466
466
  providers = fetch_providers_from_tenant_and_database(self.jaaql_lookup_connection, inputs[KG__user_registry__tenant],
467
467
  database[KG__application_schema__database])
468
468
 
469
- return [
470
- {
471
- KG__user_registry__provider: provider[KG__identity_provider_service__name],
472
- KG__identity_provider_service__logo_url: provider[KG__identity_provider_service__logo_url]
473
- }
474
- for provider in providers
475
- ]
469
+ return {
470
+ "providers": [
471
+ {
472
+ KG__user_registry__provider: provider[KG__identity_provider_service__name],
473
+ KG__identity_provider_service__logo_url: provider[KG__identity_provider_service__logo_url]
474
+ }
475
+ for provider in providers
476
+ ]
477
+ }
476
478
 
477
479
  def fetch_discovery_content(self, database: str, provider: str, tenant: str, discovery_url: str = None):
478
480
  lookup = database + ":" + provider + ":" + tenant
@@ -486,7 +488,7 @@ WHERE
486
488
  return discovery
487
489
 
488
490
  def fetch_jwks_client(self, database: str, provider: str, tenant: str, discovery):
489
- jwks_url = discovery.get("jwks_uri")
491
+ jwks_url = discovery.get("jwks_uri").replace("localhost", "host.docker.internal")
490
492
  if not jwks_url:
491
493
  raise Exception(f"Discovery document for {provider}, {tenant} did not have JWKS url")
492
494
  lookup = database + ":" + provider + ":" + tenant
@@ -547,9 +549,14 @@ WHERE
547
549
  token_request_payload["client_secret"] = database_user_registry[KG__database_user_registry__client_secret]
548
550
 
549
551
  token_response = requests.post(
550
- token_endpoint,
552
+ token_endpoint.replace("localhost", "host.docker.internal"),
551
553
  data=token_request_payload,
552
554
  )
555
+
556
+ if os.environ.get("JAAQL_DEBUGGING") == "TRUE":
557
+ print(token_response.status_code)
558
+ print(token_response.text)
559
+
553
560
  token_data = token_response.json()
554
561
  id_token = token_data.get('id_token')
555
562
 
@@ -581,27 +588,28 @@ WHERE
581
588
 
582
589
  except HttpSingletonStatusException:
583
590
  # User does not exist, federate it
591
+ print("federating user")
584
592
  email = id_payload.get('email')
585
593
  email_verified = id_payload.get('email_verified')
586
-
587
594
  account_id = self.create_account_with_potential_api_key(self.jaaql_lookup_connection,
588
595
  sub, provider, tenant,
589
- email, registered=email_verified)
596
+ None, email, registered=email_verified)
597
+ print("new federated user with account id " + account_id)
590
598
  account = account__select(self.jaaql_lookup_connection, self.get_db_crypt_key(), account_id)
591
599
  db_params = {"tenant": tenant, "application": application, "account_id": account_id}
592
600
  parameters = fetch_parameters_for_federation_procedure(self.jaaql_lookup_connection,
593
601
  database_user_registry[KG__database_user_registry__federation_procedure])
594
602
  for claim in parameters:
595
603
  claim_name = claim[KG__federation_procedure_parameter__name]
596
- db_params[claim_name] = id_token.get(claim_name)
604
+ db_params[claim_name] = id_payload.get(claim_name)
597
605
 
598
606
  procedure_name = database_user_registry[KG__database_user_registry__federation_procedure]
599
- if re.match(REGEX__dmbs_object_name, procedure_name) is None:
607
+ if re.match(REGEX__dmbs_procedure_name, procedure_name) is None:
600
608
  raise HttpStatusException("Unsafe data federation procedure")
601
609
 
602
610
  procedure_params = []
603
611
  for key, _ in db_params.items():
604
- if re.match(REGEX__dmbs_object_name, procedure_name) is None:
612
+ if re.match(REGEX__dmbs_object_name, key) is None:
605
613
  raise HttpStatusException("Unsafe data federation parameter " + key)
606
614
  procedure_params.append(f"{key} => :{key}")
607
615
 
@@ -612,10 +620,15 @@ WHERE
612
620
  KEY__parameters: db_params
613
621
  }
614
622
 
623
+ print("Preparing federating procedure")
624
+
615
625
  submit(self.vault, self.config, self.get_db_crypt_key(),
616
626
  self.jaaql_lookup_connection, submit_data, ROLE__jaaql,
617
627
  None, self.cached_canned_query_service, as_objects=True, singleton=True)
618
628
 
629
+ print("Federated user")
630
+ print(submit_data)
631
+
619
632
  salt_user = self.get_repeatable_salt(account[KG__account__id])
620
633
  encrypted_salted_ip_address = jaaql__encrypt(ip_address, self.get_db_crypt_key(), salt_user) # An optimisation, it is used later twice
621
634
  address = execute_supplied_statement_singleton(self.jaaql_lookup_connection,
@@ -627,7 +640,7 @@ WHERE
627
640
  jwt_data = {
628
641
  KEY__account_id: str(account[KG__account__id]),
629
642
  KEY__username: sub,
630
- KEY__password: str(account[KG__account__api_key]),
643
+ KEY__password: None,
631
644
  KEY__ip_address: ip_address,
632
645
  KEY__ip_id: str(address),
633
646
  KEY__created: datetime.now().isoformat(),
@@ -649,7 +662,7 @@ WHERE
649
662
  schema = inputs.get(KEY__schema, None)
650
663
  application = application__select(self.jaaql_lookup_connection, inputs[KEY__application])
651
664
  if not schema:
652
- schema = application[KG__application_schema__name]
665
+ schema = application[KG__application__default_schema]
653
666
 
654
667
  database = application_schema__select(self.jaaql_lookup_connection, inputs[KEY__application], schema)
655
668
  user_registry = user_registry__select(self.jaaql_lookup_connection, inputs[KG__user_registry__provider], inputs[KG__user_registry__tenant])
@@ -665,14 +678,14 @@ WHERE
665
678
 
666
679
  parameters = fetch_parameters_for_federation_procedure(self.jaaql_lookup_connection,
667
680
  database_user_registry[KG__database_user_registry__federation_procedure])
668
- scope_list = urllib.parse.quote(" ".join([parameter[KG__federation_procedure_parameter__name] for parameter in parameters]))
681
+ scope_list = [parameter[KG__federation_procedure_parameter__name] for parameter in parameters]
669
682
  client_id = urllib.parse.quote(database_user_registry[KG__database_user_registry__client_id])
670
683
 
671
684
  nonce = secrets.token_urlsafe(32)
672
685
  state = secrets.token_urlsafe(32)
673
686
  code_verifier = secrets.token_urlsafe(64)
674
687
  code_challenge = self.generate_code_challenge(code_verifier)
675
- redirect_uri = application[KG__application__base_url + "/" + inputs[KEY__redirect_uri]]
688
+ redirect_uri = application[KG__application__base_url] + "/" + inputs[KEY__redirect_uri]
676
689
 
677
690
  oidc_session = crypt_utils.jwt_encode(self.vault.get_obj(VAULT_KEY__jwt_crypt_key), {
678
691
  "redirect_uri": redirect_uri,
@@ -695,8 +708,9 @@ WHERE
695
708
  if scope not in default_scopes:
696
709
  default_scopes.append(scope)
697
710
 
698
- redirect = auth_endpoint + f"?client_id={client_id}&response_type=code&code_challenge_method=S256&nonce=&scope={default_scopes}&nonce={nonce}&state={
699
- state}&code_challenge={code_challenge}&redirect_uri={urllib.parse.quote(redirect_uri)}"
711
+ redirect = auth_endpoint + f"?client_id={client_id}&response_type=code&code_challenge_method=S256&scope={
712
+ urllib.parse.quote(" ".join(["openid"]))}&nonce={nonce}&state={
713
+ state}&code_challenge={code_challenge}&redirect_uri={urllib.parse.quote(redirect_uri, safe='')}"
700
714
 
701
715
  response.response_code = HTTPStatus.FOUND
702
716
  response.raw_headers["Location"] = redirect
@@ -914,7 +928,7 @@ WHERE
914
928
  try:
915
929
  account = fetch_account_from_id(self.jaaql_lookup_connection, decoded[KEY__account_id], singleton_code=HTTPStatus.UNAUTHORIZED,
916
930
  singleton_message=ERR__invalid_token)
917
- if account[KG__account__api_key] != decoded[KEY__password]:
931
+ if decoded[KEY__password] is not None and account[KG__account__api_key] != decoded[KEY__password]:
918
932
  raise HttpSingletonStatusException(ERR__invalid_token, HTTPStatus.UNAUTHORIZED)
919
933
  except HttpSingletonStatusException:
920
934
  raise UserUnauthorized()
@@ -933,7 +947,7 @@ WHERE
933
947
  if datetime.fromisoformat(decoded[KEY__created]) + timedelta(milliseconds=self.refresh_expiry_ms) < datetime.now():
934
948
  raise UserUnauthorized()
935
949
 
936
- return self.get_auth_token(decoded[KEY__username], ip_address, cookie=cookie, remember_me=remember_me, response=response)
950
+ return self.get_auth_token(decoded[KEY__username], ip_address, cookie=cookie, remember_me=remember_me, response=response, is_refresh=True)
937
951
 
938
952
  def get_bypass_user(self, username: str, ip_address: str, provider: str = None, tenant: str = None):
939
953
  account = fetch_account_from_username(self.jaaql_lookup_connection, username, singleton_code=HTTPStatus.UNAUTHORIZED)
@@ -954,6 +968,7 @@ WHERE
954
968
  self,
955
969
  username: str, ip_address: str, password: str = None,
956
970
  response: JAAQLResponse = None, remember_me: bool = False, cookie: bool = False,
971
+ is_refresh=False,
957
972
  ):
958
973
  incorrect_credentials = False
959
974
  account = None
@@ -975,10 +990,12 @@ WHERE
975
990
 
976
991
  encrypted_salted_ip_address = jaaql__encrypt(ip_address, self.get_db_crypt_key(), salt_user) # An optimisation, it is used later twice
977
992
 
978
- if password is not None:
993
+ if is_refresh:
994
+ incorrect_credentials = not exists_matching_validated_ip_address(self.jaaql_lookup_connection, encrypted_salted_ip_address)
995
+ elif password is not None:
979
996
  incorrect_credentials = jaaql__decrypt(account[KG__account__api_key], self.get_db_crypt_key()) != password
980
997
  else:
981
- incorrect_credentials = not exists_matching_validated_ip_address(self.jaaql_lookup_connection, encrypted_salted_ip_address)
998
+ incorrect_credentials = True
982
999
 
983
1000
  if incorrect_credentials:
984
1001
  raise UserUnauthorized()
@@ -4,7 +4,7 @@ CREATE DOMAIN encrypted__email_server_password AS character varying(256);
4
4
  CREATE DOMAIN encrypted__access_token AS character varying(64);
5
5
  CREATE DOMAIN encrypted__oidc_client_id AS character varying(200);
6
6
  CREATE DOMAIN encrypted__oidc_client_secret AS character varying(200);
7
- CREATE DOMAIN encrypted__oidc_sub AS character varying(63);
7
+ CREATE DOMAIN encrypted__oidc_sub AS character varying(200);
8
8
  CREATE DOMAIN encrypted__email AS character varying(255);
9
9
  CREATE DOMAIN encrypted__salted_ip AS character varying(256);
10
10
  CREATE DOMAIN encrypted__jaaql_username AS character varying(128);
@@ -9,8 +9,8 @@ DECLARE
9
9
  account_id postgres_role;
10
10
  BEGIN
11
11
  if create_account.provider is not null then
12
- SELECT requires_email_verification INTO requires_email_verification
13
- FROM identity_provider_service
12
+ SELECT X.requires_email_verification INTO requires_email_verification
13
+ FROM identity_provider_service X
14
14
  WHERE name = create_account.provider;
15
15
  end if;
16
16
 
@@ -76,5 +76,7 @@ BEGIN
76
76
  IF lacks_registered THEN
77
77
  EXECUTE 'GRANT registered TO ' || quote_ident(mark_account_registered.id);
78
78
  END IF;
79
+
80
+ UPDATE account A SET email_verified = true WHERE A.id = mark_account_registered.id;
79
81
  END
80
82
  $$ language plpgsql SECURITY DEFINER;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaaql-middleware-python
3
- Version: 4.26.0
3
+ Version: 4.26.1
4
4
  Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
5
5
  Home-page: https://github.com/JAAQL/JAAQL-middleware-python
6
6
  Author: Software Quality Measurement and Improvement bv