From d8339fe6510ac52b748a737be5691740320f81dd Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 29 May 2024 10:45:35 -0400 Subject: [PATCH] Allow oauth2 file sources with Dropbox initial implementation. --- client/src/api/schema/schema.ts | 77 +++++++- .../ConfigurationTestSummary.vue | 3 + .../useConfigurationTesting.ts | 4 + .../FileSources/Instances/CreateForm.vue | 2 + .../FileSources/Instances/CreateInstance.vue | 33 +++- .../FileSources/Instances/services.ts | 4 + .../ObjectStore/Instances/CreateForm.vue | 2 + client/src/entry/analysis/router.js | 5 +- doc/source/admin/data.md | 148 +++++++++++++++ doc/source/admin/dropbox_callback.png | Bin 0 -> 33083 bytes doc/source/admin/dropbox_client_creds.png | Bin 0 -> 25403 bytes .../admin/dropbox_create_app_options_1.png | Bin 0 -> 223520 bytes doc/source/admin/dropbox_create_button.png | Bin 0 -> 66003 bytes doc/source/admin/dropbox_scopes.png | Bin 0 -> 252834 bytes .../file_source_dropbox_configuration.png | Bin 0 -> 15944 bytes ..._source_dropbox_configuration_template.png | Bin 0 -> 26877 bytes doc/source/admin/file_source_templates.png | Bin 323201 -> 409046 bytes doc/source/admin/gen_diagrams.py | 4 + lib/galaxy/app_unittest_utils/galaxy_mock.py | 2 +- lib/galaxy/files/sources/dropbox.py | 2 + lib/galaxy/files/templates/__init__.py | 4 + .../dropbox_client_secrets_explicit.yml | 7 + .../dropbox_client_secrets_in_vault.yml | 14 ++ .../templates/examples/production_dropbox.yml | 14 ++ lib/galaxy/files/templates/models.py | 66 ++++++- lib/galaxy/managers/_config_templates.py | 179 ++++++++++++++++-- lib/galaxy/managers/file_source_instances.py | 168 ++++++++++++++-- lib/galaxy/managers/object_store_instances.py | 11 +- lib/galaxy/model/__init__.py | 12 +- lib/galaxy/schema/schema.py | 13 ++ lib/galaxy/util/config_templates.py | 112 +++++++++++ lib/galaxy/webapps/galaxy/api/file_sources.py | 27 ++- .../webapps/galaxy/api/oauth2_callback.py | 51 +++++ .../app/managers/test_user_file_sources.py | 173 +++++++++++++++++ test/unit/files/test_template_models.py | 3 + test/unit/schema/test_schema.py | 8 + 36 files changed, 1106 insertions(+), 42 deletions(-) create mode 100644 doc/source/admin/dropbox_callback.png create mode 100644 doc/source/admin/dropbox_client_creds.png create mode 100644 doc/source/admin/dropbox_create_app_options_1.png create mode 100644 doc/source/admin/dropbox_create_button.png create mode 100644 doc/source/admin/dropbox_scopes.png create mode 100644 doc/source/admin/file_source_dropbox_configuration.png create mode 100644 doc/source/admin/file_source_dropbox_configuration_template.png create mode 100644 lib/galaxy/files/templates/examples/dropbox_client_secrets_explicit.yml create mode 100644 lib/galaxy/files/templates/examples/dropbox_client_secrets_in_vault.yml create mode 100644 lib/galaxy/files/templates/examples/production_dropbox.yml create mode 100644 lib/galaxy/webapps/galaxy/api/oauth2_callback.py diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index 1208a1260e0d..edbce0bb2c4e 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -346,6 +346,10 @@ export interface paths { /** Get a list of file source templates available to build user defined file sources from */ get: operations["file_sources__templates_index"]; }; + "/api/file_source_templates/{template_id}/{template_version}/oauth2": { + /** Template Oauth2 */ + get: operations["file_sources__template_oauth2"]; + }; "/api/folders/{folder_id}/contents": { /** * Returns a list of a folder's contents (files and sub-folders) with additional metadata about the folder. @@ -2063,6 +2067,10 @@ export interface paths { /** Service Info */ get: operations["service_info_ga4gh_drs_v1_service_info_get"]; }; + "/oauth2_callback": { + /** Callback entry point for remote resource responses with OAuth2 authorization codes */ + get: operations["oauth2_callback_oauth2_callback_get"]; + }; } export type webhooks = Record; @@ -3231,6 +3239,8 @@ export interface components { template_id: string; /** Template Version */ template_version: number; + /** Uuid */ + uuid?: string | null; /** Variables */ variables: { [key: string]: (string | boolean | number) | undefined; @@ -5299,7 +5309,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure"; + type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox"; /** Variables */ variables?: | ( @@ -9969,6 +9979,11 @@ export interface components { */ updated_count: number; }; + /** OAuth2Info */ + OAuth2Info: { + /** Authorize Url */ + authorize_url: string; + }; /** ObjectExportTaskResponse */ ObjectExportTaskResponse: { /** @@ -10494,6 +10509,7 @@ export interface components { /** PluginStatus */ PluginStatus: { connection?: components["schemas"]["PluginAspectStatus"] | null; + oauth2_access_token_generation?: components["schemas"]["PluginAspectStatus"] | null; template_definition: components["schemas"]["PluginAspectStatus"]; template_settings?: components["schemas"]["PluginAspectStatus"] | null; }; @@ -12809,7 +12825,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure"; + type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox"; /** Uri Root */ uri_root: string; /** Uuid */ @@ -15256,6 +15272,35 @@ export interface operations { }; }; }; + file_sources__template_oauth2: { + /** Template Oauth2 */ + parameters: { + /** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */ + header?: { + "run-as"?: string | null; + }; + /** @description The template ID of the target file source template. */ + /** @description The template version of the target file source template. */ + path: { + template_id: string; + template_version: number; + }; + }; + responses: { + /** @description OAuth2 authorization url to redirect user to prior to creation. */ + 200: { + content: { + "application/json": components["schemas"]["OAuth2Info"]; + }; + }; + /** @description Validation Error */ + 422: { + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; index_api_folders__folder_id__contents_get: { /** * Returns a list of a folder's contents (files and sub-folders) with additional metadata about the folder. @@ -25675,4 +25720,32 @@ export interface operations { }; }; }; + oauth2_callback_oauth2_callback_get: { + /** Callback entry point for remote resource responses with OAuth2 authorization codes */ + parameters: { + /** @description Base-64 encoded JSON used to route request within Galaxy. */ + query: { + state: string; + code: string; + }; + /** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */ + header?: { + "run-as"?: string | null; + }; + }; + responses: { + /** @description Successful Response */ + 200: { + content: { + "application/json": Record; + }; + }; + /** @description Validation Error */ + 422: { + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; } diff --git a/client/src/components/ConfigTemplates/ConfigurationTestSummary.vue b/client/src/components/ConfigTemplates/ConfigurationTestSummary.vue index be17f1593821..b781c6eae665 100644 --- a/client/src/components/ConfigTemplates/ConfigurationTestSummary.vue +++ b/client/src/components/ConfigTemplates/ConfigurationTestSummary.vue @@ -15,6 +15,9 @@ defineProps();