cornflow 1.3.9__tar.gz → 1.4.0__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.
- {cornflow-1.3.9/cornflow.egg-info → cornflow-1.4.0}/PKG-INFO +6 -3
- cornflow-1.4.0/airflow_config/airflow_local_settings.py +12 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/airflow_config/webserver_ldap.py +3 -0
- cornflow-1.4.0/cornflow/app.py +498 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/__init__.py +4 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/service.py +90 -21
- cornflow-1.4.0/cornflow/cli/sessions.py +29 -0
- cornflow-1.4.0/cornflow/cli/tokens.py +31 -0
- cornflow-1.4.0/cornflow/cli/users.py +256 -0
- cornflow-1.4.0/cornflow/cli/utils.py +52 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/access.py +5 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/auxiliar.py +58 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/permissions.py +126 -7
- cornflow-1.4.0/cornflow/commands/token_expiry.py +203 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/users.py +44 -3
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/views.py +26 -2
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/config.py +62 -15
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/__init__.py +47 -12
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/action.py +4 -2
- cornflow-1.4.0/cornflow/endpoints/api_key.py +150 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/apiview.py +4 -2
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/dag.py +9 -3
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/login.py +211 -32
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/meta_resource.py +34 -4
- cornflow-1.4.0/cornflow/endpoints/mfa.py +276 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/permission.py +39 -4
- cornflow-1.4.0/cornflow/endpoints/refresh.py +87 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/roles.py +73 -6
- cornflow-1.4.0/cornflow/endpoints/signup.py +191 -0
- cornflow-1.4.0/cornflow/endpoints/user.py +584 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/user_role.py +95 -3
- cornflow-1.4.0/cornflow/migrations/versions/b7a1c9d807e5_.py +142 -0
- cornflow-1.4.0/cornflow/migrations/versions/c3f2a1b4e5d6_.py +61 -0
- cornflow-1.4.0/cornflow/migrations/versions/d4e8b2c6f109_.py +43 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/__init__.py +3 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/base_data_model.py +78 -10
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/execution.py +4 -9
- cornflow-1.4.0/cornflow/models/mfa_backup_code.py +82 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/role.py +17 -0
- cornflow-1.4.0/cornflow/models/session.py +213 -0
- cornflow-1.4.0/cornflow/models/user.py +721 -0
- cornflow-1.4.0/cornflow/models/user_password_history.py +74 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/user_role.py +67 -4
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/role.py +1 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/user.py +54 -1
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/user_role.py +3 -0
- cornflow-1.4.0/cornflow/shared/admin_access.py +65 -0
- cornflow-1.4.0/cornflow/shared/audit.py +102 -0
- cornflow-1.4.0/cornflow/shared/authentication/auth.py +1227 -0
- cornflow-1.4.0/cornflow/shared/const.py +521 -0
- cornflow-1.4.0/cornflow/shared/email.py +213 -0
- cornflow-1.4.0/cornflow/shared/encryption.py +67 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/exceptions.py +41 -2
- cornflow-1.4.0/cornflow/shared/log_config.py +52 -0
- cornflow-1.4.0/cornflow/shared/plugins.py +289 -0
- cornflow-1.4.0/cornflow/shared/rate_limit.py +106 -0
- cornflow-1.4.0/cornflow/shared/secret_keys.py +285 -0
- cornflow-1.4.0/cornflow/shared/security.py +218 -0
- cornflow-1.4.0/cornflow/shared/security_levels.py +473 -0
- cornflow-1.4.0/cornflow/shared/utils.py +58 -0
- cornflow-1.4.0/cornflow/shared/validators.py +352 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/const.py +1 -1
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/custom_liveServer.py +8 -3
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/custom_test_case.py +18 -4
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/integration/test_cornflowclient.py +37 -20
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/integration/test_data_checks_kpis.py +6 -4
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/ldap/test_ldap_authentication.py +1 -1
- cornflow-1.4.0/cornflow/tests/security_levels_support.py +135 -0
- cornflow-1.4.0/cornflow/tests/swagger_csp_support.py +151 -0
- cornflow-1.4.0/cornflow/tests/uat_hardening_support.py +391 -0
- cornflow-1.4.0/cornflow/tests/unit/test_admin_levels.py +1351 -0
- cornflow-1.4.0/cornflow/tests/unit/test_api_key_lifecycle.py +411 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_apiview.py +4 -2
- cornflow-1.4.0/cornflow/tests/unit/test_application.py +109 -0
- cornflow-1.4.0/cornflow/tests/unit/test_atomic_claims.py +134 -0
- cornflow-1.4.0/cornflow/tests/unit/test_bi_token_levels.py +302 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_cli.py +38 -89
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_commands.py +1 -1
- cornflow-1.4.0/cornflow/tests/unit/test_conditional_endpoints.py +198 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_dags.py +76 -3
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_external_role_creation.py +63 -5
- cornflow-1.4.0/cornflow/tests/unit/test_invalid_token_response.py +685 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_licenses.py +1 -1
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_log_in.py +111 -19
- cornflow-1.4.0/cornflow/tests/unit/test_login_lockout_levels.py +490 -0
- cornflow-1.4.0/cornflow/tests/unit/test_mfa_levels.py +749 -0
- cornflow-1.4.0/cornflow/tests/unit/test_password_change_levels.py +856 -0
- cornflow-1.4.0/cornflow/tests/unit/test_password_levels.py +841 -0
- cornflow-1.4.0/cornflow/tests/unit/test_platform_isolation.py +467 -0
- cornflow-1.4.0/cornflow/tests/unit/test_plugins.py +617 -0
- cornflow-1.4.0/cornflow/tests/unit/test_rate_limit_failures.py +598 -0
- cornflow-1.4.0/cornflow/tests/unit/test_refresh_token.py +508 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_roles.py +36 -14
- cornflow-1.4.0/cornflow/tests/unit/test_secret_keys.py +1587 -0
- cornflow-1.4.0/cornflow/tests/unit/test_security_hardening.py +2108 -0
- cornflow-1.4.0/cornflow/tests/unit/test_security_levels.py +1405 -0
- cornflow-1.4.0/cornflow/tests/unit/test_security_routes.py +482 -0
- cornflow-1.4.0/cornflow/tests/unit/test_security_startup.py +604 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_sign_up.py +127 -9
- cornflow-1.4.0/cornflow/tests/unit/test_swagger_csp.py +425 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_tables.py +4 -4
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_token.py +20 -4
- cornflow-1.4.0/cornflow/tests/unit/test_uat_battery_levels.py +469 -0
- cornflow-1.4.0/cornflow/tests/unit/test_uat_hardening_auth.py +941 -0
- cornflow-1.4.0/cornflow/tests/unit/test_uat_hardening_keys_audit.py +1260 -0
- cornflow-1.4.0/cornflow/tests/unit/test_uat_hardening_sessions.py +772 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_users.py +92 -19
- {cornflow-1.3.9 → cornflow-1.4.0/cornflow.egg-info}/PKG-INFO +6 -3
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow.egg-info/SOURCES.txt +47 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow.egg-info/requires.txt +5 -2
- {cornflow-1.3.9 → cornflow-1.4.0}/requirements.txt +5 -2
- {cornflow-1.3.9 → cornflow-1.4.0}/setup.py +1 -1
- cornflow-1.3.9/airflow_config/airflow_local_settings.py +0 -23
- cornflow-1.3.9/cornflow/app.py +0 -235
- cornflow-1.3.9/cornflow/cli/users.py +0 -85
- cornflow-1.3.9/cornflow/cli/utils.py +0 -41
- cornflow-1.3.9/cornflow/endpoints/signup.py +0 -107
- cornflow-1.3.9/cornflow/endpoints/user.py +0 -304
- cornflow-1.3.9/cornflow/models/user.py +0 -262
- cornflow-1.3.9/cornflow/shared/authentication/auth.py +0 -503
- cornflow-1.3.9/cornflow/shared/const.py +0 -206
- cornflow-1.3.9/cornflow/shared/email.py +0 -98
- cornflow-1.3.9/cornflow/shared/log_config.py +0 -28
- cornflow-1.3.9/cornflow/shared/utils.py +0 -31
- cornflow-1.3.9/cornflow/shared/validators.py +0 -147
- cornflow-1.3.9/cornflow/tests/unit/test_application.py +0 -60
- {cornflow-1.3.9 → cornflow-1.4.0}/MANIFEST.in +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/README.rst +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/airflow_config/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/airflow_config/plugins/XCom/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/airflow_config/plugins/XCom/gce_xcom_backend.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/airflow_config/plugins/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/actions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/arguments.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/config.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/migrations.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/permissions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/roles.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/schemas.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/api_generator.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/endpoint_tools.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/models_tools.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/schema_generator.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/schemas_tools.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/tools/tools.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/cli/views.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/actions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/cleanup.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/dag.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/roles.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/commands/schemas.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/case.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/data_check.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/example_data.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/execution.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/health.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/instance.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/licenses.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/main_alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/schemas.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/tables.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/endpoints/token.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/gunicorn.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/README +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/alembic.ini +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/env.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/script.py.mako +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/00757b557b02_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/1af47a419bbd_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/4729cd156460_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/4aac5e0c6e66_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/509d280698e4_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/7c3ea5ab5501_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/991b98e24225_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/999b98e24225.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/9cacf194fa1c_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/a472b5ad50b7_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/c2db9409cb5f_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/c8a6c762e818_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/ca449af8034c_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/cef1df240b27_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/d0e0700dcd8e_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/d1b5be1f0549_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/e1a50dae1ac9_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/e937a5234ce4_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/ebdd955fcc5e_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/migrations/versions/f3bee20314a2_.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/action.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/case.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/dag.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/dag_permissions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/instance.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/main_alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/meta_models.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/permissions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/models/view.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/action.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/case.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/common.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/dag.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/example_data.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/execution.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/health.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/instance.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/main_alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/model_json.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/patch.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/permissions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/query.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/schemas.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/solution_log.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/tables.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/schemas/view.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/authentication/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/authentication/decorators.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/authentication/ldap.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/compress.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/licenses.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/query_tools.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/shared/utils_tables.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/base_test_execution.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/integration/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/integration/test_commands.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/ldap/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/__init__.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_actions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_cases.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_data_checks.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_example_data.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_executions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_generate_from_schema.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_get_resources.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_health.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_instances.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_instances_file.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_main_alarms.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_meta_resource.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_permissions.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_schema_from_models.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/test_schemas.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow/tests/unit/tools.py +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow.egg-info/dependency_links.txt +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow.egg-info/entry_points.txt +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/cornflow.egg-info/top_level.txt +0 -0
- {cornflow-1.3.9 → cornflow-1.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cornflow
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: cornflow is an open source multi-solver optimization server with a REST API built using flask.
|
|
5
5
|
Home-page: https://github.com/baobabsoluciones/cornflow
|
|
6
6
|
Author: baobab soluciones
|
|
@@ -14,7 +14,7 @@ Requires-Dist: alembic==1.9.2
|
|
|
14
14
|
Requires-Dist: apispec==6.3.0
|
|
15
15
|
Requires-Dist: cachetools==5.3.3
|
|
16
16
|
Requires-Dist: click==8.1.7
|
|
17
|
-
Requires-Dist: cornflow-client==1.
|
|
17
|
+
Requires-Dist: cornflow-client==1.4.0
|
|
18
18
|
Requires-Dist: cryptography==50.0.2
|
|
19
19
|
Requires-Dist: disposable-email-domains==0.0.162
|
|
20
20
|
Requires-Dist: Flask==2.3.2
|
|
@@ -23,6 +23,7 @@ Requires-Dist: Flask-Bcrypt==1.0.1
|
|
|
23
23
|
Requires-Dist: Flask-Compress==1.14
|
|
24
24
|
Requires-Dist: flask-cors==6.0.0
|
|
25
25
|
Requires-Dist: flask-inflate==0.3
|
|
26
|
+
Requires-Dist: Flask-Limiter[redis]==3.8.0
|
|
26
27
|
Requires-Dist: Flask-Migrate==4.0.5
|
|
27
28
|
Requires-Dist: Flask-RESTful==0.3.10
|
|
28
29
|
Requires-Dist: Flask-SQLAlchemy==2.5.1
|
|
@@ -36,12 +37,14 @@ Requires-Dist: marshmallow==3.26.2
|
|
|
36
37
|
Requires-Dist: PuLP==2.9.0
|
|
37
38
|
Requires-Dist: psycopg2==2.9.9
|
|
38
39
|
Requires-Dist: PyJWT==2.15.1
|
|
40
|
+
Requires-Dist: pyotp==2.9.0
|
|
39
41
|
Requires-Dist: pytups==0.86.2
|
|
40
42
|
Requires-Dist: requests==2.33.0
|
|
43
|
+
Requires-Dist: setuptools==83.0.0
|
|
41
44
|
Requires-Dist: SQLAlchemy==1.3.21
|
|
42
45
|
Requires-Dist: webargs==8.3.0
|
|
43
46
|
Requires-Dist: Werkzeug==3.0.6
|
|
44
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: zxcvbn==4.5.0
|
|
45
48
|
Dynamic: author
|
|
46
49
|
Dynamic: author-email
|
|
47
50
|
Dynamic: classifier
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# AIRFLOW custom settings for CornflowEnv
|
|
2
|
+
# Airflow 3 moved UIAlert to airflow.api_fastapi and dropped STATE_COLORS (the new UI
|
|
3
|
+
# manages its own theme), so only the dashboard alert is kept.
|
|
4
|
+
|
|
5
|
+
from airflow.api_fastapi.common.types import UIAlert
|
|
6
|
+
|
|
7
|
+
DASHBOARD_UIALERTS = [
|
|
8
|
+
UIAlert(
|
|
9
|
+
text="Welcome! This is the backend of your cornflow environment. Airflow is a platform created by the community to programmatically author, schedule and monitor workflows.",
|
|
10
|
+
category="info",
|
|
11
|
+
),
|
|
12
|
+
]
|
|
@@ -20,6 +20,9 @@ import os
|
|
|
20
20
|
|
|
21
21
|
from airflow import configuration as conf
|
|
22
22
|
|
|
23
|
+
# the FAB provider calls ldap.filter without importing it, so it has to be loaded here
|
|
24
|
+
import ldap.filter # noqa: F401
|
|
25
|
+
|
|
23
26
|
from flask_appbuilder.security.manager import AUTH_LDAP
|
|
24
27
|
|
|
25
28
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Main file with the creation of the app logic
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# Full imports
|
|
6
|
+
import os
|
|
7
|
+
from logging.config import dictConfig
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
|
|
11
|
+
# Partial imports
|
|
12
|
+
from flask import Flask, Blueprint
|
|
13
|
+
from flask.cli import with_appcontext
|
|
14
|
+
from flask_apispec.extension import FlaskApiSpec
|
|
15
|
+
from flask_cors import CORS
|
|
16
|
+
from flask_migrate import Migrate
|
|
17
|
+
from flask_restful import Api
|
|
18
|
+
from werkzeug.exceptions import NotFound
|
|
19
|
+
from werkzeug.middleware.dispatcher import DispatcherMiddleware
|
|
20
|
+
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
21
|
+
|
|
22
|
+
# Module imports
|
|
23
|
+
from cornflow.commands import (
|
|
24
|
+
create_service_user_command,
|
|
25
|
+
create_admin_user_command,
|
|
26
|
+
create_planner_user_command,
|
|
27
|
+
register_roles_command,
|
|
28
|
+
register_actions_command,
|
|
29
|
+
register_views_command,
|
|
30
|
+
register_base_permissions_command,
|
|
31
|
+
access_init_command,
|
|
32
|
+
register_deployed_dags_command,
|
|
33
|
+
register_dag_permissions_command,
|
|
34
|
+
)
|
|
35
|
+
from cornflow.config import app_config
|
|
36
|
+
from cornflow.endpoints import resources, alarms_resources
|
|
37
|
+
from cornflow.endpoints.login import LoginEndpoint, LoginOpenAuthEndpoint
|
|
38
|
+
from cornflow.endpoints.refresh import LogoutEndpoint, RefreshTokenEndpoint
|
|
39
|
+
from cornflow.endpoints.signup import SignUpEndpoint
|
|
40
|
+
from cornflow.shared import db, bcrypt
|
|
41
|
+
from cornflow.shared.compress import init_compress
|
|
42
|
+
from cornflow.shared.rate_limit import limiter
|
|
43
|
+
from cornflow.shared.const import (
|
|
44
|
+
AUTH_DB,
|
|
45
|
+
AUTH_LDAP,
|
|
46
|
+
AUTH_OID,
|
|
47
|
+
CONDITIONAL_ENDPOINTS,
|
|
48
|
+
LEGACY_ENDPOINT_SUFFIX,
|
|
49
|
+
MFA_DEPENDENT_SETTINGS,
|
|
50
|
+
SIGNUP_PLATFORM_ADMIN_ONLY,
|
|
51
|
+
SIGNUP_WITH_AUTH,
|
|
52
|
+
SIGNUP_WITH_NO_AUTH,
|
|
53
|
+
)
|
|
54
|
+
from cornflow.shared.exceptions import initialize_errorhandlers, ConfigurationError
|
|
55
|
+
from cornflow.shared.log_config import log_config
|
|
56
|
+
from cornflow.shared.plugins import load_plugins
|
|
57
|
+
from cornflow.shared.security import init_security_headers, resolve_cors_origins
|
|
58
|
+
from cornflow.shared.security_levels import (
|
|
59
|
+
CONFIG_KEY_ADJUSTED,
|
|
60
|
+
CONFIG_KEY_CHANGED,
|
|
61
|
+
CONFIG_KEY_ERRORS,
|
|
62
|
+
CONFIG_KEY_LEVEL,
|
|
63
|
+
CONFIG_KEY_LEVEL_ERROR,
|
|
64
|
+
DEFAULT_SECURITY_LEVEL,
|
|
65
|
+
)
|
|
66
|
+
from cornflow.shared.secret_keys import (
|
|
67
|
+
CONFIG_KEY_SECRET_KEY_SOURCE,
|
|
68
|
+
CONFIG_KEY_SECRET_KEYS_DIFFER,
|
|
69
|
+
KEY_SOURCE_CONFIG,
|
|
70
|
+
MINIMUM_SECRET_KEY_LENGTH, # noqa: F401 (imported by the tests from here)
|
|
71
|
+
check_secret_keys,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _check_security_level(app):
|
|
76
|
+
"""
|
|
77
|
+
Refuses to start with an invalid CORNFLOW_SECURITY_LEVEL. config.py
|
|
78
|
+
records the error instead of raising, so the import never fails.
|
|
79
|
+
"""
|
|
80
|
+
message = app.config.get(CONFIG_KEY_LEVEL_ERROR)
|
|
81
|
+
if message:
|
|
82
|
+
raise ConfigurationError(error=message, log_txt=message)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _check_disabling_zeros(app):
|
|
86
|
+
"""
|
|
87
|
+
Refuses to start when a security setting is set to a value <= 0 that turns
|
|
88
|
+
a control off and the security level does not allow it (LOGIN_MAX_ATTEMPTS
|
|
89
|
+
at levels 2 and 3, BI_TOKEN_DURATION_DAYS at level 3).
|
|
90
|
+
"""
|
|
91
|
+
errors = tuple(app.config.get(CONFIG_KEY_ERRORS) or ())
|
|
92
|
+
if errors:
|
|
93
|
+
message = "; ".join(errors)
|
|
94
|
+
raise ConfigurationError(error=message, log_txt=message)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _check_mfa_coherence(app):
|
|
98
|
+
"""
|
|
99
|
+
Refuses to start when a setting that needs the MFA endpoints is on while
|
|
100
|
+
MFA_ENABLED is off. MFA_ENABLED is never forced to 1.
|
|
101
|
+
"""
|
|
102
|
+
mfa_enabled = int(app.config.get("MFA_ENABLED", 0))
|
|
103
|
+
if mfa_enabled == 1:
|
|
104
|
+
return
|
|
105
|
+
enabled = [
|
|
106
|
+
name for name in MFA_DEPENDENT_SETTINGS if int(app.config.get(name, 0)) == 1
|
|
107
|
+
]
|
|
108
|
+
if not enabled:
|
|
109
|
+
return
|
|
110
|
+
names = ", ".join(enabled)
|
|
111
|
+
assignments = ", ".join(f"{name}=1" for name in enabled)
|
|
112
|
+
verb = "needs" if len(enabled) == 1 else "need"
|
|
113
|
+
message = (
|
|
114
|
+
f"{assignments} {verb} MFA_ENABLED=1, but MFA_ENABLED is {mfa_enabled}: "
|
|
115
|
+
f"set MFA_ENABLED=1, or set {names} to 0"
|
|
116
|
+
)
|
|
117
|
+
raise ConfigurationError(error=message, log_txt=message)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _log_security_level(app):
|
|
121
|
+
"""
|
|
122
|
+
Logs the effective security level, the variables that change a level
|
|
123
|
+
default (INFO) and the ones clamped to a limit or not parseable (WARNING).
|
|
124
|
+
Key values are never logged: the sensitive settings hide their value.
|
|
125
|
+
"""
|
|
126
|
+
level = app.config.get(CONFIG_KEY_LEVEL)
|
|
127
|
+
app.logger.info(f"Security level: {level}")
|
|
128
|
+
for change in app.config.get(CONFIG_KEY_CHANGED) or ():
|
|
129
|
+
app.logger.info(
|
|
130
|
+
f"Security level {level}, changed setting: {change.as_log_text()}"
|
|
131
|
+
)
|
|
132
|
+
for adjustment in app.config.get(CONFIG_KEY_ADJUSTED) or ():
|
|
133
|
+
app.logger.warning(
|
|
134
|
+
f"Security level {level}, adjusted setting: {adjustment.as_log_text()}"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _run_startup_checks(app):
|
|
139
|
+
"""
|
|
140
|
+
Startup checks of the security configuration, in this order: security
|
|
141
|
+
level, disabling zeros the level does not allow, secret keys, MFA_ENABLED
|
|
142
|
+
coherence, security level log and session windows. The checks raise
|
|
143
|
+
ConfigurationError when cornflow must not start; the last two only log.
|
|
144
|
+
"""
|
|
145
|
+
_check_security_level(app)
|
|
146
|
+
_check_disabling_zeros(app)
|
|
147
|
+
_check_secret_keys(app)
|
|
148
|
+
_check_mfa_coherence(app)
|
|
149
|
+
_log_security_level(app)
|
|
150
|
+
_check_session_windows(app)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _check_secret_keys(app):
|
|
154
|
+
"""
|
|
155
|
+
Step 3 of the startup checks: the effective secret key (FERNET_KEY, else
|
|
156
|
+
SECRET_KEY, else random at level 1) and SECRET_BI_KEY, per security level.
|
|
157
|
+
Logs the warnings and raises ConfigurationError with every error joined
|
|
158
|
+
with "; ". Key values are never logged.
|
|
159
|
+
"""
|
|
160
|
+
warnings, errors = check_secret_keys(
|
|
161
|
+
level=app.config.get(CONFIG_KEY_LEVEL, DEFAULT_SECURITY_LEVEL),
|
|
162
|
+
token_key=app.config.get("SECRET_TOKEN_KEY"),
|
|
163
|
+
source=app.config.get(CONFIG_KEY_SECRET_KEY_SOURCE, KEY_SOURCE_CONFIG),
|
|
164
|
+
keys_differ=bool(app.config.get(CONFIG_KEY_SECRET_KEYS_DIFFER, False)),
|
|
165
|
+
bi_key=app.config.get("SECRET_BI_KEY"),
|
|
166
|
+
mfa_enabled=int(app.config.get("MFA_ENABLED", 0)) == 1,
|
|
167
|
+
)
|
|
168
|
+
for message in warnings:
|
|
169
|
+
app.logger.warning(message)
|
|
170
|
+
if errors:
|
|
171
|
+
message = "; ".join(errors)
|
|
172
|
+
raise ConfigurationError(error=message, log_txt=message)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _check_session_windows(app):
|
|
176
|
+
"""
|
|
177
|
+
Warns when the session windows are configured in a way that would log out
|
|
178
|
+
users who are actively working.
|
|
179
|
+
|
|
180
|
+
Activity is only recorded when the client exchanges the refresh token, and
|
|
181
|
+
a client only does that once its access token has expired. So an
|
|
182
|
+
inactivity window that is not longer than the access-token lifetime closes
|
|
183
|
+
the session of an active user: by the time the client refreshes, the
|
|
184
|
+
window has already elapsed. The same applies to an absolute cap shorter
|
|
185
|
+
than the inactivity window, which would make the window unreachable.
|
|
186
|
+
|
|
187
|
+
These are misconfigurations rather than security weaknesses (they are
|
|
188
|
+
stricter, not laxer), so they are reported and not clamped.
|
|
189
|
+
|
|
190
|
+
:param app: the Flask application being created
|
|
191
|
+
"""
|
|
192
|
+
if int(app.config.get("REFRESH_TOKEN_ENABLED", 1)) != 1:
|
|
193
|
+
return
|
|
194
|
+
access = int(app.config.get("ACCESS_TOKEN_DURATION_MINUTES", 15))
|
|
195
|
+
inactivity = int(app.config.get("REFRESH_TOKEN_INACTIVITY_MINUTES", 30))
|
|
196
|
+
absolute_minutes = int(app.config.get("REFRESH_TOKEN_ABSOLUTE_HOURS", 12)) * 60
|
|
197
|
+
if inactivity <= access:
|
|
198
|
+
app.logger.warning(
|
|
199
|
+
f"REFRESH_TOKEN_INACTIVITY_MINUTES ({inactivity}) is not greater "
|
|
200
|
+
f"than ACCESS_TOKEN_DURATION_MINUTES ({access}): users who are "
|
|
201
|
+
f"actively working will be logged out, because a client only "
|
|
202
|
+
f"refreshes its session once the access token has expired. Set "
|
|
203
|
+
f"the inactivity window above the access-token lifetime "
|
|
204
|
+
f"(defaults: 15 and 30)."
|
|
205
|
+
)
|
|
206
|
+
if absolute_minutes <= inactivity:
|
|
207
|
+
app.logger.warning(
|
|
208
|
+
f"REFRESH_TOKEN_ABSOLUTE_HOURS ({absolute_minutes // 60}h) is not "
|
|
209
|
+
f"longer than REFRESH_TOKEN_INACTIVITY_MINUTES ({inactivity} min): "
|
|
210
|
+
f"every session will end at the absolute cap and the inactivity "
|
|
211
|
+
f"window will never apply."
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _check_rate_limit_storage(app):
|
|
216
|
+
"""
|
|
217
|
+
Warns at startup when the rate limiter keeps its counters in memory.
|
|
218
|
+
The in-memory storage is per process: behind gunicorn every worker counts
|
|
219
|
+
on its own, so a client is only throttled after the configured limit
|
|
220
|
+
times the number of workers, and the remaining-requests header jumps up
|
|
221
|
+
and down depending on the worker that answers. Production deployments
|
|
222
|
+
must point RATELIMIT_STORAGE_URI to a shared storage (e.g. redis://).
|
|
223
|
+
|
|
224
|
+
:param app: the Flask application being created
|
|
225
|
+
"""
|
|
226
|
+
if not int(app.config.get("RATELIMIT_ENABLED", 0)):
|
|
227
|
+
return
|
|
228
|
+
storage = str(app.config.get("RATELIMIT_STORAGE_URI") or "memory://")
|
|
229
|
+
if storage.startswith("memory://"):
|
|
230
|
+
app.logger.warning(
|
|
231
|
+
"RATELIMIT_STORAGE_URI is memory://: the rate-limit counters are "
|
|
232
|
+
"kept per process, so with several gunicorn workers each one "
|
|
233
|
+
"counts on its own and the effective limit is the configured one "
|
|
234
|
+
"times the number of workers. Set RATELIMIT_STORAGE_URI to a "
|
|
235
|
+
"shared storage (e.g. redis://<host>:6379/0) in production."
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def _register_legacy_routes(app, resources, alarms_resources, auth_type):
|
|
240
|
+
"""
|
|
241
|
+
Registers the unprefixed routes (e.g. ``/login/``) kept for backwards
|
|
242
|
+
compatibility. The canonical routes live under ``/cornflow/``.
|
|
243
|
+
|
|
244
|
+
Every alias is named ``<endpoint>`` + ``LEGACY_ENDPOINT_SUFFIX``. To remove
|
|
245
|
+
the unprefixed routes, delete this function and its call in ``create_app``.
|
|
246
|
+
"""
|
|
247
|
+
suffix = LEGACY_ENDPOINT_SUFFIX
|
|
248
|
+
api_legacy = Api(app)
|
|
249
|
+
for res in resources:
|
|
250
|
+
api_legacy.add_resource(res["resource"], res["urls"], endpoint=res["endpoint"] + suffix)
|
|
251
|
+
if app.config["ALARMS_ENDPOINTS"]:
|
|
252
|
+
for res in alarms_resources:
|
|
253
|
+
api_legacy.add_resource(res["resource"], res["urls"], endpoint=res["endpoint"] + suffix)
|
|
254
|
+
if auth_type == AUTH_DB:
|
|
255
|
+
signup_activated = int(app.config["SIGNUP_ACTIVATED"])
|
|
256
|
+
if signup_activated in [
|
|
257
|
+
SIGNUP_WITH_AUTH,
|
|
258
|
+
SIGNUP_WITH_NO_AUTH,
|
|
259
|
+
SIGNUP_PLATFORM_ADMIN_ONLY,
|
|
260
|
+
]:
|
|
261
|
+
api_legacy.add_resource(SignUpEndpoint, CONDITIONAL_ENDPOINTS["signup"], endpoint="signup" + suffix)
|
|
262
|
+
api_legacy.add_resource(LoginEndpoint, CONDITIONAL_ENDPOINTS["login"], endpoint="login" + suffix)
|
|
263
|
+
elif auth_type == AUTH_LDAP:
|
|
264
|
+
api_legacy.add_resource(LoginEndpoint, CONDITIONAL_ENDPOINTS["login"], endpoint="login" + suffix)
|
|
265
|
+
elif auth_type == AUTH_OID:
|
|
266
|
+
api_legacy.add_resource(LoginOpenAuthEndpoint, CONDITIONAL_ENDPOINTS["login"], endpoint="login" + suffix)
|
|
267
|
+
api_legacy.add_resource(RefreshTokenEndpoint, "/token/refresh/", endpoint="token-refresh" + suffix)
|
|
268
|
+
api_legacy.add_resource(LogoutEndpoint, "/logout/", endpoint="logout" + suffix)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def create_app(env_name="development", dataconn=None):
|
|
272
|
+
"""
|
|
273
|
+
|
|
274
|
+
:param str env_name: 'testing' or 'development' or 'production'
|
|
275
|
+
:param str dataconn: string to connect to the database
|
|
276
|
+
:return: the application that is going to be running :class:`Flask`
|
|
277
|
+
:rtype: :class:`Flask`
|
|
278
|
+
"""
|
|
279
|
+
dictConfig(log_config(app_config[env_name].LOG_LEVEL))
|
|
280
|
+
|
|
281
|
+
# Note: Explicit CSRF protection is not configured as the application uses
|
|
282
|
+
# JWT for authentication via headers, mitigating standard CSRF vulnerabilities.
|
|
283
|
+
app = Flask(__name__)
|
|
284
|
+
app.json.sort_keys = False
|
|
285
|
+
app.logger.setLevel(app_config[env_name].LOG_LEVEL)
|
|
286
|
+
|
|
287
|
+
app.config.from_object(app_config[env_name])
|
|
288
|
+
_run_startup_checks(app)
|
|
289
|
+
# initialization for init_cornflow_service.py
|
|
290
|
+
if dataconn is not None:
|
|
291
|
+
app.config["SQLALCHEMY_DATABASE_URI"] = dataconn
|
|
292
|
+
# Cross-origin access is driven by CORS_ORIGINS: "*" allows any origin
|
|
293
|
+
# (development default), an explicit list restricts it and an empty value
|
|
294
|
+
# (production default) is default-closed.
|
|
295
|
+
CORS(app, origins=resolve_cors_origins(app.config.get("CORS_ORIGINS", "*")))
|
|
296
|
+
bcrypt.init_app(app)
|
|
297
|
+
db.init_app(app)
|
|
298
|
+
Migrate(app=app, db=db)
|
|
299
|
+
|
|
300
|
+
# When behind a trusted reverse proxy, honour the forwarded headers so the
|
|
301
|
+
# rate limiter and the logs see the real client IP instead of the proxy's
|
|
302
|
+
if int(app.config.get("RATELIMIT_TRUST_FORWARDED_FOR", 0)):
|
|
303
|
+
app.wsgi_app = ProxyFix(
|
|
304
|
+
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_port=1
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
limiter.init_app(app)
|
|
308
|
+
_check_rate_limit_storage(app)
|
|
309
|
+
|
|
310
|
+
if "sqlite" in app.config["SQLALCHEMY_DATABASE_URI"]:
|
|
311
|
+
|
|
312
|
+
def _fk_pragma_on_connect(dbapi_con, _con_record):
|
|
313
|
+
dbapi_con.execute("pragma foreign_keys=ON")
|
|
314
|
+
|
|
315
|
+
with app.app_context():
|
|
316
|
+
from sqlalchemy import event
|
|
317
|
+
|
|
318
|
+
event.listen(db.engine, "connect", _fk_pragma_on_connect)
|
|
319
|
+
|
|
320
|
+
# Rutas del Core bajo /cornflow/ via Blueprint (URLs canónicas)
|
|
321
|
+
cornflow_bp = Blueprint("cornflow", __name__, url_prefix="/cornflow")
|
|
322
|
+
api = Api(cornflow_bp)
|
|
323
|
+
for res in resources:
|
|
324
|
+
api.add_resource(res["resource"], res["urls"], endpoint=res["endpoint"])
|
|
325
|
+
if app.config["ALARMS_ENDPOINTS"]:
|
|
326
|
+
for res in alarms_resources:
|
|
327
|
+
api.add_resource(res["resource"], res["urls"], endpoint=res["endpoint"])
|
|
328
|
+
|
|
329
|
+
# Resource for the log-in
|
|
330
|
+
auth_type = app.config["AUTH_TYPE"]
|
|
331
|
+
|
|
332
|
+
if auth_type == AUTH_DB:
|
|
333
|
+
signup_activated = int(app.config["SIGNUP_ACTIVATED"])
|
|
334
|
+
if signup_activated in [
|
|
335
|
+
SIGNUP_WITH_AUTH,
|
|
336
|
+
SIGNUP_WITH_NO_AUTH,
|
|
337
|
+
SIGNUP_PLATFORM_ADMIN_ONLY,
|
|
338
|
+
]:
|
|
339
|
+
api.add_resource(
|
|
340
|
+
SignUpEndpoint, CONDITIONAL_ENDPOINTS["signup"], endpoint="signup"
|
|
341
|
+
)
|
|
342
|
+
api.add_resource(
|
|
343
|
+
LoginEndpoint, CONDITIONAL_ENDPOINTS["login"], endpoint="login"
|
|
344
|
+
)
|
|
345
|
+
elif auth_type == AUTH_LDAP:
|
|
346
|
+
api.add_resource(
|
|
347
|
+
LoginEndpoint, CONDITIONAL_ENDPOINTS["login"], endpoint="login"
|
|
348
|
+
)
|
|
349
|
+
elif auth_type == AUTH_OID:
|
|
350
|
+
api.add_resource(
|
|
351
|
+
LoginOpenAuthEndpoint, CONDITIONAL_ENDPOINTS["login"], endpoint="login"
|
|
352
|
+
)
|
|
353
|
+
else:
|
|
354
|
+
raise ConfigurationError(
|
|
355
|
+
error="Invalid authentication type",
|
|
356
|
+
log_txt="Error while configuring authentication. The authentication type is not valid.",
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
# Refresh-token session endpoints. Like login, they validate the token in
|
|
360
|
+
# the request themselves, so they are registered outside the permission
|
|
361
|
+
# system (no ViewModel / permission entries).
|
|
362
|
+
api.add_resource(RefreshTokenEndpoint, "/token/refresh/", endpoint="token-refresh")
|
|
363
|
+
api.add_resource(LogoutEndpoint, "/logout/", endpoint="logout")
|
|
364
|
+
|
|
365
|
+
app.register_blueprint(cornflow_bp)
|
|
366
|
+
|
|
367
|
+
_register_legacy_routes(app, resources, alarms_resources, auth_type)
|
|
368
|
+
|
|
369
|
+
# The interactive API docs (Swagger UI) are registered only when enabled
|
|
370
|
+
# (DOCS_ENABLED: on by default at security levels 1 and 2, off at level 3).
|
|
371
|
+
# Their routes get a Content-Security-Policy of their own that lets the
|
|
372
|
+
# Swagger UI load (see cornflow.shared.security); the rest of the API keeps
|
|
373
|
+
# the strict one. Only the Blueprint routes are documented; the legacy
|
|
374
|
+
# aliases are not duplicated in the schema.
|
|
375
|
+
if int(app.config.get("DOCS_ENABLED", 1)):
|
|
376
|
+
docs = FlaskApiSpec(app)
|
|
377
|
+
for res in resources:
|
|
378
|
+
docs.register(target=res["resource"], endpoint=res["endpoint"], blueprint="cornflow")
|
|
379
|
+
if app.config["ALARMS_ENDPOINTS"]:
|
|
380
|
+
for res in alarms_resources:
|
|
381
|
+
docs.register(target=res["resource"], endpoint=res["endpoint"], blueprint="cornflow")
|
|
382
|
+
|
|
383
|
+
initialize_errorhandlers(app)
|
|
384
|
+
init_compress(app)
|
|
385
|
+
init_security_headers(app)
|
|
386
|
+
|
|
387
|
+
app.cli.add_command(create_service_user)
|
|
388
|
+
app.cli.add_command(create_admin_user)
|
|
389
|
+
app.cli.add_command(register_roles)
|
|
390
|
+
app.cli.add_command(create_base_user)
|
|
391
|
+
app.cli.add_command(register_actions)
|
|
392
|
+
app.cli.add_command(register_views)
|
|
393
|
+
app.cli.add_command(register_base_assignations)
|
|
394
|
+
app.cli.add_command(access_init)
|
|
395
|
+
app.cli.add_command(register_deployed_dags)
|
|
396
|
+
app.cli.add_command(register_dag_permissions)
|
|
397
|
+
|
|
398
|
+
if int(app.config["EXTERNAL_APP"]) == 1:
|
|
399
|
+
# Legacy mode: DispatcherMiddleware mounts cornflow under APPLICATION_ROOT.
|
|
400
|
+
# The external app is responsible for combining both apps via wsgi.py.
|
|
401
|
+
if app.config["APPLICATION_ROOT"] != "/":
|
|
402
|
+
app.wsgi_app = DispatcherMiddleware(
|
|
403
|
+
NotFound(), {app.config["APPLICATION_ROOT"]: app.wsgi_app}
|
|
404
|
+
)
|
|
405
|
+
else:
|
|
406
|
+
# Plugin mode: autodiscover and mount plugins registered under cornflow.plugins.
|
|
407
|
+
load_plugins(app)
|
|
408
|
+
|
|
409
|
+
return app
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
@click.command("create_service_user")
|
|
413
|
+
@click.option("-u", "--username", required=True, type=str)
|
|
414
|
+
@click.option("-e", "--email", required=True, type=str)
|
|
415
|
+
@click.option("-p", "--password", required=True, type=str)
|
|
416
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
417
|
+
@with_appcontext
|
|
418
|
+
def create_service_user(username, email, password, verbose):
|
|
419
|
+
create_service_user_command(username, email, password, verbose)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
@click.command("create_admin_user")
|
|
423
|
+
@click.option("-u", "--username", required=True, type=str)
|
|
424
|
+
@click.option("-e", "--email", required=True, type=str)
|
|
425
|
+
@click.option("-p", "--password", required=True, type=str)
|
|
426
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
427
|
+
@with_appcontext
|
|
428
|
+
def create_admin_user(username, email, password, verbose):
|
|
429
|
+
create_admin_user_command(username, email, password, verbose)
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
@click.command("create_base_user")
|
|
433
|
+
@click.option("-u", "--username", required=True, type=str)
|
|
434
|
+
@click.option("-e", "--email", required=True, type=str)
|
|
435
|
+
@click.option("-p", "--password", required=True, type=str)
|
|
436
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
437
|
+
@with_appcontext
|
|
438
|
+
def create_base_user(username, email, password, verbose):
|
|
439
|
+
create_planner_user_command(username, email, password, verbose)
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
@click.command("register_roles")
|
|
443
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
444
|
+
@with_appcontext
|
|
445
|
+
def register_roles(verbose):
|
|
446
|
+
register_roles_command(verbose=verbose)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
@click.command("register_actions")
|
|
450
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
451
|
+
@with_appcontext
|
|
452
|
+
def register_actions(verbose):
|
|
453
|
+
register_actions_command(verbose)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
@click.command("register_views")
|
|
457
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
458
|
+
@with_appcontext
|
|
459
|
+
def register_views(verbose):
|
|
460
|
+
register_views_command(verbose=verbose)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@click.command("register_base_assignations")
|
|
464
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
465
|
+
@with_appcontext
|
|
466
|
+
def register_base_assignations(verbose):
|
|
467
|
+
register_base_permissions_command(verbose=verbose)
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
@click.command("access_init")
|
|
471
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
472
|
+
@with_appcontext
|
|
473
|
+
def access_init(verbose):
|
|
474
|
+
access_init_command(verbose=verbose)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
@click.command("register_deployed_dags")
|
|
478
|
+
@click.option("-r", "--url", type=str)
|
|
479
|
+
@click.option("-u", "--username", type=str)
|
|
480
|
+
@click.option("-p", "--password", type=str)
|
|
481
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
482
|
+
@with_appcontext
|
|
483
|
+
def register_deployed_dags(url, username, password, verbose):
|
|
484
|
+
register_deployed_dags_command(url, username, password, verbose)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
@click.command("register_dag_permissions")
|
|
488
|
+
@click.option("-o", "--open_deployment", default=0, type=int)
|
|
489
|
+
@click.option("-v", "--verbose", is_flag=True, default=False)
|
|
490
|
+
@with_appcontext
|
|
491
|
+
def register_dag_permissions(open_deployment, verbose):
|
|
492
|
+
register_dag_permissions_command(open_deployment=open_deployment, verbose=verbose)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
if __name__ == "__main__":
|
|
496
|
+
environment_name = os.getenv("FLASK_ENV", "development")
|
|
497
|
+
flask_app = create_app(environment_name)
|
|
498
|
+
flask_app.run()
|
|
@@ -11,6 +11,8 @@ from cornflow.cli.permissions import permissions
|
|
|
11
11
|
from cornflow.cli.roles import roles
|
|
12
12
|
from cornflow.cli.schemas import schemas
|
|
13
13
|
from cornflow.cli.service import service
|
|
14
|
+
from cornflow.cli.sessions import sessions
|
|
15
|
+
from cornflow.cli.tokens import tokens
|
|
14
16
|
from cornflow.cli.users import users
|
|
15
17
|
from cornflow.cli.views import views
|
|
16
18
|
|
|
@@ -31,5 +33,7 @@ cli.add_command(permissions)
|
|
|
31
33
|
cli.add_command(roles)
|
|
32
34
|
cli.add_command(schemas)
|
|
33
35
|
cli.add_command(service)
|
|
36
|
+
cli.add_command(sessions)
|
|
37
|
+
cli.add_command(tokens)
|
|
34
38
|
cli.add_command(users)
|
|
35
39
|
cli.add_command(views)
|