opentf-toolkit-nightly 0.62.0.dev1333__py3-none-any.whl → 0.62.0.dev1342__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.
- opentf/commons/__init__.py +33 -3
- opentf/commons/auth.py +9 -0
- opentf/commons/config.py +6 -0
- {opentf_toolkit_nightly-0.62.0.dev1333.dist-info → opentf_toolkit_nightly-0.62.0.dev1342.dist-info}/METADATA +1 -1
- {opentf_toolkit_nightly-0.62.0.dev1333.dist-info → opentf_toolkit_nightly-0.62.0.dev1342.dist-info}/RECORD +8 -8
- {opentf_toolkit_nightly-0.62.0.dev1333.dist-info → opentf_toolkit_nightly-0.62.0.dev1342.dist-info}/WHEEL +1 -1
- {opentf_toolkit_nightly-0.62.0.dev1333.dist-info → opentf_toolkit_nightly-0.62.0.dev1342.dist-info}/licenses/LICENSE +0 -0
- {opentf_toolkit_nightly-0.62.0.dev1333.dist-info → opentf_toolkit_nightly-0.62.0.dev1342.dist-info}/top_level.txt +0 -0
opentf/commons/__init__.py
CHANGED
|
@@ -337,6 +337,11 @@ def _make_authenticator(context: Dict[str, Any]):
|
|
|
337
337
|
):
|
|
338
338
|
g.insecure_login = True
|
|
339
339
|
return None
|
|
340
|
+
if (
|
|
341
|
+
context.get('enable_insecure_healthcheck_endpoint')
|
|
342
|
+
and request.path == '/health'
|
|
343
|
+
):
|
|
344
|
+
return None
|
|
340
345
|
authz = request.headers.get('Authorization')
|
|
341
346
|
if authz is None:
|
|
342
347
|
return make_status_response('Unauthorized', 'No Bearer token')
|
|
@@ -461,6 +466,7 @@ def make_app(
|
|
|
461
466
|
app.config['DESCRIPTOR'] = (
|
|
462
467
|
descriptor if isinstance(descriptor, list) else [descriptor]
|
|
463
468
|
)
|
|
469
|
+
app.route('/health', methods=['GET'])(lambda: 'OK')
|
|
464
470
|
app.before_request(_make_authenticator(context))
|
|
465
471
|
app.after_request(_add_securityheaders)
|
|
466
472
|
return app
|
|
@@ -842,7 +848,10 @@ def validate_inputs(
|
|
|
842
848
|
If `normalize` is set, non-normalized inputs are removed from the
|
|
843
849
|
dictionary.
|
|
844
850
|
|
|
845
|
-
Choices values are validated.
|
|
851
|
+
Choices values are validated.
|
|
852
|
+
|
|
853
|
+
Types are enforced if declared as `boolean`, `number`, or `string`.
|
|
854
|
+
Conversion is performed if needed.
|
|
846
855
|
|
|
847
856
|
# Required parameters
|
|
848
857
|
|
|
@@ -870,12 +879,33 @@ def validate_inputs(
|
|
|
870
879
|
raise ValueError(f'Mandatory input "{key}" not provided.')
|
|
871
880
|
_set_default(inputs, key, definition)
|
|
872
881
|
continue
|
|
873
|
-
|
|
874
|
-
|
|
882
|
+
val = inputs.get(key)
|
|
883
|
+
type_ = definition.get('type')
|
|
884
|
+
if type_ == 'choice':
|
|
885
|
+
if val not in definition['options']:
|
|
875
886
|
allowed = '", "'.join(sorted(definition['options']))
|
|
876
887
|
raise ValueError(
|
|
877
888
|
f'Invalid value "{val}" for input "{key}". Allowed values: "{allowed}".'
|
|
878
889
|
)
|
|
890
|
+
elif type_ == 'boolean' and not isinstance(val, bool):
|
|
891
|
+
if isinstance(val, str) and val.lower() in ('true', 'false'):
|
|
892
|
+
inputs[key] = val.lower() == 'true'
|
|
893
|
+
continue
|
|
894
|
+
raise ValueError(
|
|
895
|
+
f'Invalid value "{val}" for input "{key}". Allowed values: "true", "false".'
|
|
896
|
+
)
|
|
897
|
+
elif type_ == 'number':
|
|
898
|
+
try:
|
|
899
|
+
inputs[key] = int(val)
|
|
900
|
+
except ValueError:
|
|
901
|
+
try:
|
|
902
|
+
inputs[key] = float(val)
|
|
903
|
+
except ValueError:
|
|
904
|
+
raise ValueError(
|
|
905
|
+
f'Invalid value "{val}" for input "{key}". Expected a number.'
|
|
906
|
+
)
|
|
907
|
+
elif type_ == 'string':
|
|
908
|
+
inputs[key] = str(val)
|
|
879
909
|
|
|
880
910
|
if additional_inputs:
|
|
881
911
|
return
|
opentf/commons/auth.py
CHANGED
|
@@ -445,6 +445,7 @@ def initialize_authn_authz(args, context: Dict[str, Any]) -> None:
|
|
|
445
445
|
|
|
446
446
|
- `--trusted-authorities`
|
|
447
447
|
- `--enable-insecure-login`
|
|
448
|
+
- `--enable-insecure-healthcheck-endpoint`
|
|
448
449
|
- `--insecure-bind-address`
|
|
449
450
|
- `--authorization-mode` (ABAC, RBAC, JWT)
|
|
450
451
|
|
|
@@ -485,6 +486,14 @@ def initialize_authn_authz(args, context: Dict[str, Any]) -> None:
|
|
|
485
486
|
context['enable_insecure_login'] = True
|
|
486
487
|
if 'enable_insecure_login' not in context:
|
|
487
488
|
context['enable_insecure_login'] = False
|
|
489
|
+
if args.enable_insecure_healthcheck_endpoint:
|
|
490
|
+
context['enable_insecure_healthcheck_endpoint'] = True
|
|
491
|
+
else:
|
|
492
|
+
ihe = os.environ.get('OPENTF_ENABLE_INSECURE_HEALTHCHECK_ENDPOINT')
|
|
493
|
+
if ihe and ihe.lower() in ('true', 'on', 'yes', '1'):
|
|
494
|
+
context['enable_insecure_healthcheck_endpoint'] = True
|
|
495
|
+
if 'enable_insecure_healthcheck_endpoint' not in context:
|
|
496
|
+
context['enable_insecure_healthcheck_endpoint'] = False
|
|
488
497
|
if 'insecure_bind_address' not in context:
|
|
489
498
|
context['insecure_bind_address'] = args.insecure_bind_address
|
|
490
499
|
if args.trustedkeys_auth_file:
|
opentf/commons/config.py
CHANGED
|
@@ -109,6 +109,12 @@ def make_argparser(description: str, configfile: str) -> argparse.ArgumentParser
|
|
|
109
109
|
'--trustedkeys-auth-file',
|
|
110
110
|
help='authenticated trusted keys for ABAC and RBAC',
|
|
111
111
|
)
|
|
112
|
+
parser.add_argument(
|
|
113
|
+
'--enable-insecure-healthcheck-endpoint',
|
|
114
|
+
'--enable_insecure_healthcheck_endpoint',
|
|
115
|
+
action='store_true',
|
|
116
|
+
help='enable insecure healthcheck endpoint (disabled by default)',
|
|
117
|
+
)
|
|
112
118
|
return parser
|
|
113
119
|
|
|
114
120
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opentf-toolkit-nightly
|
|
3
|
-
Version: 0.62.0.
|
|
3
|
+
Version: 0.62.0.dev1342
|
|
4
4
|
Summary: OpenTestFactory Orchestrator Toolkit
|
|
5
5
|
Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
|
|
6
6
|
Author: Martin Lafaix
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
opentf/commons/__init__.py,sha256=
|
|
2
|
-
opentf/commons/auth.py,sha256=
|
|
3
|
-
opentf/commons/config.py,sha256=
|
|
1
|
+
opentf/commons/__init__.py,sha256=2Y6BWtwYPWdLPbf-96iQwmk-6fjRVtgbSCl4_j8NV6E,28326
|
|
2
|
+
opentf/commons/auth.py,sha256=yUmAoZPk9Aru2UVT5xSjH96u9DOKPk17AeL1_12mjBM,16399
|
|
3
|
+
opentf/commons/config.py,sha256=gcge4zou7wMgu3GTyM5vVZudTyEpuyi3JEY8cdCBf5A,10454
|
|
4
4
|
opentf/commons/exceptions.py,sha256=7dhUXO8iyAbqVwlUKxZhgRzGqVcb7LkG39hFlm-VxIA,2407
|
|
5
5
|
opentf/commons/expressions.py,sha256=jM_YKXVOFhvOE2aE2IuacuvxhIsOYTFs2oQkpcbWR6g,19645
|
|
6
6
|
opentf/commons/meta.py,sha256=ygSO3mE2d-Ux62abzK1wYk86noT4R5Tumd90nyZo0MU,3322
|
|
@@ -59,8 +59,8 @@ opentf/scripts/startup.py,sha256=AcVXU2auPvqMb_6OpGzkVqrpgYV6vz7x_Rnv8YbAEkk,231
|
|
|
59
59
|
opentf/toolkit/__init__.py,sha256=7MGAfKb5V9ckzWE8ozfj0PcC7g0a-0VfdyrClkWTk38,22319
|
|
60
60
|
opentf/toolkit/channels.py,sha256=6qKSsAgq_oJpuDRiKqVUz-EAjdfikcCG3SFAGmKZdhQ,25551
|
|
61
61
|
opentf/toolkit/core.py,sha256=fqnGgaYnuVcd4fyeNIwpc0QtyUo7jsKeVgdkBfY3iqo,9443
|
|
62
|
-
opentf_toolkit_nightly-0.62.0.
|
|
63
|
-
opentf_toolkit_nightly-0.62.0.
|
|
64
|
-
opentf_toolkit_nightly-0.62.0.
|
|
65
|
-
opentf_toolkit_nightly-0.62.0.
|
|
66
|
-
opentf_toolkit_nightly-0.62.0.
|
|
62
|
+
opentf_toolkit_nightly-0.62.0.dev1342.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
63
|
+
opentf_toolkit_nightly-0.62.0.dev1342.dist-info/METADATA,sha256=dzyod6IsHTN1wbSmbplog9qMCLxK8wJiNBNI6eug1eE,2214
|
|
64
|
+
opentf_toolkit_nightly-0.62.0.dev1342.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
65
|
+
opentf_toolkit_nightly-0.62.0.dev1342.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
|
|
66
|
+
opentf_toolkit_nightly-0.62.0.dev1342.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|