From b15652c3355a78a6d2822c7c128b3dc75519dd73 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/sources/googledrive.py | 3 + lib/galaxy/files/templates/__init__.py | 4 + .../dropbox_client_secrets_explicit.yml | 7 + .../dropbox_client_secrets_in_vault.yml | 15 ++ .../templates/examples/production_dropbox.yml | 15 ++ .../examples/production_google_drive.yml | 15 ++ lib/galaxy/files/templates/models.py | 89 ++++++++- lib/galaxy/managers/_config_templates.py | 183 +++++++++++++++-- lib/galaxy/managers/file_source_instances.py | 187 ++++++++++++++++-- lib/galaxy/managers/object_store_instances.py | 11 +- lib/galaxy/model/__init__.py | 12 +- lib/galaxy/objectstore/templates/models.py | 5 + lib/galaxy/schema/schema.py | 13 ++ lib/galaxy/util/config_templates.py | 130 ++++++++++++ lib/galaxy/webapps/galaxy/api/file_sources.py | 27 ++- .../webapps/galaxy/api/oauth2_callback.py | 50 +++++ lib/galaxy/work/context.py | 5 + .../app/managers/test_user_file_sources.py | 182 ++++++++++++++++- test/unit/files/test_template_models.py | 3 + test/unit/schema/test_schema.py | 8 + .../util/test_config_template_validation.py | 1 + 41 files changed, 1208 insertions(+), 43 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/files/templates/examples/production_google_drive.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 389a25f52387..80f626297b41 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -332,6 +332,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. @@ -2053,6 +2057,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; @@ -3151,6 +3159,8 @@ export interface components { template_id: string; /** Template Version */ template_version: number; + /** Uuid */ + uuid?: string | null; /** Variables */ variables: { [key: string]: (string | boolean | number) | undefined; @@ -5178,7 +5188,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure"; + type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox" | "googledrive"; /** Variables */ variables?: | ( @@ -9954,6 +9964,11 @@ export interface components { */ updated_count: number; }; + /** OAuth2Info */ + OAuth2Info: { + /** Authorize Url */ + authorize_url: string; + }; /** ObjectExportTaskResponse */ ObjectExportTaskResponse: { /** @@ -10479,6 +10494,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; }; @@ -12790,7 +12806,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure"; + type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox" | "googledrive"; /** Uri Root */ uri_root: string; /** Uuid */ @@ -15178,6 +15194,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. @@ -25626,4 +25671,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();