queryapigate 0.51.0__tar.gz → 0.53.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.
- {queryapigate-0.51.0/queryapigate.egg-info → queryapigate-0.53.0}/PKG-INFO +5 -5
- {queryapigate-0.51.0 → queryapigate-0.53.0}/README.md +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/pyproject.toml +6 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/__init__.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/adminroles.py +6 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/admins.py +28 -7
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/agentwrites.py +26 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/alerts.py +4 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/apikeys.py +11 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/app.py +95 -29
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/bundle.py +34 -17
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/cdcsources.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/cli.py +132 -49
- queryapigate-0.53.0/queryapigate/clidoc.py +92 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/config.py +156 -69
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/configcode.py +34 -12
- queryapigate-0.53.0/queryapigate/console_dist/assets/AccessMapPage-B2fgXnjB.js +2 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/AdministratorsPage-gTTL99VZ.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/AgentsPage-DD5g0r--.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/AlertsPage-CPoX-LrI.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/ApiKeyDetailPage-C4MaGe1f.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/ApiKeysPage-DCRji-0w.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/ApprovalsPage-CHk7uHED.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/AuditLogPage-4qLBj9zn.js +2 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/CachingPage-C6__FvEq.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/CatalogPage-BCIs8MUF.js +3 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/CdcSourcesPage-CYxShRau.js +2 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/CodeBox-BNjg3Ntu.js +5 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/ConnectionsPage-BM8L_7zE.js +4 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/DesignerPage-C13DG7vW.js +4 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/DestinationsPage-DCxE3xZX.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/Experimental-CzCYlw3L.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/ExportsPage-xzu1RflJ.js +1 -0
- queryapigate-0.51.0/queryapigate/console_dist/assets/HelpPage-BKnEzwAb.js → queryapigate-0.53.0/queryapigate/console_dist/assets/HelpPage-DY0w7k3J.js +2 -2
- queryapigate-0.53.0/queryapigate/console_dist/assets/HomePage-DR63y7U4.js +4 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/KeyActivity-a3QDao6f.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/Managed-D2DQQSxx.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/McpPage-xAz6EJPw.js +8 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/MetricsPage-Bo5ng5Wk.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/PageTitle-D3gn6RQm.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/Popover-1u5AL0Xi.js +1 -0
- queryapigate-0.51.0/queryapigate/console_dist/assets/QueryInfo--z9ZqXkQ.js → queryapigate-0.53.0/queryapigate/console_dist/assets/QueryInfo-rJFJMxQh.js +2 -2
- queryapigate-0.53.0/queryapigate/console_dist/assets/RepositoryPage-9BuJ7kpg.js +4 -0
- queryapigate-0.51.0/queryapigate/console_dist/assets/Results-CxkMrmv4.js → queryapigate-0.53.0/queryapigate/console_dist/assets/Results-CCSSPc8I.js +2 -2
- queryapigate-0.53.0/queryapigate/console_dist/assets/RolesPage-BDA4aTcK.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/SchemaBrowser-CKo8Uqlb.js +13 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/SettingsPage-D7-XFD6b.js +3 -0
- queryapigate-0.51.0/queryapigate/console_dist/assets/StatTile-Cft4kJPH.js → queryapigate-0.53.0/queryapigate/console_dist/assets/StatTile-5belOp8P.js +2 -2
- queryapigate-0.53.0/queryapigate/console_dist/assets/Time-B4F0EKt4.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/WorkspacesPage-BSDQ-34V.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/api-BGxrpPPD.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/data-BaZ7Pk4n.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/forms-C7YTnxLE.js +1 -0
- queryapigate-0.51.0/queryapigate/console_dist/assets/forms-Daj5x4ru.js → queryapigate-0.53.0/queryapigate/console_dist/assets/forms-DW_bgAgp.js +2 -2
- queryapigate-0.53.0/queryapigate/console_dist/assets/grantSort-D_V8ssgl.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/index-Cmfet26n.js +12 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/index-DdBLsNzW.css +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/maskRules-L7dUzZ5J.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/reach-CZ8SDAUE.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/shared-C1FQskYm.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/useMutation-DnH3aLVa.js +1 -0
- queryapigate-0.53.0/queryapigate/console_dist/assets/useTableControls-DNgJhbY_.js +1 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/console_dist/index.html +3 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/dataplane.py +4 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/definitions.py +2 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/deprecations.py +6 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/destinations.py +5 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/engine.py +26 -7
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/events.py +14 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/examples.py +295 -85
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/experimental.py +2 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/exports.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/formats.py +94 -20
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/history.py +13 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/jwtauth.py +13 -10
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/mcp_server.py +44 -12
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/metrics.py +15 -10
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/openapi.py +69 -10
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/rekey.py +6 -6
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/schema.py +1 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/secretrefs.py +68 -8
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/access.py +22 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/administrators.py +2 -1
- queryapigate-0.53.0/queryapigate/services/audit.py +80 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/collections.py +22 -10
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/connections.py +21 -5
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/destinations.py +2 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/mcp.py +2 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/queries.py +29 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/workspaces.py +1 -1
- queryapigate-0.53.0/queryapigate/settingnames.py +63 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/sqlflow.py +34 -6
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/sso.py +22 -14
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/store.py +22 -15
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/tableguard.py +7 -0
- queryapigate-0.53.0/queryapigate/toolnames.py +64 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/usage.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/v1.py +58 -13
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/v1_spec.py +92 -26
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/workspaces.py +40 -9
- {queryapigate-0.51.0 → queryapigate-0.53.0/queryapigate.egg-info}/PKG-INFO +5 -5
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate.egg-info/SOURCES.txt +52 -43
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate.egg-info/requires.txt +3 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_adminroles.py +5 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_admins.py +11 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_agent_writes.py +62 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_api_keys.py +42 -15
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_api_v1.py +172 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_audit_log.py +3 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_aws.py +5 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_backup_restore.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_cdc_sources.py +3 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_cli.py +76 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_collection_bundle.py +61 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_collections.py +45 -15
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_configcode.py +94 -6
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_connection_encryption.py +54 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_cors_and_rate_limit.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_data_protection.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_dataplane.py +21 -4
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_dependency_floors.py +4 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_deprecations.py +25 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_descriptions.py +12 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_destinations.py +2 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_duckdb_files.py +2 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_errors.py +3 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_events_server.py +3 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_examples.py +204 -9
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_export_security.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_helm.py +1 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_integration.py +65 -5
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_jwt.py +2 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_key_rotation.py +11 -6
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_limits.py +4 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_live.py +2 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_mcp.py +65 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_mcp_oauth.py +60 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_observability.py +12 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_query_window.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_queryapigate.py +122 -6
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_quotas.py +9 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_rekey.py +6 -5
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_roles.py +9 -5
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_runstore.py +13 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_secretrefs.py +20 -6
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_settings.py +1 -1
- queryapigate-0.53.0/tests/test_settings_index.py +55 -0
- queryapigate-0.53.0/tests/test_shutdown.py +142 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_sqlflow.py +22 -3
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_sso.py +28 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_vault.py +1 -1
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_workspace_isolation.py +40 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_workspace_local_files.py +55 -2
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_workspace_observability.py +21 -0
- queryapigate-0.53.0/tests/test_workspace_secret_refs.py +93 -0
- queryapigate-0.51.0/queryapigate/console_dist/assets/AccessMapPage-BLTtrvV7.js +0 -2
- queryapigate-0.51.0/queryapigate/console_dist/assets/AdministratorsPage-gWX1epBr.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/AgentsPage-CQCw6zsv.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/AlertsPage-Dcs615rM.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/ApiKeyDetailPage-CTdAD9mo.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/ApiKeysPage-DrydnYjp.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/ApprovalsPage-0cJWRfX2.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/AuditLogPage-BKUfkk9p.js +0 -2
- queryapigate-0.51.0/queryapigate/console_dist/assets/CachingPage-D9z2sT0j.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/CdcSourcesPage-ColAZA6a.js +0 -2
- queryapigate-0.51.0/queryapigate/console_dist/assets/CodeBox-Cwh5KHLp.js +0 -5
- queryapigate-0.51.0/queryapigate/console_dist/assets/ConnectionsPage-DDzYECYe.js +0 -4
- queryapigate-0.51.0/queryapigate/console_dist/assets/DesignerPage-CUtj9F6J.js +0 -4
- queryapigate-0.51.0/queryapigate/console_dist/assets/DestinationsPage-jEO9uCHi.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/Experimental-B3dnaeV7.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/ExportsPage-B1BcJ83k.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/HomePage-CU0QeQNe.js +0 -4
- queryapigate-0.51.0/queryapigate/console_dist/assets/KeyActivity-BhV8qZ-p.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/Managed-C6wP4b1l.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/McpPage-CvjuiKZV.js +0 -8
- queryapigate-0.51.0/queryapigate/console_dist/assets/MetricsPage-Cv2y-OBV.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/RepositoryPage-Dx-NdAHu.js +0 -4
- queryapigate-0.51.0/queryapigate/console_dist/assets/RolesPage-BwJqzmix.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/SchemaBrowser-C-910PNM.js +0 -13
- queryapigate-0.51.0/queryapigate/console_dist/assets/SettingsPage-CahRTpCG.js +0 -3
- queryapigate-0.51.0/queryapigate/console_dist/assets/Time-1LzS0WOr.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/WorkspacesPage-QhgHD8D7.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/api-Culg17uJ.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/client-ZHNiMG8H.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/forms-CietEOlU.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/icons-CFXE8hAz.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/index-Cv64XKNs.css +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/index-zWukbTre.js +0 -12
- queryapigate-0.51.0/queryapigate/console_dist/assets/maskRules-CvKQIPgN.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/reach-BAOLd75Y.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/shared-DZEj-9yA.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/state-O13cl7cO.js +0 -1
- queryapigate-0.51.0/queryapigate/console_dist/assets/useMutation-kSEF_Amb.js +0 -1
- queryapigate-0.51.0/queryapigate/services/audit.py +0 -38
- {queryapigate-0.51.0 → queryapigate-0.53.0}/LICENSE +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/NOTICE +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/__main__.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/accesslog.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/auditchain.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/auditstream.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/aws.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/broadcast.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/cache.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/collection_admin.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/console.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/console_dist/favicon.svg +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/cors.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/databases.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/db.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/descriptions.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/duckfiles.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/embeddings.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/errors.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/exporting.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/governance.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/gunicorn_conf.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/instances.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/lib/h2-2.2.224.jar +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/limits.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/live.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/logging_setup.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/masking.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/metacache.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/mongodocs.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/mongotools.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/oidc.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/params.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/parquet.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/pool.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/postman.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/quotas.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/ratelimit.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/rediscache.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/runners.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/runstore.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/scope.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/secheaders.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/__init__.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/cdc_sources.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/descriptions.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/services/exports.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/sqltools.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/tracing.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate/vault.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate.egg-info/dependency_links.txt +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate.egg-info/entry_points.txt +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/queryapigate.egg-info/top_level.txt +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/setup.cfg +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_adhoc_history.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_alerts.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_api_administrators.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_audit_chain.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_audit_siem.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_audit_stream.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_broadcast.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_collection_postman.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_console.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_databases.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_db.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_docs_site.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_duckdb.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_embeddings.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_events.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_experimental.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_exporting.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_exports.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_fips.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_history.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_howto.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_instances.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_jdbc.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_live_cache.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_live_debezium.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_masking.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_masking_requests.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_mcp_keycloak.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_metacache.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_mongo_streaming.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_mongotools.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_multinode.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_oidc.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_params.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_parquet.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_pool.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_publishing.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_release_check.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_response_cache.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_rolling_upgrade.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_runstore_differential.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_security_headers.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_shared_rate_limit.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_sql_guard_fuzz.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_sql_guard_writes.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_sso_keycloak.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_supply_chain.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_tableguard.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_tracing.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_upgrades.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_usage.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_workspace_config_cli.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_workspace_store.py +0 -0
- {queryapigate-0.51.0 → queryapigate-0.53.0}/tests/test_workspaces_api.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queryapigate
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.53.0
|
|
4
4
|
Summary: Turn SQL into governed REST APIs over MySQL, PostgreSQL, ClickHouse, SQLite, DuckDB, H2, MongoDB, and Parquet/CSV/JSON files - JSON, CSV, Parquet or Excel out, with scoped keys, an admin Console and MCP for AI agents.
|
|
5
5
|
Author-email: Anantha Raju C <arcswdev@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -31,11 +31,11 @@ Requires-Dist: Werkzeug>=3.0
|
|
|
31
31
|
Requires-Dist: PyYAML>=6.0.1
|
|
32
32
|
Requires-Dist: openpyxl>=3.1
|
|
33
33
|
Provides-Extra: mysql
|
|
34
|
-
Requires-Dist: mysql-connector-python>=
|
|
34
|
+
Requires-Dist: mysql-connector-python>=9.1.0; extra == "mysql"
|
|
35
35
|
Provides-Extra: postgres
|
|
36
36
|
Requires-Dist: psycopg2-binary>=2.9.5; extra == "postgres"
|
|
37
37
|
Provides-Extra: clickhouse
|
|
38
|
-
Requires-Dist: clickhouse-driver>=0.2; extra == "clickhouse"
|
|
38
|
+
Requires-Dist: clickhouse-driver>=0.2.4; extra == "clickhouse"
|
|
39
39
|
Provides-Extra: h2
|
|
40
40
|
Requires-Dist: JayDeBeApi>=1.2; extra == "h2"
|
|
41
41
|
Requires-Dist: JPype1>=1.4; extra == "h2"
|
|
@@ -61,7 +61,7 @@ Provides-Extra: otel
|
|
|
61
61
|
Requires-Dist: opentelemetry-sdk>=1.27; extra == "otel"
|
|
62
62
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.27; extra == "otel"
|
|
63
63
|
Provides-Extra: server
|
|
64
|
-
Requires-Dist: gunicorn>=
|
|
64
|
+
Requires-Dist: gunicorn>=23; extra == "server"
|
|
65
65
|
Provides-Extra: aws
|
|
66
66
|
Requires-Dist: boto3>=1.28; extra == "aws"
|
|
67
67
|
Provides-Extra: docs
|
|
@@ -250,7 +250,7 @@ SQLite needs no extra driver. H2 and generic JDBC connections (`queryapigate[h2]
|
|
|
250
250
|
driver jar is bundled, a JDBC connection to another vendor brings its own. DuckDB (`queryapigate[duckdb]`) needs no
|
|
251
251
|
external runtime either - it's a native Python extension, same as SQLite. `queryapigate[encryption]` adds
|
|
252
252
|
[encryption at rest](documentation/API.md#encryption-at-rest-for-connection-passwords) for connection passwords -
|
|
253
|
-
only needed if you set `
|
|
253
|
+
only needed if you set `QUERYAPIGATE_ENCRYPTION_KEY`.
|
|
254
254
|
From a clone: `pip install -e ".[dev]"`. Or use Docker - see [below](#try-it-with-docker).
|
|
255
255
|
|
|
256
256
|
## Quick start
|
|
@@ -169,7 +169,7 @@ SQLite needs no extra driver. H2 and generic JDBC connections (`queryapigate[h2]
|
|
|
169
169
|
driver jar is bundled, a JDBC connection to another vendor brings its own. DuckDB (`queryapigate[duckdb]`) needs no
|
|
170
170
|
external runtime either - it's a native Python extension, same as SQLite. `queryapigate[encryption]` adds
|
|
171
171
|
[encryption at rest](documentation/API.md#encryption-at-rest-for-connection-passwords) for connection passwords -
|
|
172
|
-
only needed if you set `
|
|
172
|
+
only needed if you set `QUERYAPIGATE_ENCRYPTION_KEY`.
|
|
173
173
|
From a clone: `pip install -e ".[dev]"`. Or use Docker - see [below](#try-it-with-docker).
|
|
174
174
|
|
|
175
175
|
## Quick start
|
|
@@ -31,15 +31,17 @@ classifiers = [
|
|
|
31
31
|
dependencies = ["Flask>=3.0", "Werkzeug>=3.0", "PyYAML>=6.0.1", "openpyxl>=3.1"]
|
|
32
32
|
|
|
33
33
|
[project.optional-dependencies]
|
|
34
|
-
mysql = ["mysql-connector-python>=
|
|
34
|
+
mysql = ["mysql-connector-python>=9.1.0"] # 9.0.0 and earlier: CVE-2024-21272 (CVSS 7.5)
|
|
35
35
|
postgres = ["psycopg2-binary>=2.9.5"] # 2.9.5 is the first with wheels for Python 3.11, the oldest supported
|
|
36
|
-
clickhouse = ["clickhouse-driver>=0.2"]
|
|
36
|
+
clickhouse = ["clickhouse-driver>=0.2.4"] # 0.2.4 is the first with wheels for Python 3.11
|
|
37
37
|
h2 = ["JayDeBeApi>=1.2", "JPype1>=1.4"] # also needs a Java runtime
|
|
38
38
|
duckdb = ["duckdb>=1.2"] # allowed_directories/allowed_paths, which lock every connection (duckfiles.py), arrived in 1.2
|
|
39
39
|
mongo = ["pymongo>=4.0"]
|
|
40
40
|
trino = ["trino>=0.330"] # the trino DB-API client (runners._Trino); experimental, ADR 0026
|
|
41
41
|
flow = ["sqlglot>=25.2,<31"] # the Access tab's tables and joins (sqlflow.py) and column masking's tracing (masking.py)
|
|
42
|
-
encryption = ["cryptography>=41"] # only needed when
|
|
42
|
+
encryption = ["cryptography>=41"] # only needed when QUERYAPIGATE_ENCRYPTION_KEY is set - see store.py's _get_fernet().
|
|
43
|
+
# 41, what the FIPS image's distribution ships: its later advisories (PKCS#7, PKCS#12, RSA decryption) are in code
|
|
44
|
+
# Fernet and PyJWT's signature checks don't reach
|
|
43
45
|
redis = ["redis>=5"] # only needed when QUERYAPIGATE_REDIS_URL is set - see rediscache.py
|
|
44
46
|
mcp = ["mcp>=1.21.1,<2"] # only needed for `queryapigate mcp` - see mcp_server.py. Structured tool output arrived
|
|
45
47
|
# in 1.10, but nothing before 1.21.1 can be imported beside the pydantic pip installs
|
|
@@ -50,7 +52,7 @@ jwt = ["PyJWT[crypto]>=2.14"] # only needed when QUERYAPIGATE_JWT_SECRET or QUE
|
|
|
50
52
|
all = ["queryapigate[mysql,postgres,clickhouse,h2,duckdb,mongo,trino,flow,encryption,jwt]"]
|
|
51
53
|
# only needed when an OTLP endpoint is set (OTEL_EXPORTER_OTLP_ENDPOINT) - see tracing.py
|
|
52
54
|
otel = ["opentelemetry-sdk>=1.27", "opentelemetry-exporter-otlp-proto-http>=1.27"]
|
|
53
|
-
server = ["gunicorn>=
|
|
55
|
+
server = ["gunicorn>=23"] # 22 and 23 fixed request smuggling (CVE-2024-1135, CVE-2024-6827); the image runs 26+
|
|
54
56
|
# only needed for ${aws-sm:...} and aws-rds-iam credentials (ADR 0015) - see aws.py. 1.28 is the floor because that is
|
|
55
57
|
# where boto3 reads AWS_ENDPOINT_URL_<SERVICE> (a VPC endpoint, or a local stand-in).
|
|
56
58
|
aws = ["boto3>=1.28"]
|
|
@@ -21,7 +21,7 @@ CAPABILITIES = {
|
|
|
21
21
|
'access.write': 'create, change and delete API keys and roles',
|
|
22
22
|
'cache.read': 'read cached responses',
|
|
23
23
|
'cache.write': 'clear cached responses',
|
|
24
|
-
'examples.write': 'load and remove the bundled example APIs',
|
|
24
|
+
'examples.write': 'load and remove the bundled example APIs, with their workspace and its administrators',
|
|
25
25
|
'observe': 'read the audit log, run history, alerts, instances and MCP status',
|
|
26
26
|
'settings.read': "read the server's settings",
|
|
27
27
|
'secrets.rotate': 're-encrypt stored passwords under a new encryption key (ADR 0009)',
|
|
@@ -41,8 +41,10 @@ CAPABILITIES = {
|
|
|
41
41
|
|
|
42
42
|
# What only a server-wide role gives (ADR 0023 §3): the server itself, and the people who run it. A role from a
|
|
43
43
|
# workspace membership is that role without these - whatever it is called, it administers one workspace.
|
|
44
|
+
# (config.apply isn't one: a workspace's owner applies its file.) examples.write is: the examples make a workspace and
|
|
45
|
+
# administrators.
|
|
44
46
|
SERVER_ONLY = frozenset({'admins.read', 'admins.write', 'settings.read', 'secrets.rotate', 'history.forget',
|
|
45
|
-
'workspaces.read', 'workspaces.write'
|
|
47
|
+
'workspaces.read', 'workspaces.write', 'examples.write'})
|
|
46
48
|
|
|
47
49
|
_EVERYONE = {'queries.read', 'connections.read', 'observe', 'self'}
|
|
48
50
|
ROLES = {
|
|
@@ -52,6 +54,8 @@ ROLES = {
|
|
|
52
54
|
'auditor': _EVERYONE | {'access.read', 'settings.read', 'exports.read', 'workspaces.read'},
|
|
53
55
|
}
|
|
54
56
|
ROLES['admin'] -= {'workspaces.write'} # like administrators: who belongs where is an owner's to decide
|
|
57
|
+
# The examples make a workspace and administrators with admin tokens (examples.py): an owner's, as those are.
|
|
58
|
+
ROLES['admin'] -= {'examples.write'}
|
|
55
59
|
|
|
56
60
|
# Which roles may run SQL - ad-hoc or saved - on every connection, as the shared key can. An auditor reads what
|
|
57
61
|
# happened and needs no rows.
|
|
@@ -24,7 +24,9 @@ from .db import DEFAULT_WORKSPACE
|
|
|
24
24
|
from .errors import ApiError
|
|
25
25
|
|
|
26
26
|
TOKEN_PREFIX = 'qagadm_'
|
|
27
|
-
|
|
27
|
+
# The shared key's, the CLI's and start-up's names in the audit log, and the examples' author: an administrator the
|
|
28
|
+
# examples make is marked by `created_by` being that name (examples.py), so no administrator may act under it.
|
|
29
|
+
RESERVED_NAMES = {'admin', 'cli', 'startup', '-', 'queryapigate-examples'}
|
|
28
30
|
_EMAIL_RE = re.compile(r'^[^@\s]+@[^@\s]+$')
|
|
29
31
|
_UNSET = object()
|
|
30
32
|
_USE_RECORD_INTERVAL = 60.0 # seconds between last_used_at/last_seen_at writes per token, as for API keys
|
|
@@ -161,9 +163,10 @@ def update_admin(name, role=_UNSET, email=_UNSET, active=None):
|
|
|
161
163
|
return admin
|
|
162
164
|
|
|
163
165
|
|
|
164
|
-
def delete_admin(name):
|
|
166
|
+
def delete_admin(name, check_owner=True):
|
|
165
167
|
"""Remove an administrator, every token it holds and its workspace memberships. Its name stays in the audit log
|
|
166
|
-
as written.
|
|
168
|
+
as written. `check_owner=False` is for the examples' own administrators (examples.unload()): never owners
|
|
169
|
+
server-wide, so removing one can't be what leaves the server without one."""
|
|
167
170
|
with db.transaction() as conn:
|
|
168
171
|
if _get(conn, name) is None:
|
|
169
172
|
raise ApiError(f"No administrator named '{name}'", 404, code='admin_not_found')
|
|
@@ -171,7 +174,8 @@ def delete_admin(name):
|
|
|
171
174
|
conn.execute('DELETE FROM workspace_members WHERE admin_name = ?', (name,)) # their roles in workspaces too
|
|
172
175
|
_end_sessions(conn, name)
|
|
173
176
|
conn.execute('DELETE FROM administrators WHERE name = ?', (name,))
|
|
174
|
-
|
|
177
|
+
if check_owner:
|
|
178
|
+
_refuse_ownerless(conn)
|
|
175
179
|
|
|
176
180
|
|
|
177
181
|
# --------------------------------------------------------------------------------------
|
|
@@ -394,12 +398,26 @@ def _free_name(conn, wanted):
|
|
|
394
398
|
raise ApiError('Could not find a free administrator name', 409, code='admin_exists')
|
|
395
399
|
|
|
396
400
|
|
|
397
|
-
def sign_in_sso(issuer, subject,
|
|
401
|
+
def sign_in_sso(issuer, subject, group_role, default_role, wanted_name, email):
|
|
398
402
|
"""The administrator for someone who just signed in through SSO, created on first sign-in - (admin, change)
|
|
399
403
|
where change is 'created', 'linked' (an administrator waiting for this verified email, now bound - 'linked_role'
|
|
400
404
|
when their groups also gave them a new role), 'role' (their groups gave a new role) or None. The provider decides
|
|
401
|
-
the role:
|
|
402
|
-
group.
|
|
405
|
+
the role: the one their groups map to (`group_role`), else the default role (`default_role`, anyone with a verified
|
|
406
|
+
email at an allowed domain) - one moved out of the owners' group is no longer an owner, last one or not.
|
|
407
|
+
|
|
408
|
+
Except for an administrator whose roles are all workspace memberships (ADR 0023 - no server-wide role): the
|
|
409
|
+
default role doesn't make them server-wide. Their invitation to a workspace is what lets them in, so they sign in
|
|
410
|
+
with no group too; only a group the provider puts them in gives them a server-wide role. Before, an invitation to
|
|
411
|
+
one workspace became a server-wide role - a data role in every workspace - at the first sign-in."""
|
|
412
|
+
def role_for(admin):
|
|
413
|
+
if admin is not None and admin['role'] is None and group_role is None:
|
|
414
|
+
return None
|
|
415
|
+
role = group_role or default_role
|
|
416
|
+
if role is None:
|
|
417
|
+
from .sso import NO_ROLE
|
|
418
|
+
raise ApiError(NO_ROLE, 403, code='sso_no_role')
|
|
419
|
+
return role
|
|
420
|
+
|
|
403
421
|
with db.transaction() as conn:
|
|
404
422
|
found = find_by_sso(issuer, subject)
|
|
405
423
|
if found is None and email:
|
|
@@ -409,17 +427,20 @@ def sign_in_sso(issuer, subject, role, wanted_name, email):
|
|
|
409
427
|
raise ApiError(f'More than one administrator waits for an SSO sign-in as {email}', 409,
|
|
410
428
|
code='sso_ambiguous')
|
|
411
429
|
if waiting:
|
|
430
|
+
role = role_for(waiting[0])
|
|
412
431
|
found = {**waiting[0], 'sso': {'issuer': issuer, 'subject': subject}}
|
|
413
432
|
change = 'linked' if found['role'] == role else 'linked_role'
|
|
414
433
|
found['role'] = role
|
|
415
434
|
_write_admin(conn, found)
|
|
416
435
|
return found, change
|
|
417
436
|
if found is not None:
|
|
437
|
+
role = role_for(found)
|
|
418
438
|
if found['role'] == role:
|
|
419
439
|
return found, None
|
|
420
440
|
found = {**found, 'role': role}
|
|
421
441
|
_write_admin(conn, found)
|
|
422
442
|
return found, 'role'
|
|
443
|
+
role = role_for(None)
|
|
423
444
|
admin = {'name': _free_name(conn, wanted_name), 'role': role, 'active': True, 'created_at': store.now(),
|
|
424
445
|
'email': email if email and _EMAIL_RE.match(email) else None, 'created_by': 'sso',
|
|
425
446
|
'last_seen_at': None, 'sso': {'issuer': issuer, 'subject': subject}}
|
|
@@ -68,14 +68,36 @@ def get(request_id):
|
|
|
68
68
|
return _row(row)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def list_requests(status=None, limit=200):
|
|
71
|
+
def list_requests(status=None, limit=200, cursor=None):
|
|
72
|
+
"""A page of requests, newest first, and the cursor of the next page or None (rc1, B13: before, the newest 200
|
|
73
|
+
and no way to the rest)."""
|
|
74
|
+
from .services import audit
|
|
72
75
|
if status not in (None, '') and status not in STATUSES:
|
|
73
76
|
raise ApiError(f"status must be one of: {', '.join(STATUSES)}", code='invalid_filter')
|
|
74
|
-
|
|
77
|
+
# Filtered before the limit, not after: the newest `limit` of every status, filtered afterwards, could leave out
|
|
78
|
+
# an older request still pending approval. `expired` isn't stored - it is a pending or approved one past its time
|
|
79
|
+
# (_row) - so the filter says the same here.
|
|
80
|
+
where, args, now = '', [], time.time()
|
|
81
|
+
if status in ('pending', 'approved'):
|
|
82
|
+
where, args = ' AND status = ? AND expires_at >= ?', [status, now]
|
|
83
|
+
elif status == 'expired':
|
|
84
|
+
where, args = " AND (status = 'expired' OR (status IN ('pending', 'approved') AND expires_at < ?))", [now]
|
|
85
|
+
elif status:
|
|
86
|
+
where, args = ' AND status = ?', [status]
|
|
87
|
+
if cursor:
|
|
88
|
+
created, request_id = audit.decode_cursor(
|
|
89
|
+
cursor, lambda v: isinstance(v, list) and len(v) == 2 and all(isinstance(x, str) for x in v))
|
|
90
|
+
where += ' AND (created_at < ? OR (created_at = ? AND id < ?))'
|
|
91
|
+
args += [created, created, request_id]
|
|
92
|
+
limit = audit.page_limit(limit, 200)
|
|
93
|
+
rows = db.connection().execute(f'SELECT {_COLUMNS} FROM write_requests WHERE workspace = ?{where} '
|
|
75
94
|
'ORDER BY created_at DESC, id DESC LIMIT ?',
|
|
76
|
-
(scope.current(),
|
|
95
|
+
(scope.current(), *args, limit + 1)).fetchall()
|
|
77
96
|
found = [_row(r) for r in rows]
|
|
78
|
-
|
|
97
|
+
more = len(found) > limit
|
|
98
|
+
found = found[:limit]
|
|
99
|
+
next_cursor = audit.encode_cursor([rows[limit - 1]['created_at'], rows[limit - 1]['id']]) if more else None
|
|
100
|
+
return [r for r in found if not status or r['status'] == status], next_cursor
|
|
79
101
|
|
|
80
102
|
|
|
81
103
|
def approval_url(request_id):
|
|
@@ -105,7 +105,7 @@ def _sso():
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
def _encryption():
|
|
108
|
-
"""
|
|
108
|
+
"""QUERYAPIGATE_ENCRYPTION_KEY lists more than one key: a rotation was started (ADR 0009) and isn't finished -
|
|
109
109
|
passwords are still under an old key (run rekey), or none are (remove the old keys)."""
|
|
110
110
|
if len(config.secret_keys()) < 2:
|
|
111
111
|
return []
|
|
@@ -116,12 +116,12 @@ def _encryption():
|
|
|
116
116
|
if old:
|
|
117
117
|
return [_alert('warning', 'encryption_key_rotation_incomplete', 'secret_key',
|
|
118
118
|
f"{_plural(old, 'password')} {'is' if old == 1 else 'are'} still encrypted with an old key",
|
|
119
|
-
'
|
|
119
|
+
'QUERYAPIGATE_ENCRYPTION_KEY lists several keys, so a rotation has started. Run `queryapigate '
|
|
120
120
|
'rekey` to re-encrypt them with the first key, then remove the others.', target)]
|
|
121
121
|
return [_alert('info', 'encryption_key_rotation_incomplete', 'secret_key',
|
|
122
122
|
'Every password is under the new encryption key - remove the old ones',
|
|
123
|
-
f"
|
|
124
|
-
'the first. Remove the others from every instance to finish the rotation.', target)]
|
|
123
|
+
f"QUERYAPIGATE_ENCRYPTION_KEY still lists {found['keys']} keys, but nothing is encrypted with any "
|
|
124
|
+
'but the first. Remove the others from every instance to finish the rotation.', target)]
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
def _secret_providers():
|
|
@@ -232,6 +232,15 @@ def _upsert(conn, name, entry, workspace=None):
|
|
|
232
232
|
entry.get('expires_at'), entry.get('created_at') or store.now(), json.dumps(details)))
|
|
233
233
|
|
|
234
234
|
|
|
235
|
+
def require_connections(connections):
|
|
236
|
+
"""A new key or role names its connections (rc1, B1): left out, it used to mean every connection - the widest
|
|
237
|
+
grant there is, given by silence, while every other grant left out gives nothing. Stored keys and roles keep
|
|
238
|
+
what they hold; only a create (the API, the CLI, a configuration file) is refused."""
|
|
239
|
+
if connections is None:
|
|
240
|
+
raise ApiError('connections is required: a list of connection names, [] for none (saved queries only), or '
|
|
241
|
+
f'"{ALL_CONNECTIONS}" for every connection', code='invalid_body')
|
|
242
|
+
|
|
243
|
+
|
|
235
244
|
def _normalize_connections(connections):
|
|
236
245
|
if connections in (None, ALL_CONNECTIONS):
|
|
237
246
|
return ALL_CONNECTIONS
|
|
@@ -541,6 +550,8 @@ def create_key(name, connections=None, allow_writes=None, queries=None, expires_
|
|
|
541
550
|
example=False, mask=None, max_concurrent=None, query_timeout=None, max_rows=None, quota=None):
|
|
542
551
|
if not isinstance(name, str) or not _NAME_RE.match(name):
|
|
543
552
|
raise ApiError("API key name may only contain letters, digits, spaces, '.', '_' and '-'", code='invalid_name')
|
|
553
|
+
if name in admins.RESERVED_NAMES: # `admin` is every administrator's label in /metrics, `-` no caller's
|
|
554
|
+
raise ApiError(f"'{name}' is reserved - choose another name", code='invalid_name')
|
|
544
555
|
admins.refuse_taken_name(name)
|
|
545
556
|
if role is None:
|
|
546
557
|
collections = _normalize_collections(collections)
|
|
@@ -52,6 +52,7 @@ from . import (
|
|
|
52
52
|
schema,
|
|
53
53
|
scope,
|
|
54
54
|
secheaders,
|
|
55
|
+
settingnames,
|
|
55
56
|
sqltools,
|
|
56
57
|
sso,
|
|
57
58
|
store,
|
|
@@ -144,10 +145,12 @@ def load_examples_at_startup():
|
|
|
144
145
|
log.warning('QUERYAPIGATE_LOAD_EXAMPLES is set but the examples could not be loaded (unexpected error: %s)',
|
|
145
146
|
error, exc_info=True)
|
|
146
147
|
return
|
|
147
|
-
if added
|
|
148
|
+
if examples.added_anything(added):
|
|
148
149
|
store.record_audit('startup', 'load_examples', 'examples', examples.redact_for_audit(added))
|
|
149
|
-
log.info('Loaded the example APIs: %d queries, %d roles, %d API keys
|
|
150
|
-
|
|
150
|
+
log.info('Loaded the example APIs: %d queries, %d roles, %d API keys, and the %s workspace with %d members',
|
|
151
|
+
len(added['queries']) + len(added['workspace']['queries']),
|
|
152
|
+
len(added['roles']) + len(added['workspace']['roles']), len(added['key_secrets']),
|
|
153
|
+
examples.WORKSPACE, len(added['workspace']['members']))
|
|
151
154
|
if added['key_secrets']:
|
|
152
155
|
# There is no interactive terminal at startup to hand these to (unlike `queryapigate examples
|
|
153
156
|
# load`'s own stdout) and a secret is never recoverable once created - the log is the only
|
|
@@ -157,20 +160,25 @@ def load_examples_at_startup():
|
|
|
157
160
|
# rotates away.
|
|
158
161
|
log.warning('Example API keys were just created - store these now, they cannot be shown again: %s',
|
|
159
162
|
', '.join(f'{name}={secret}' for name, secret in sorted(added['key_secrets'].items())))
|
|
163
|
+
if added['admin_tokens']:
|
|
164
|
+
# The same reasoning: the example workspace's members sign in to the Console with these, and only these.
|
|
165
|
+
log.warning('Admin tokens for the %s workspace\'s example members were just created - store these now, '
|
|
166
|
+
'they cannot be shown again: %s', examples.WORKSPACE,
|
|
167
|
+
', '.join(f'{name}={secret}' for name, secret in sorted(added['admin_tokens'].items())))
|
|
160
168
|
|
|
161
169
|
|
|
162
170
|
def warn_env_references():
|
|
163
|
-
"""Once at startup: ${VAR} references in use with no QUERYAPIGATE_SECRET_ENV_VARS
|
|
164
|
-
|
|
171
|
+
"""Once at startup: ${VAR} references in use with no QUERYAPIGATE_SECRET_ENV_VARS. Unset, none is read (rc1, B2:
|
|
172
|
+
before, any could be, but the few secretrefs.py always refuses - ADR 0017), so the connections and destinations that
|
|
173
|
+
use them fail until it's set: the log names the setting that brings them back."""
|
|
165
174
|
from . import destinations, secretrefs
|
|
166
175
|
if config.secret_env_vars():
|
|
167
176
|
return
|
|
168
177
|
used = secretrefs.env_variables([*store.read_connections().values(), *destinations.list_all()])
|
|
169
178
|
if used:
|
|
170
|
-
log.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
', '.join(used))
|
|
179
|
+
log.error('Connections and destinations reference environment variables (%s), and QUERYAPIGATE_SECRET_ENV_VARS '
|
|
180
|
+
'is unset: no ${VAR} is read without it, so they fail until it is set. To keep them working, set '
|
|
181
|
+
'QUERYAPIGATE_SECRET_ENV_VARS=%s', ', '.join(used), ','.join(used))
|
|
174
182
|
|
|
175
183
|
|
|
176
184
|
class _CapturePeer:
|
|
@@ -182,8 +190,10 @@ class _CapturePeer:
|
|
|
182
190
|
server sees the request as if the client had connected directly, ProxyFix and QUERYAPIGATE_TRUST_PROXY included.
|
|
183
191
|
A peer that isn't an IP address counts as remote, as a Unix socket does. A data plane from another release
|
|
184
192
|
(X-QAG-Dataplane-Version) is still the data plane, but is given no plan (dataplane.paired()). The rate-limit buckets
|
|
185
|
-
it counted a call in before forwarding it (X-QAG-Rate-Counted, ADR 0032) are taken from it alone. Its
|
|
186
|
-
|
|
193
|
+
it counted a call in before forwarding it (X-QAG-Rate-Counted, ADR 0032) are taken from it alone. Its own calls to
|
|
194
|
+
/internal/dataplane/* carry X-QAG-Own as well, which it takes off every request it relays: the secret alone means
|
|
195
|
+
"came through the data plane", which every client's call does. Its headers are removed here, so nothing after this
|
|
196
|
+
layer reads, logs or passes on the secret."""
|
|
187
197
|
|
|
188
198
|
def __init__(self, app):
|
|
189
199
|
self.app = app
|
|
@@ -194,7 +204,9 @@ class _CapturePeer:
|
|
|
194
204
|
wanted = environ.pop(dataplane.WANTED_ENVIRON, None)
|
|
195
205
|
version = environ.pop(dataplane.VERSION_ENVIRON, None)
|
|
196
206
|
rate_counted = environ.pop(dataplane.COUNTED_ENVIRON, None)
|
|
207
|
+
own = environ.pop(dataplane.OWN_ENVIRON, None)
|
|
197
208
|
if supplied is not None and dataplane.matches(supplied):
|
|
209
|
+
environ['queryapigate.dataplane_own'] = own == '1'
|
|
198
210
|
is_paired = dataplane.paired(version)
|
|
199
211
|
environ['queryapigate.dataplane'] = 'plan' if wanted == '1' and is_paired else True
|
|
200
212
|
environ['queryapigate.dataplane_paired'] = is_paired
|
|
@@ -215,6 +227,11 @@ def create_app():
|
|
|
215
227
|
from . import __version__
|
|
216
228
|
config.check_settings()
|
|
217
229
|
logging_setup.configure(log) # before anything below logs - the legacy import's deprecation warning, for one
|
|
230
|
+
unknown = settingnames.unknown(os.environ, config.SECRET_SETTINGS)
|
|
231
|
+
if unknown: # a typo is ignored otherwise, and what was meant runs with its default (rc1, D1)
|
|
232
|
+
log.warning('%s %s no setting of this server, and %s ignored - see documentation/CONFIGURATION.md for every '
|
|
233
|
+
'one', ', '.join(unknown), 'is' if len(unknown) == 1 else 'are',
|
|
234
|
+
'it is' if len(unknown) == 1 else 'they are')
|
|
218
235
|
db.init_schema()
|
|
219
236
|
runstore.check_marker()
|
|
220
237
|
store.refuse_legacy_home()
|
|
@@ -261,29 +278,29 @@ def create_app():
|
|
|
261
278
|
'create an owner with `queryapigate admins create NAME --role owner`.')
|
|
262
279
|
if config.secret_key():
|
|
263
280
|
# Encrypt any literal password already on disk immediately, rather than waiting for its next
|
|
264
|
-
# PATCH /api/v1/connections - a connection saved before
|
|
281
|
+
# PATCH /api/v1/connections - a connection saved before QUERYAPIGATE_ENCRYPTION_KEY existed benefits right away.
|
|
265
282
|
store.encrypt_plaintext_passwords_in_place()
|
|
266
283
|
from . import rekey
|
|
267
284
|
found = rekey.report()
|
|
268
285
|
if found['undecryptable']:
|
|
269
|
-
log.warning('No key in
|
|
286
|
+
log.warning('No key in QUERYAPIGATE_ENCRYPTION_KEY decrypts the secret of %s - add the key it was '
|
|
270
287
|
'encrypted with (after the first), or enter it again.',
|
|
271
288
|
', '.join(rekey.describe(v) for v in found['undecryptable']))
|
|
272
289
|
if found['under_old_keys']:
|
|
273
|
-
log.warning('%d password(s) are still encrypted with an old key in
|
|
290
|
+
log.warning('%d password(s) are still encrypted with an old key in QUERYAPIGATE_ENCRYPTION_KEY - run '
|
|
274
291
|
'`queryapigate rekey` to move them to the first key, then remove the others.',
|
|
275
292
|
found['under_old_keys'])
|
|
276
293
|
else:
|
|
277
294
|
encrypted = store.encrypted_password_connections()
|
|
278
295
|
if encrypted:
|
|
279
|
-
log.warning('Connection(s) %s have an encrypted password but
|
|
296
|
+
log.warning('Connection(s) %s have an encrypted password but QUERYAPIGATE_ENCRYPTION_KEY is not set - '
|
|
280
297
|
'they cannot be used until the key that encrypted them is restored.',
|
|
281
298
|
', '.join(encrypted))
|
|
282
299
|
plaintext = store.plaintext_password_connections()
|
|
283
300
|
if plaintext:
|
|
284
301
|
log.warning("Connection(s) %s store a literal password in %s. Consider a \"${VAR}\" reference to an "
|
|
285
302
|
"environment variable instead - it reads the same way but keeps the secret out of the file, "
|
|
286
|
-
"or set
|
|
303
|
+
"or set QUERYAPIGATE_ENCRYPTION_KEY to encrypt it at rest automatically.",
|
|
287
304
|
', '.join(plaintext), config.db_file())
|
|
288
305
|
_note_audit_key_rotation()
|
|
289
306
|
from . import auditstream
|
|
@@ -336,7 +353,8 @@ def create_app():
|
|
|
336
353
|
g.request_id = new_request_id(request.headers.get('X-Request-Id'))
|
|
337
354
|
g.request_started = time.monotonic()
|
|
338
355
|
if request.endpoint in DATAPLANE_ENDPOINTS: # the data plane's own calls: nothing else applies to them
|
|
339
|
-
|
|
356
|
+
# Its own - not merely through it: every client's call through the data plane carries the secret too
|
|
357
|
+
if request.environ.get('queryapigate.dataplane_own'):
|
|
340
358
|
return None
|
|
341
359
|
return jsonify(error_body('Not Found', 404)), 404
|
|
342
360
|
if request.environ.get('queryapigate.dataplane') == 'plan': # before the key is read: a plan names its row
|
|
@@ -590,19 +608,21 @@ def get_json_body(required=True):
|
|
|
590
608
|
get_object = definitions.as_object # one definition, shared with saved-query validation
|
|
591
609
|
|
|
592
610
|
|
|
593
|
-
def get_int(value, label):
|
|
611
|
+
def get_int(value, label, code):
|
|
612
|
+
"""`value` as an int, None when not given - else a 400 with `code`, what the argument is to the endpoint (rc1, D6:
|
|
613
|
+
page=abc was invalid_request while page=0 was invalid_paging)."""
|
|
594
614
|
if value is None or value == '':
|
|
595
615
|
return None
|
|
596
616
|
try:
|
|
597
617
|
return int(value)
|
|
598
618
|
except (TypeError, ValueError):
|
|
599
|
-
raise ApiError(f'{label} must be an integer') from None
|
|
619
|
+
raise ApiError(f'{label} must be an integer', code=code) from None
|
|
600
620
|
|
|
601
621
|
|
|
602
622
|
def get_pagination():
|
|
603
623
|
"""Return (limit, offset, page) from the ?page and ?page_size query parameters."""
|
|
604
|
-
page = get_int(request.args.get('page'), 'page')
|
|
605
|
-
page_size = get_int(request.args.get('page_size'), 'page_size')
|
|
624
|
+
page = get_int(request.args.get('page'), 'page', 'invalid_paging')
|
|
625
|
+
page_size = get_int(request.args.get('page_size'), 'page_size', 'invalid_paging')
|
|
606
626
|
page = 1 if page is None else page
|
|
607
627
|
page_size = 10 if page_size is None else page_size
|
|
608
628
|
if page < 1 or page_size < 1:
|
|
@@ -642,7 +662,9 @@ def render(result, output_format, page, page_size):
|
|
|
642
662
|
single serialization span to measure for those (see that function's docstring)."""
|
|
643
663
|
started = time.monotonic()
|
|
644
664
|
with tracing.span(f'serialize {output_format}', attributes={'queryapigate.format': output_format}) as span:
|
|
645
|
-
|
|
665
|
+
# No rows is the format's own empty document (rc1, B5): [], a header-only CSV, an empty NDJSON body - before, a
|
|
666
|
+
# {"message": "No results returned"} object in every format, contradicting the documented array.
|
|
667
|
+
response = FORMATTERS[output_format](result)
|
|
646
668
|
tracing.set_attributes(span, queryapigate__bytes=response.content_length)
|
|
647
669
|
elapsed = time.monotonic() - started
|
|
648
670
|
metrics.observe_serialization(output_format, elapsed)
|
|
@@ -672,7 +694,7 @@ def stream_sql_response(sql, connection_name, params, timeout, output_format, fi
|
|
|
672
694
|
raise ApiError('stream=true exports the whole result and does not accept page/page_size', code='invalid_stream')
|
|
673
695
|
key_name = metrics_key_name()
|
|
674
696
|
columns, rows = engine.stream_sql(sql, connection_name, params, timeout, key_name=key_name,
|
|
675
|
-
allowed_tables=allowed_tables, mask=mask)
|
|
697
|
+
allowed_tables=allowed_tables, mask=mask, database=database)
|
|
676
698
|
# Captured here, not inside _record_stream_history(): that generator's body runs lazily, as the response
|
|
677
699
|
# streams out - by then the request/app context this view function runs in is long gone (no
|
|
678
700
|
# flask.stream_with_context() wrapping is used), so g, caller_key_name() and current_app are only safe to read
|
|
@@ -812,6 +834,7 @@ def _stream_history(rows, entry, record, permission=None):
|
|
|
812
834
|
@bp.route('/execute_sql', methods=['POST'])
|
|
813
835
|
def execute_sql_endpoint():
|
|
814
836
|
data = get_json_body()
|
|
837
|
+
refuse_unknown_body(data, ('sql', 'connection_name', 'database', 'params', 'format', 'timeout', 'mask'))
|
|
815
838
|
if not data.get('sql'):
|
|
816
839
|
raise ApiError('SQL query is missing', code='sql_required')
|
|
817
840
|
if not data.get('connection_name'):
|
|
@@ -861,6 +884,8 @@ def execute_mongo_endpoint():
|
|
|
861
884
|
full stop (BACKLOG #36: MongoDB support is find-only in this version) - unlike /execute_sql there is no
|
|
862
885
|
write permission to check."""
|
|
863
886
|
data = get_json_body()
|
|
887
|
+
refuse_unknown_body(data, ('collection', 'connection_name', 'filter', 'params', 'format', 'timeout', 'projection',
|
|
888
|
+
'sort'))
|
|
864
889
|
if not data.get('collection'):
|
|
865
890
|
raise ApiError('Collection is missing', code='collection_required')
|
|
866
891
|
if not data.get('connection_name'):
|
|
@@ -992,6 +1017,44 @@ def bind_embeddings(saved, values, connection_name):
|
|
|
992
1017
|
return values
|
|
993
1018
|
|
|
994
1019
|
|
|
1020
|
+
def _refuse_unreachable(path, content):
|
|
1021
|
+
"""A saved query this caller can't run at all is one that doesn't exist (rc1, B12): the same 404, with the same
|
|
1022
|
+
message, as a name never used - before, a 403 naming its connection told a key which names exist. Reachable is
|
|
1023
|
+
what can_run_saved() says of its published version - by a `queries` or collection grant, or its connection's -
|
|
1024
|
+
and, for a query with no connection of its own, any connection grant (?connection_name= still needs one). A
|
|
1025
|
+
caller that can reach it still gets a 403 for another connection, or a claim it lacks. An administrator - even an
|
|
1026
|
+
auditor, who runs nothing - lists the names anyway (queries.read), so is told why."""
|
|
1027
|
+
permission = g.permission
|
|
1028
|
+
if permission.admin or permission.role is not None:
|
|
1029
|
+
return
|
|
1030
|
+
name = store.query_name(path)
|
|
1031
|
+
try:
|
|
1032
|
+
_, live = store.select_version(content, None)
|
|
1033
|
+
except ApiError:
|
|
1034
|
+
live = None # nothing published: a draft, which no caller but an administrator runs - 404 below, as before
|
|
1035
|
+
if live is not None:
|
|
1036
|
+
connection_name = live.get('connection_name')
|
|
1037
|
+
reached_by_connection = (apikeys.can_use(permission, connection_name) if connection_name
|
|
1038
|
+
else bool(permission.connections))
|
|
1039
|
+
if (reached_by_connection or apikeys.can_use_query(permission, name)
|
|
1040
|
+
or apikeys.can_use_collection(permission, store.read_collection(content))):
|
|
1041
|
+
return
|
|
1042
|
+
raise ApiError(f"Saved query '{name}' not found", 404, code='query_not_found')
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
_QUERY_STRING_ONLY = ('page', 'page_size', 'stream')
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
def refuse_unknown_body(data, allowed):
|
|
1049
|
+
"""A body field the endpoint doesn't read is refused (unknown_field, rc1 B8): before, `page`, `page_size` and
|
|
1050
|
+
`stream` in a body were dropped without a word - they're read from the query string only."""
|
|
1051
|
+
unknown = sorted(set(data) - set(allowed))
|
|
1052
|
+
if unknown:
|
|
1053
|
+
hint = (f" - {', '.join(k for k in unknown if k in _QUERY_STRING_ONLY)} go in the query string"
|
|
1054
|
+
if any(k in _QUERY_STRING_ONLY for k in unknown) else '')
|
|
1055
|
+
raise ApiError(f"Unknown field(s): {', '.join(unknown)}{hint}", code='unknown_field')
|
|
1056
|
+
|
|
1057
|
+
|
|
995
1058
|
def run_saved(ref, body, url_params):
|
|
996
1059
|
"""_run_saved(), in its own span (tracing.py): named once the query is found, never by what the caller sent."""
|
|
997
1060
|
with tracing.span('query') as span:
|
|
@@ -1008,7 +1071,8 @@ def _run_saved(ref, body, url_params):
|
|
|
1008
1071
|
doesn't exist: the same 404 as a version number that was never used, so drafts can't be discovered."""
|
|
1009
1072
|
path = store.resolve_saved_file(ref, check_exists=False) # load_versions() 404s the same, one read fewer
|
|
1010
1073
|
content = store.load_versions(path, with_history=False)
|
|
1011
|
-
|
|
1074
|
+
_refuse_unreachable(path, content)
|
|
1075
|
+
requested = get_int(request.args.get('version') or body.get('version'), 'version', 'invalid_version')
|
|
1012
1076
|
if requested is not None and store.is_draft(content, requested) and not g.permission.admin:
|
|
1013
1077
|
raise ApiError(f'Version {requested} not found', 404, code='version_not_found')
|
|
1014
1078
|
number, saved = store.select_version(content, requested)
|
|
@@ -1033,6 +1097,8 @@ def _run_saved(ref, body, url_params):
|
|
|
1033
1097
|
if not (granted_by_name and connection_name == saved.get('connection_name')):
|
|
1034
1098
|
require_connection(connection_name)
|
|
1035
1099
|
|
|
1100
|
+
if 'placeholders' in body:
|
|
1101
|
+
deprecations.warn('placeholders')
|
|
1036
1102
|
raw = {**url_params, **get_object(body.get('params'), 'params'),
|
|
1037
1103
|
**get_object(body.get('placeholders'), 'placeholders')}
|
|
1038
1104
|
raw = bind_claims(saved, raw)
|
|
@@ -1250,6 +1316,7 @@ def run_saved_mongo(saved, path, number, ref, connection_name, raw, output_forma
|
|
|
1250
1316
|
@bp.route('/q/<name>', methods=['GET', 'POST'])
|
|
1251
1317
|
def run_named_query(name):
|
|
1252
1318
|
body = get_json_body(required=False) if request.method == 'POST' else {}
|
|
1319
|
+
refuse_unknown_body(body, ('version', 'connection_name', 'params', 'placeholders', 'format', 'timeout'))
|
|
1253
1320
|
url_params = {k: v for k, v in request.args.items() if k not in RESERVED_ARGS}
|
|
1254
1321
|
return run_saved(name, body, url_params)
|
|
1255
1322
|
|
|
@@ -1486,15 +1553,14 @@ def health():
|
|
|
1486
1553
|
|
|
1487
1554
|
@bp.route('/metrics', methods=['GET'])
|
|
1488
1555
|
def metrics_endpoint():
|
|
1489
|
-
"""
|
|
1490
|
-
|
|
1491
|
-
since its ingress would otherwise publish the counts and the key, query and connection names in them (ADR 0017's
|
|
1492
|
-
review)."""
|
|
1556
|
+
"""For a scraper (metrics.authorized(): its token, or without one a client on this machine), or an administrator
|
|
1557
|
+
whose role may observe, as the Console's Metrics screen reads it."""
|
|
1493
1558
|
from . import adminroles
|
|
1494
1559
|
permission = g.get('permission')
|
|
1495
1560
|
# every workspace's counts: a server-wide role's to read (ADR 0023)
|
|
1496
1561
|
observer = adminroles.allows(permission, 'observe') and getattr(permission, 'server_wide', True)
|
|
1497
|
-
if not (observer or metrics.authorized(request.headers.get('Authorization')
|
|
1562
|
+
if not (observer or metrics.authorized(request.headers.get('Authorization'),
|
|
1563
|
+
request.environ.get('queryapigate.peer_addr'))):
|
|
1498
1564
|
response = jsonify(error_body(metrics.UNAUTHORIZED, 401))
|
|
1499
1565
|
response.status_code = 401
|
|
1500
1566
|
response.headers['WWW-Authenticate'] = 'Bearer realm="metrics"'
|