aspera-cli 4.28.0 → 4.29.1
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/BUGS.md +5 -10
- data/CHANGELOG.md +217 -2
- data/CODE_OF_CONDUCT.md +18 -0
- data/CONTRIBUTING.md +135 -56
- data/GOVERNANCE.md +30 -0
- data/LICENSE +201 -0
- data/README.md +122 -26
- data/SECURITY.md +84 -0
- data/bin/ascli +8 -5
- data/bin/asession +9 -6
- data/docs/README.md +1895 -632
- data/docs/test-mcp-with-ai.md +8 -8
- data/lib/aspera/agent/base.rb +23 -2
- data/lib/aspera/agent/connect.rb +16 -12
- data/lib/aspera/agent/desktop.rb +10 -7
- data/lib/aspera/agent/direct.rb +20 -19
- data/lib/aspera/agent/factory.rb +6 -3
- data/lib/aspera/agent/httpgw.rb +7 -5
- data/lib/aspera/agent/node.rb +15 -7
- data/lib/aspera/agent/transferd.rb +167 -43
- data/lib/aspera/api/alee.rb +4 -1
- data/lib/aspera/api/aoc.rb +14 -11
- data/lib/aspera/api/ats.rb +4 -2
- data/lib/aspera/api/cos_node.rb +7 -4
- data/lib/aspera/api/faspex.rb +16 -9
- data/lib/aspera/api/httpgw.rb +9 -6
- data/lib/aspera/api/node.rb +29 -22
- data/lib/aspera/ascmd.rb +8 -5
- data/lib/aspera/ascp/installation.rb +95 -67
- data/lib/aspera/ascp/log.schema.yaml +1084 -0
- data/lib/aspera/ascp/log_analyzer/advice.rb +97 -0
- data/lib/aspera/ascp/log_analyzer/diagnostics.rb +344 -0
- data/lib/aspera/ascp/log_analyzer/lines.rb +75 -0
- data/lib/aspera/ascp/log_analyzer/log_file.rb +593 -0
- data/lib/aspera/ascp/log_analyzer/records.rb +379 -0
- data/lib/aspera/ascp/log_analyzer/rules.rb +172 -0
- data/lib/aspera/ascp/log_analyzer/session.rb +782 -0
- data/lib/aspera/ascp/log_analyzer.rb +370 -0
- data/lib/aspera/ascp/log_locations.rb +163 -0
- data/lib/aspera/ascp/management.rb +16 -8
- data/lib/aspera/ascp/session_errors.rb +217 -0
- data/lib/aspera/assert.rb +4 -0
- data/lib/aspera/cli/ascp_actions.rb +12 -19
- data/lib/aspera/cli/ascp_logs_actions.rb +188 -0
- data/lib/aspera/cli/async_transfer_store.rb +7 -4
- data/lib/aspera/cli/bootstrapper.rb +38 -33
- data/lib/aspera/cli/command_line.rb +63 -8
- data/lib/aspera/cli/command_registry.rb +9 -1
- data/lib/aspera/cli/command_spec.rb +47 -7
- data/lib/aspera/cli/completion/ascli.bash +19 -5
- data/lib/aspera/cli/completion/ascli.fish +13 -2
- data/lib/aspera/cli/completion/ascli.ps1 +31 -9
- data/lib/aspera/cli/completion/ascli.zsh +22 -6
- data/lib/aspera/cli/completion_actions.rb +303 -69
- data/lib/aspera/cli/context.rb +9 -4
- data/lib/aspera/cli/deprecation.rb +5 -2
- data/lib/aspera/cli/error.rb +6 -0
- data/lib/aspera/cli/extended_value.rb +66 -31
- data/lib/aspera/cli/formatter.rb +43 -30
- data/lib/aspera/cli/gem_checker.rb +9 -6
- data/lib/aspera/cli/hints.rb +22 -10
- data/lib/aspera/cli/http.rb +38 -10
- data/lib/aspera/cli/info.rb +12 -7
- data/lib/aspera/cli/mailer.rb +6 -3
- data/lib/aspera/cli/mcp/http_servlet.rb +7 -8
- data/lib/aspera/cli/mcp/secrets.rb +8 -5
- data/lib/aspera/cli/mcp/tool.rb +20 -17
- data/lib/aspera/cli/option_declarator.rb +10 -4
- data/lib/aspera/cli/option_registry.rb +6 -3
- data/lib/aspera/cli/option_types.rb +17 -2
- data/lib/aspera/cli/option_value.rb +77 -18
- data/lib/aspera/cli/options.schema.yaml +641 -80
- data/lib/aspera/cli/parser.rb +71 -35
- data/lib/aspera/cli/plugins/alee.rb +7 -4
- data/lib/aspera/cli/plugins/aoc.rb +248 -37
- data/lib/aspera/cli/plugins/ats.rb +10 -9
- data/lib/aspera/cli/plugins/base.rb +50 -18
- data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
- data/lib/aspera/cli/plugins/config.rb +210 -104
- data/lib/aspera/cli/plugins/console.rb +6 -3
- data/lib/aspera/cli/plugins/cos.rb +8 -4
- data/lib/aspera/cli/plugins/factory.rb +21 -7
- data/lib/aspera/cli/plugins/faspex5.rb +31 -26
- data/lib/aspera/cli/plugins/faspio.rb +7 -5
- data/lib/aspera/cli/plugins/httpgw.rb +7 -4
- data/lib/aspera/cli/plugins/mcp.rb +42 -22
- data/lib/aspera/cli/plugins/node.rb +39 -38
- data/lib/aspera/cli/plugins/oauth.rb +23 -6
- data/lib/aspera/cli/plugins/orchestrator.rb +287 -83
- data/lib/aspera/cli/plugins/preview.rb +72 -45
- data/lib/aspera/cli/plugins/server.rb +66 -14
- data/lib/aspera/cli/plugins/shares.rb +87 -18
- data/lib/aspera/cli/plugins/transferd.rb +228 -0
- data/lib/aspera/cli/poll.rb +236 -0
- data/lib/aspera/cli/preset_actions.rb +144 -30
- data/lib/aspera/cli/preset_manager.rb +113 -35
- data/lib/aspera/cli/prompt.rb +157 -9
- data/lib/aspera/cli/result.rb +12 -8
- data/lib/aspera/cli/runner.rb +89 -48
- data/lib/aspera/cli/secret_finder.rb +4 -1
- data/lib/aspera/cli/security.rb +89 -9
- data/lib/aspera/cli/special_values.rb +4 -1
- data/lib/aspera/cli/sync_actions.rb +15 -10
- data/lib/aspera/cli/table_fitter.rb +3 -0
- data/lib/aspera/cli/terminal_formatter.rb +9 -6
- data/lib/aspera/cli/transfer_actions.rb +11 -8
- data/lib/aspera/cli/transfer_agent.rb +43 -20
- data/lib/aspera/cli/transfer_progress.rb +14 -45
- data/lib/aspera/cli/vault_actions.rb +45 -0
- data/lib/aspera/cli/vault_manager.rb +188 -42
- data/lib/aspera/cli/version.rb +4 -1
- data/lib/aspera/cli/web_secret.rb +12 -10
- data/lib/aspera/cli/wizard.rb +42 -39
- data/lib/aspera/command_line_builder.rb +9 -5
- data/lib/aspera/command_line_converter.rb +4 -1
- data/lib/aspera/coverage.rb +103 -33
- data/lib/aspera/data_repository.rb +4 -1
- data/lib/aspera/dot_container.rb +4 -1
- data/lib/aspera/environment.rb +23 -12
- data/lib/aspera/exec_spec.rb +3 -0
- data/lib/aspera/faspex_gw.rb +13 -9
- data/lib/aspera/faspex_postproc.rb +15 -12
- data/lib/aspera/formatter_interface.rb +4 -1
- data/lib/aspera/graphql.rb +5 -1
- data/lib/aspera/hash_ext.rb +3 -0
- data/lib/aspera/id_generator.rb +20 -5
- data/lib/aspera/inflate.rb +43 -0
- data/lib/aspera/json_rpc/client.rb +6 -5
- data/lib/aspera/json_rpc/version.rb +3 -0
- data/lib/aspera/line_logger.rb +4 -1
- data/lib/aspera/link_header.rb +4 -1
- data/lib/aspera/log.rb +18 -5
- data/lib/aspera/markdown.rb +5 -2
- data/lib/aspera/mime.rb +3 -0
- data/lib/aspera/nagios.rb +6 -4
- data/lib/aspera/node_emulator.rb +15 -13
- data/lib/aspera/oauth/client/base.rb +124 -73
- data/lib/aspera/oauth/client/boot.rb +7 -4
- data/lib/aspera/oauth/client/factory.rb +41 -18
- data/lib/aspera/oauth/client/generic.rb +5 -1
- data/lib/aspera/oauth/client/json_credentials.rb +7 -3
- data/lib/aspera/oauth/client/jwt.rb +6 -3
- data/lib/aspera/oauth/client/shares_web.rb +94 -0
- data/lib/aspera/oauth/client/url_json.rb +7 -3
- data/lib/aspera/oauth/client/web.rb +40 -13
- data/lib/aspera/oauth/server/pkce.rb +6 -5
- data/lib/aspera/orchestrator_workflow_checker.rb +129 -2
- data/lib/aspera/persistency_action_once.rb +5 -3
- data/lib/aspera/persistency_folder.rb +6 -3
- data/lib/aspera/preview/file_types.rb +6 -3
- data/lib/aspera/preview/generator.rb +9 -5
- data/lib/aspera/preview/options.schema.yaml +3 -3
- data/lib/aspera/preview/terminal.rb +16 -6
- data/lib/aspera/preview/utils.rb +6 -4
- data/lib/aspera/products/connect.rb +5 -2
- data/lib/aspera/products/desktop.rb +17 -2
- data/lib/aspera/products/other.rb +4 -2
- data/lib/aspera/products/transferd.rb +6 -2
- data/lib/aspera/products/transferd_service.rb +610 -0
- data/lib/aspera/proxy_auto_config.js +2 -2
- data/lib/aspera/proxy_auto_config.rb +5 -2
- data/lib/aspera/rainbow.rb +3 -0
- data/lib/aspera/rest/aspera_errors.rb +4 -1
- data/lib/aspera/rest/call_error.rb +3 -0
- data/lib/aspera/rest/client.rb +45 -34
- data/lib/aspera/rest/error_analyzer.rb +5 -2
- data/lib/aspera/rest/list.rb +8 -4
- data/lib/aspera/rest/parameters.rb +3 -0
- data/lib/aspera/rest/util.rb +8 -5
- data/lib/aspera/rest.rb +9 -6
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -9
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +118 -30
- data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +11 -11
- data/lib/aspera/schema/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +2437 -1437
- data/lib/aspera/schema/async_tables.yaml +11 -10
- data/lib/aspera/schema/documentation.rb +8 -2
- data/lib/aspera/schema/reader.rb +7 -0
- data/lib/aspera/schema/registry.rb +44 -28
- data/lib/aspera/schema/transferd-config.schema.json +333 -0
- data/lib/aspera/schema/validator.rb +4 -1
- data/lib/aspera/sealed_hash.rb +150 -0
- data/lib/aspera/secret/hider.rb +213 -0
- data/lib/aspera/secret/reference.rb +150 -0
- data/lib/aspera/secret/resolver.rb +212 -0
- data/lib/aspera/secret/store/base.rb +153 -0
- data/lib/aspera/secret/store/encrypted_hash.rb +329 -0
- data/lib/aspera/secret/store/factory.rb +103 -0
- data/lib/aspera/secret/store/hashicorp_vault.rb +390 -0
- data/lib/aspera/secret/store/keeper.rb +141 -0
- data/lib/aspera/secret/store/macos_security.rb +284 -0
- data/lib/aspera/secret/store/one_password_api.rb +99 -0
- data/lib/aspera/secret/store/one_password_base.rb +42 -0
- data/lib/aspera/secret/store/one_password_cli.rb +112 -0
- data/lib/aspera/secret/store/secret_service.rb +125 -0
- data/lib/aspera/secret/strength.rb +119 -0
- data/lib/aspera/servlet_helpers.rb +5 -2
- data/lib/aspera/ssh.rb +10 -7
- data/lib/aspera/ssl.rb +5 -2
- data/lib/aspera/string_ext.rb +3 -0
- data/lib/aspera/sync/args.schema.yaml +3 -0
- data/lib/aspera/sync/conf.schema.yaml +9 -4
- data/lib/aspera/sync/database.rb +3 -0
- data/lib/aspera/sync/operations.rb +17 -15
- data/lib/aspera/temp_file_manager.rb +8 -4
- data/lib/aspera/timer_limiter.rb +3 -0
- data/lib/aspera/transfer/error.rb +4 -1
- data/lib/aspera/transfer/faux_file.rb +4 -1
- data/lib/aspera/transfer/parameters.rb +17 -14
- data/lib/aspera/transfer/result.rb +23 -0
- data/lib/aspera/transfer/resumer.rb +6 -4
- data/lib/aspera/transfer/spec.rb +9 -22
- data/lib/aspera/units/decimal.rb +67 -0
- data/lib/aspera/units/duration.rb +109 -0
- data/lib/aspera/uri_reader.rb +64 -9
- data/lib/aspera/web_auth/index.html.erb +6 -2
- data/lib/aspera/web_auth/paste.rb +109 -0
- data/lib/aspera/web_auth/receiver.rb +50 -0
- data/lib/aspera/web_auth/relay.rb +76 -0
- data/lib/aspera/web_auth/reply.html.erb +150 -0
- data/lib/aspera/web_auth/server.rb +47 -10
- data/lib/aspera/web_page.rb +7 -2
- data/lib/aspera/web_server_simple.rb +6 -3
- data/lib/aspera/yaml.rb +5 -1
- data/llms-install.md +88 -0
- data/llms.txt +87 -0
- data/skills/ascli/SKILL.md +94 -0
- data.tar.gz.sig +0 -0
- metadata +77 -20
- metadata.gz.sig +0 -0
- data/lib/aspera/duration.rb +0 -42
- data/lib/aspera/keychain/base.rb +0 -30
- data/lib/aspera/keychain/encrypted_hash.rb +0 -192
- data/lib/aspera/keychain/factory.rb +0 -58
- data/lib/aspera/keychain/hashicorp_vault.rb +0 -77
- data/lib/aspera/keychain/macos_security.rb +0 -277
- data/lib/aspera/keychain/one_password_api.rb +0 -91
- data/lib/aspera/keychain/one_password_base.rb +0 -39
- data/lib/aspera/keychain/one_password_cli.rb +0 -100
- data/lib/aspera/secret_hider.rb +0 -196
- data/lib/aspera/secret_strength.rb +0 -114
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../assert'
|
|
7
|
+
require_relative '../error'
|
|
8
|
+
require_relative '../security'
|
|
9
|
+
require_relative '../../environment'
|
|
10
|
+
require_relative '../../string_ext'
|
|
3
11
|
require 'singleton'
|
|
4
|
-
require 'aspera/assert'
|
|
5
|
-
require 'aspera/cli/error'
|
|
6
|
-
require 'aspera/environment'
|
|
7
|
-
require 'aspera/string_ext'
|
|
8
12
|
|
|
9
13
|
module Aspera
|
|
10
14
|
module Cli
|
|
@@ -20,6 +24,8 @@ module Aspera
|
|
|
20
24
|
|
|
21
25
|
def initialize
|
|
22
26
|
@lookup_folders = []
|
|
27
|
+
# Security level (see `Security`) of each folder: a plugin is code
|
|
28
|
+
@folder_security = {}
|
|
23
29
|
# information on plugins
|
|
24
30
|
@plugins = {}
|
|
25
31
|
end
|
|
@@ -31,8 +37,12 @@ module Aspera
|
|
|
31
37
|
|
|
32
38
|
# add a folder to the list of folders to look for plugins
|
|
33
39
|
# (absolute, as `require` resolves a relative path against $LOAD_PATH)
|
|
34
|
-
|
|
40
|
+
# @param folder [String] Folder
|
|
41
|
+
# @param security [Symbol, nil] Most restrictive security level at which plugins of this folder are used, `nil` for all levels (folder of the gem).
|
|
42
|
+
# A folder that a user or a client can write is `:low`: a file written there would be loaded as code.
|
|
43
|
+
def add_lookup_folder(folder, security: nil)
|
|
35
44
|
folder = File.expand_path(folder)
|
|
45
|
+
@folder_security[folder] = security
|
|
36
46
|
@lookup_folders.unshift(folder) unless @lookup_folders.include?(folder)
|
|
37
47
|
end
|
|
38
48
|
|
|
@@ -40,6 +50,8 @@ module Aspera
|
|
|
40
50
|
def add_plugins_from_lookup_folders
|
|
41
51
|
@lookup_folders.each do |folder|
|
|
42
52
|
next unless File.directory?(folder)
|
|
53
|
+
# Plugins registered at start (level low) stay, but files that appear later are not
|
|
54
|
+
next unless Security.instance.allowed?(@folder_security[folder])
|
|
43
55
|
# TODO: add gem root to load path ? and require short folder ?
|
|
44
56
|
# $LOAD_PATH.push(folder) if i[:add_path]
|
|
45
57
|
Dir.children(folder).each do |source|
|
|
@@ -49,7 +61,7 @@ module Aspera
|
|
|
49
61
|
next if IGNORE_PLUGINS.include?(plugin_symbol)
|
|
50
62
|
req = path.sub(/#{Environment::RB_EXT}$/o, '')
|
|
51
63
|
next if @plugins.key?(plugin_symbol)
|
|
52
|
-
@plugins[plugin_symbol] = {source: path, require_stanza: req}
|
|
64
|
+
@plugins[plugin_symbol] = {source: path, require_stanza: req, security: @folder_security[folder]}
|
|
53
65
|
end
|
|
54
66
|
end
|
|
55
67
|
end
|
|
@@ -63,6 +75,8 @@ module Aspera
|
|
|
63
75
|
# @return [Class] class object for plugin
|
|
64
76
|
def plugin_class(plugin_name_sym)
|
|
65
77
|
Aspera.assert(@plugins.key?(plugin_name_sym), type: NoSuchElement) { "plugin not found: #{plugin_name_sym}" }
|
|
78
|
+
# A plugin registered at start can be replaced by a file written since: it is code
|
|
79
|
+
Security.instance.check_level(@plugins[plugin_name_sym][:security], "plugin #{plugin_name_sym}")
|
|
66
80
|
require @plugins[plugin_name_sym][:require_stanza]
|
|
67
81
|
# Module.nesting[1] is Aspera::Cli::Plugins
|
|
68
82
|
return Object.const_get("#{Module.nesting[1]}::#{plugin_name_sym.to_s.snake_to_capital}")
|
|
@@ -76,7 +90,7 @@ module Aspera
|
|
|
76
90
|
plugin_class(plugin_name_sym).new(**args)
|
|
77
91
|
end
|
|
78
92
|
|
|
79
|
-
IGNORE_PLUGINS = %i[factory base basic_auth oauth]
|
|
93
|
+
IGNORE_PLUGINS = %i[factory base basic_auth oauth].freeze
|
|
80
94
|
private_constant :IGNORE_PLUGINS
|
|
81
95
|
end
|
|
82
96
|
end
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
3
6
|
# spellchecker: ignore workgroups mypackages passcode
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
require_relative '../../schema/registry'
|
|
9
|
+
require_relative 'oauth'
|
|
10
|
+
require_relative '../extended_value'
|
|
11
|
+
require_relative '../formatter'
|
|
12
|
+
require_relative '../../transfer/result'
|
|
13
|
+
require_relative '../special_values'
|
|
14
|
+
require_relative '../wizard'
|
|
15
|
+
require_relative '../../api/faspex'
|
|
16
|
+
require_relative '../../persistency_action_once'
|
|
17
|
+
require_relative '../../id_generator'
|
|
18
|
+
require_relative '../../nagios'
|
|
19
|
+
require_relative '../../environment'
|
|
20
|
+
require_relative '../../assert'
|
|
21
|
+
require_relative '../../rainbow'
|
|
18
22
|
require 'securerandom'
|
|
19
23
|
require 'digest'
|
|
20
24
|
require 'json'
|
|
21
|
-
require 'aspera/rainbow'
|
|
22
25
|
using Rainbow
|
|
23
26
|
|
|
24
27
|
module Aspera
|
|
@@ -79,7 +82,7 @@ module Aspera
|
|
|
79
82
|
end
|
|
80
83
|
wiz_username = options.get_option(:username, mandatory: true)
|
|
81
84
|
wizard.check_email(wiz_username)
|
|
82
|
-
|
|
85
|
+
private_key = wizard.ask_private_key(
|
|
83
86
|
user: wiz_username,
|
|
84
87
|
url: app_url,
|
|
85
88
|
page: [Environment.char('👤'), 'Account Settings', 'Preferences', 'Public Key in PEM']
|
|
@@ -90,7 +93,7 @@ module Aspera
|
|
|
90
93
|
url: app_url,
|
|
91
94
|
username: wiz_username,
|
|
92
95
|
auth: :jwt.to_s,
|
|
93
|
-
private_key:
|
|
96
|
+
private_key: private_key,
|
|
94
97
|
client_id: client_id,
|
|
95
98
|
client_secret: client_secret
|
|
96
99
|
},
|
|
@@ -109,9 +112,8 @@ module Aspera
|
|
|
109
112
|
Aspera.assert_type(parameters[type], Array) { type }
|
|
110
113
|
recipient_types = Api::Faspex::RECIPIENT_TYPES
|
|
111
114
|
if parameters.key?('recipient_types')
|
|
112
|
-
recipient_types = parameters
|
|
113
|
-
|
|
114
|
-
recipient_types = [recipient_types] unless recipient_types.is_a?(Array)
|
|
115
|
+
recipient_types = Array(parameters.delete('recipient_types'))
|
|
116
|
+
Aspera.assert_array_all(recipient_types, String) { 'recipient_types' }
|
|
115
117
|
end
|
|
116
118
|
parameters[type].map! do |recipient_data|
|
|
117
119
|
# If just a string, make a general lookup and build expected name/type hash
|
|
@@ -251,7 +253,7 @@ module Aspera
|
|
|
251
253
|
Log.dump(:package_ids, level: :trace1) { packages.map { |p| p['id'] } }
|
|
252
254
|
else
|
|
253
255
|
# a single id was provided, or a list of ids
|
|
254
|
-
package_ids =
|
|
256
|
+
package_ids = Array(package_ids)
|
|
255
257
|
Aspera.assert_array_all(package_ids, String) { 'Package id(s)' }
|
|
256
258
|
# packages = package_ids.map{|pkg_id|api_v5.read("packages/#{pkg_id}")}
|
|
257
259
|
packages = package_ids.map { |pkg_id| {'id'=>pkg_id} }
|
|
@@ -297,6 +299,8 @@ module Aspera
|
|
|
297
299
|
end
|
|
298
300
|
|
|
299
301
|
def package_send(parameters)
|
|
302
|
+
# The package is created before the transfer
|
|
303
|
+
transfer.assert_no_dry_run
|
|
300
304
|
# autofill recipient for public url
|
|
301
305
|
if api_v5.pub_link_context&.key?('recipient_type') && !parameters.key?('recipients')
|
|
302
306
|
parameters['recipients'] = [{
|
|
@@ -497,7 +501,7 @@ module Aspera
|
|
|
497
501
|
|
|
498
502
|
# :health and :postprocessing work without authentication: they do not use api_v5.
|
|
499
503
|
command :health, description: 'Check Faspex 5 health'
|
|
500
|
-
command :version, description: 'Show Faspex 5 version', action: ->(**) { Result::SingleObject.new(api_v5.read('version')) }
|
|
504
|
+
command :version, read_only: true, description: 'Show Faspex 5 version', action: ->(**) { Result::SingleObject.new(api_v5.read('version')) }
|
|
501
505
|
command :bearer_token, description: 'Show OAuth bearer token', action: ->(**) { Result::Text.new(api_v5.oauth.authorization) }
|
|
502
506
|
# Package id argument; with a public link to a package, setup_package_id provides it instead
|
|
503
507
|
PACKAGE_ID_ARG = [{name: :package_id, type: :identifier}].freeze
|
|
@@ -530,7 +534,7 @@ module Aspera
|
|
|
530
534
|
command :shared_folders, description: 'Browse shared folders'
|
|
531
535
|
command :gateway, description: 'Start Faspex 4 gateway emulation',
|
|
532
536
|
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: Schema::Registry::GATEWAY_OPTIONS}]
|
|
533
|
-
command :postprocessing, description: 'Start Faspex 4 post-processing server',
|
|
537
|
+
command :postprocessing, description: 'Start Faspex 4 post-processing server', security: :low,
|
|
534
538
|
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: Schema::Registry::POSTPROC_OPTIONS}]
|
|
535
539
|
command :invitations, description: 'Manage invitations'
|
|
536
540
|
|
|
@@ -833,7 +837,8 @@ module Aspera
|
|
|
833
837
|
# @param users [Array] raw user ids or percent-selector strings
|
|
834
838
|
# @return [Array<String>] resolved user ids
|
|
835
839
|
def resolve_member_user_ids(users)
|
|
836
|
-
users =
|
|
840
|
+
users = Array(users)
|
|
841
|
+
Aspera.assert_array_all(users, String) { 'users' }
|
|
837
842
|
users.map do |user|
|
|
838
843
|
if (m = Parser.percent_selector(user))
|
|
839
844
|
api_v5.lookup_entity_by_field(entity: 'accounts', field: m[:field], value: m[:value], query: Rest.php_style({type: ACCOUNT_TYPES}))['id']
|
|
@@ -977,20 +982,20 @@ module Aspera
|
|
|
977
982
|
end
|
|
978
983
|
|
|
979
984
|
def action_gateway(parameters: {}, **)
|
|
980
|
-
|
|
985
|
+
require_relative '../../faspex_gw'
|
|
981
986
|
Faspex4GWServlet.serve(parameters.symbolize_keys, type: Cli::BadArgument) { [api_v5, nil] }
|
|
982
987
|
Result::Status.new('Gateway terminated')
|
|
983
988
|
end
|
|
984
989
|
|
|
985
990
|
def action_postprocessing(parameters: {}, **)
|
|
986
|
-
|
|
991
|
+
require_relative '../../faspex_postproc'
|
|
987
992
|
Faspex4PostProcServlet.serve(parameters.symbolize_keys, type: Cli::BadArgument)
|
|
988
993
|
Result::Status.new('Post-processing terminated')
|
|
989
994
|
end
|
|
990
995
|
ACCOUNT_TYPES = %w{local_user saml_user self_registered_user external_user}.freeze
|
|
991
996
|
WORKGROUP_TYPES = %w{workgroup shared_inbox}.freeze
|
|
992
997
|
CONTACT_TYPES = (WORKGROUP_TYPES + %w{distribution_list user external_user}).freeze
|
|
993
|
-
PACKAGE_RECIPIENT_TYPES = %i{recipients private_recipients notified_on_upload notified_on_download notified_on_receipt}
|
|
998
|
+
PACKAGE_RECIPIENT_TYPES = %i{recipients private_recipients notified_on_upload notified_on_download notified_on_receipt}.freeze
|
|
994
999
|
private_constant :ACCOUNT_TYPES, :CONTACT_TYPES, :PACKAGE_RECIPIENT_TYPES,
|
|
995
1000
|
:CRUD_NO_SHOW, :CRUD_NO_LIST
|
|
996
1001
|
end
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../rest'
|
|
7
|
+
require_relative '../../nagios'
|
|
8
|
+
require_relative 'basic_auth'
|
|
6
9
|
|
|
7
10
|
module Aspera
|
|
8
11
|
module Cli
|
|
@@ -46,8 +49,7 @@ module Aspera
|
|
|
46
49
|
when :jwt
|
|
47
50
|
client_id = options.get_option(:client_id, mandatory: true)
|
|
48
51
|
preset_value[:client_id] = client_id
|
|
49
|
-
|
|
50
|
-
preset_value[:private_key] = key_path ? "@file:#{key_path}" : options.get_option(:private_key, mandatory: true)
|
|
52
|
+
preset_value[:private_key] = options.get_option(:private_key, mandatory: true)
|
|
51
53
|
passphrase = options.get_option(:passphrase)
|
|
52
54
|
preset_value[:passphrase] = passphrase unless passphrase.nil?
|
|
53
55
|
preset_ids.push(client_id)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'base'
|
|
7
|
+
require_relative '../../rest'
|
|
8
|
+
require_relative '../../api/httpgw'
|
|
9
|
+
require_relative '../../nagios'
|
|
7
10
|
|
|
8
11
|
module Aspera
|
|
9
12
|
module Cli
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
require_relative 'base'
|
|
7
|
+
require_relative '../info'
|
|
8
|
+
require_relative '../version'
|
|
9
|
+
require_relative '../../oauth/server/pkce'
|
|
10
|
+
require_relative '../security'
|
|
11
|
+
require_relative '../deprecation'
|
|
12
|
+
require_relative '../../secret/strength'
|
|
12
13
|
require 'securerandom'
|
|
13
14
|
|
|
14
15
|
module Aspera
|
|
@@ -96,19 +97,38 @@ module Aspera
|
|
|
96
97
|
cleanup → ["config", "transfer", "cleanup"]
|
|
97
98
|
|
|
98
99
|
ORCHESTRATOR WORKFLOW DEVELOPMENT
|
|
99
|
-
Before writing or modifying an Orchestrator workflow, read the
|
|
100
|
-
|
|
101
|
-
["orchestrator", "workflows", "development", "authoring"]
|
|
100
|
+
Before writing or modifying an Orchestrator workflow, read the development guide (large: read
|
|
101
|
+
sections, not the whole document). Start with the sections "quick-start" and "authoring-checklist":
|
|
102
|
+
["orchestrator", "workflows", "development", "guide", "section", "authoring-checklist"]
|
|
103
|
+
then the sections you need (file format, graph, inputs of steps, execution, recipes, known issues):
|
|
104
|
+
"workflow-file", "graph-xml", "inputs-of-a-step", "execution", "recipes", "known-issues".
|
|
105
|
+
Command "toc" lists the anchors of the sections of a document, up to a default level, or the level
|
|
106
|
+
given after it:
|
|
107
|
+
["orchestrator", "workflows", "development", "guide", "toc"]
|
|
102
108
|
For the template attributes (allowed values), inputs and outputs of an action plugin, and the
|
|
103
109
|
template settings they depend on, read its specification (fields: section "plugin-specifications"
|
|
104
|
-
of the
|
|
105
|
-
["orchestrator", "plugins", "spec", "<PluginClass>"]
|
|
110
|
+
of the development guide); the list of plugins is given by ["orchestrator", "plugins", "spec", "toc"]:
|
|
111
|
+
["orchestrator", "plugins", "spec", "show", "<PluginClass>"]
|
|
106
112
|
For the functional description and the setup of a plugin (for example the API client of Faspex),
|
|
107
|
-
read its section of the Plugin Manual (large: read one section)
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
read its section of the Plugin Manual (large: read one section only). The anchor of the section is
|
|
114
|
+
field "manual_anchor" of the specification of the plugin (also in the list of plugins):
|
|
115
|
+
["orchestrator", "workflows", "development", "manual", "section", "<manual_anchor>"]
|
|
110
116
|
Before importing a workflow file, check it (graph, templates, inputs of steps) and fix all errors:
|
|
111
117
|
["orchestrator", "workflows", "check_import", "<file>"]
|
|
118
|
+
|
|
119
|
+
AOC AUTOMATION WORKFLOW DEVELOPMENT
|
|
120
|
+
Before writing or modifying an Aspera on Cloud Automation workflow, read the development guide
|
|
121
|
+
(large: read sections, not the whole document). Start with the section of each trigger and action
|
|
122
|
+
used (for example "Send a package" is action type package_transfer, section "package-transfer"),
|
|
123
|
+
then "payload-rules-enforced-by-the-api" and "finding-the-identifiers":
|
|
124
|
+
["aoc", "automation", "guide", "section", "package-transfer"]
|
|
125
|
+
Other sections: "triggers", "actions", "substitution-variables", "importing-a-workflow",
|
|
126
|
+
"design-recipes-and-patterns", "common-pitfalls-and-resolutions". List the anchors with:
|
|
127
|
+
["aoc", "automation", "guide", "toc"]
|
|
128
|
+
|
|
129
|
+
GENERAL GUIDANCE
|
|
130
|
+
For the general rules of use of ascli by an AI (written for a shell: each command line maps to args):
|
|
131
|
+
["config", "skill"]
|
|
112
132
|
INST
|
|
113
133
|
|
|
114
134
|
# Keys forwarded to MCP::Server constructor (symbolized)
|
|
@@ -136,8 +156,8 @@ module Aspera
|
|
|
136
156
|
arguments: [{name: :mcp_options, type: [Hash], mandatory: false, schema: 'opts:components.schemas.McpServerOptions'}]
|
|
137
157
|
|
|
138
158
|
def action_server(mcp_options: nil, **)
|
|
139
|
-
|
|
140
|
-
|
|
159
|
+
require_relative '../mcp/tool'
|
|
160
|
+
require_relative '../extended_value'
|
|
141
161
|
mcp_options = (mcp_options || {}).transform_keys(&:to_sym)
|
|
142
162
|
unknown = mcp_options.keys - SERVER_KEYS - CONFIG_KEYS - STDIO_KEYS - HTTP_KEYS - HTTP_SERVER_KEYS - TOOL_KEYS - %i[transport]
|
|
143
163
|
Aspera.assert(unknown.empty?, type: Cli::BadArgument) { "Unknown MCP option(s): #{unknown.join(', ')}" }
|
|
@@ -241,16 +261,16 @@ module Aspera
|
|
|
241
261
|
# On an address that is not loopback, `auth_token` is mandatory, also with OAuth:
|
|
242
262
|
# it is the secret asked on the consent page, else anyone could approve its own client.
|
|
243
263
|
def start_http_transport(server, mcp_options)
|
|
244
|
-
|
|
245
|
-
|
|
264
|
+
require_relative '../mcp/http_servlet'
|
|
265
|
+
require_relative '../../web_server_simple'
|
|
246
266
|
parameters = http_server_parameters(mcp_options)
|
|
247
267
|
uri = WebServerSimple.url(parameters)
|
|
248
268
|
auth_token = mcp_options[:auth_token]
|
|
249
269
|
oauth_enabled = mcp_options.fetch(:oauth, false)
|
|
250
270
|
access_token_ttl = mcp_options.fetch(:oauth_access_token_ttl, OAuth::Server::Pkce.default_access_token_ttl)
|
|
251
271
|
refresh_token_ttl = mcp_options.fetch(:oauth_refresh_token_ttl, OAuth::Server::Pkce.default_refresh_token_ttl)
|
|
252
|
-
min_bits = mcp_options.fetch(:auth_token_min_bits,
|
|
253
|
-
|
|
272
|
+
min_bits = mcp_options.fetch(:auth_token_min_bits, Secret::Strength::DEFAULT_MIN_BITS)
|
|
273
|
+
Secret::Strength.assert_strong(auth_token, name: 'auth_token', min_bits: min_bits, type: Cli::BadArgument) unless auth_token.nil?
|
|
254
274
|
base_url = http_base_url(uri, mcp_options[:public_url], oauth_enabled)
|
|
255
275
|
what = "auth_token#{' (asked on the consent page)' if oauth_enabled}"
|
|
256
276
|
# Clients reach the server at public_url (e.g. through a reverse proxy), whatever the address it listens on
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
# cspell:ignore asperabrowserurl
|
|
7
|
+
require_relative '../../schema/registry'
|
|
8
|
+
require_relative '../../sealed_hash'
|
|
9
|
+
require_relative 'basic_auth'
|
|
10
|
+
require_relative '../sync_actions'
|
|
11
|
+
require_relative '../special_values'
|
|
12
|
+
require_relative '../../transfer/spec'
|
|
13
|
+
require_relative '../../nagios'
|
|
14
|
+
require_relative '../../hash_ext'
|
|
15
|
+
require_relative '../../id_generator'
|
|
16
|
+
require_relative '../../api/node'
|
|
17
|
+
require_relative '../../oauth/client/factory'
|
|
18
|
+
require_relative '../../rest/list'
|
|
19
|
+
require_relative '../../assert'
|
|
16
20
|
require 'base64'
|
|
17
|
-
require 'zlib'
|
|
18
21
|
|
|
19
22
|
module Aspera
|
|
20
23
|
module Cli
|
|
@@ -73,7 +76,7 @@ module Aspera
|
|
|
73
76
|
# DSL option declarations - at class level, picked up by Base#initialize via ancestor chain.
|
|
74
77
|
# Included by other plugins (Ats, Cos, Aoc) via `use_options Node`.
|
|
75
78
|
option :validator, description: 'Identifier of validator (optional for central)'
|
|
76
|
-
option :asperabrowserurl, description: 'URL
|
|
79
|
+
option :asperabrowserurl, description: 'URL of Aspera Browser, web application to browse the node', default: 'https://laurent-martin.github.io/aspera-browser-react/'
|
|
77
80
|
option :node_api, description: 'Gen4: standard_ports: Use standard FASP ports (true) or get from node API (false). cache: Set to false to force actual file system read',
|
|
78
81
|
allowed: Hash, on_set: Api::Node.method(:api_options=)
|
|
79
82
|
option :root_id, description: 'Gen4: File id of top folder when using access key (override AK root id)'
|
|
@@ -126,7 +129,7 @@ module Aspera
|
|
|
126
129
|
spec: {description: 'Show transfer spec base'},
|
|
127
130
|
api_details: {description: 'Show API details'},
|
|
128
131
|
health: {description: 'Check node health'},
|
|
129
|
-
events: {description: 'List events'},
|
|
132
|
+
events: {description: 'List events', read_only: true},
|
|
130
133
|
info: {description: 'Show node info'},
|
|
131
134
|
slash: {description: 'Show root info'},
|
|
132
135
|
license: {description: 'Show license'},
|
|
@@ -153,7 +156,7 @@ module Aspera
|
|
|
153
156
|
modify: {description: 'Modify file', arguments: [{name: :path}, {name: :file, type: Hash, schema: 'node:components.schemas.files-id-put-request'}]},
|
|
154
157
|
cat: {description: 'Show file contents', arguments: SINGLE_PATH_ARG},
|
|
155
158
|
show: {description: 'Show file info', arguments: SINGLE_PATH_ARG},
|
|
156
|
-
thumbnail: {description: 'Show file thumbnail', arguments: SINGLE_PATH_ARG},
|
|
159
|
+
thumbnail: {description: 'Show file thumbnail', arguments: SINGLE_PATH_ARG, read_only: true},
|
|
157
160
|
bearer_token_node: {description: 'Show bearer token for file node', arguments: SINGLE_PATH_ARG},
|
|
158
161
|
node_info: {description: 'Show node info for file', arguments: SINGLE_PATH_ARG},
|
|
159
162
|
ls: {description: 'List files', arguments: SINGLE_PATH_ARG, aliases: [:browse]},
|
|
@@ -451,19 +454,19 @@ module Aspera
|
|
|
451
454
|
Result::Status.new('Done')
|
|
452
455
|
end
|
|
453
456
|
)
|
|
454
|
-
command :bandwidth, description: 'Show sync bandwidth',
|
|
457
|
+
command :bandwidth, read_only: true, description: 'Show sync bandwidth',
|
|
455
458
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
456
459
|
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/bandwidth", query_read_delete(default: {}))) }
|
|
457
|
-
command :counters, description: 'Show sync counters',
|
|
460
|
+
command :counters, read_only: true, description: 'Show sync counters',
|
|
458
461
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
459
462
|
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/counters", query_read_delete(default: {}))) }
|
|
460
|
-
command :files, description: 'List sync files',
|
|
463
|
+
command :files, read_only: true, description: 'List sync files',
|
|
461
464
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
462
465
|
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/files", query_read_delete(default: {}))) }
|
|
463
|
-
command :state, description: 'Show sync state',
|
|
466
|
+
command :state, read_only: true, description: 'Show sync state',
|
|
464
467
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
465
468
|
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/state")) }
|
|
466
|
-
command :summary, description: 'Show sync summary',
|
|
469
|
+
command :summary, read_only: true, description: 'Show sync summary',
|
|
467
470
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
468
471
|
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/summary")) }
|
|
469
472
|
end
|
|
@@ -558,7 +561,7 @@ module Aspera
|
|
|
558
561
|
Result::Status.new("#{watch_folder_id} deleted")
|
|
559
562
|
end
|
|
560
563
|
)
|
|
561
|
-
command :state, description: 'Show watch folder state',
|
|
564
|
+
command :state, read_only: true, description: 'Show watch folder state',
|
|
562
565
|
arguments: [{name: :watch_folder_id, type: :identifier}],
|
|
563
566
|
action: ->(watch_folder_id:, **) { Result::SingleObject.new(api_node.read("v3/watchfolders/#{watch_folder_id}/state")) }
|
|
564
567
|
end
|
|
@@ -579,7 +582,7 @@ module Aspera
|
|
|
579
582
|
arguments: [{name: :file, type: Hash, mandatory: false, default: nil}]
|
|
580
583
|
end
|
|
581
584
|
# Standalone leaf commands
|
|
582
|
-
command :asperabrowser, description: 'Open Aspera
|
|
585
|
+
command :asperabrowser, description: 'Open Aspera Browser on this node (the password is optional: it is then entered in the application)'
|
|
583
586
|
command :basic_token, description: 'Generate basic auth token', action: ->(**) { Result::Text.new(Rest.basic_authorization(options.get_option(:username, mandatory: true), options.get_option(:password, mandatory: true))) }
|
|
584
587
|
command(
|
|
585
588
|
:bearer_token, description: 'Generate bearer token',
|
|
@@ -777,7 +780,7 @@ module Aspera
|
|
|
777
780
|
# access_keys > do > show
|
|
778
781
|
def action_access_keys_do_show(path:, do_root_file_id:, **)
|
|
779
782
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
780
|
-
Result::SingleObject.new(apifid.node_api.read("files/#{apifid.file_id}"))
|
|
783
|
+
Result::SingleObject.new(apifid.node_api.read("files/#{apifid.file_id}", headers: Api::Node.add_cache_control))
|
|
781
784
|
end
|
|
782
785
|
|
|
783
786
|
# access_keys > do > modify
|
|
@@ -790,7 +793,7 @@ module Aspera
|
|
|
790
793
|
# access_keys > do > thumbnail
|
|
791
794
|
def action_access_keys_do_thumbnail(path:, do_root_file_id:, **)
|
|
792
795
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
793
|
-
Result::Image.new(apifid.node_api.read("files/#{apifid.file_id}/preview", headers: {'Accept' => 'image/png'}, ret: :resp).body)
|
|
796
|
+
Result::Image.new(apifid.node_api.read("files/#{apifid.file_id}/preview", headers: Api::Node.add_cache_control({'Accept' => 'image/png'}), ret: :resp).body)
|
|
794
797
|
end
|
|
795
798
|
|
|
796
799
|
# access_keys > do > rename
|
|
@@ -1122,19 +1125,19 @@ module Aspera
|
|
|
1122
1125
|
def action_asperabrowser(**)
|
|
1123
1126
|
browse_params = {
|
|
1124
1127
|
'nodeUser' => options.get_option(:username, mandatory: true),
|
|
1125
|
-
'nodePW' => options.get_option(:password
|
|
1128
|
+
'nodePW' => options.get_option(:password),
|
|
1126
1129
|
'nodeURL' => options.get_option(:url, mandatory: true)
|
|
1127
|
-
}
|
|
1128
|
-
#
|
|
1129
|
-
encoded_params =
|
|
1130
|
-
Environment.instance.open_uri("#{options.get_option(:asperabrowserurl)}
|
|
1130
|
+
}.reject { |_key, value| value.to_s.empty? }
|
|
1131
|
+
# Not encrypted (decoded by the web application), in the fragment: it is not sent to the web server
|
|
1132
|
+
encoded_params = SealedHash.seal(browse_params, encrypt: false, reverse: true)
|
|
1133
|
+
Environment.instance.open_uri("#{options.get_option(:asperabrowserurl)}##{URI.encode_www_form(goto: encoded_params)}")
|
|
1131
1134
|
return Result::Status.new('done')
|
|
1132
1135
|
end
|
|
1133
1136
|
|
|
1134
1137
|
def action_emulator(parameters: {}, **)
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
+
require_relative '../../secret/strength'
|
|
1139
|
+
require_relative '../../web_server_simple'
|
|
1140
|
+
require_relative '../../node_emulator'
|
|
1138
1141
|
# missing parameters take the default of the schema
|
|
1139
1142
|
defaults = Schema::Registry.instance.reader(Schema::Registry::NODE_EMULATOR_OPTIONS).current['properties'].each_with_object({}) do |(name, property), result|
|
|
1140
1143
|
result[name.to_sym] = property['default'] if property.key?('default')
|
|
@@ -1145,7 +1148,7 @@ module Aspera
|
|
|
1145
1148
|
retention_sec = config.delete(:retention_sec)
|
|
1146
1149
|
password_min_bits = config.delete(:password_min_bits)
|
|
1147
1150
|
Aspera.assert(config[:username].nil? == config[:password].nil?, type: Cli::BadArgument) { 'Parameters username and password must be set together' }
|
|
1148
|
-
|
|
1151
|
+
Secret::Strength.assert_strong(config[:password], name: 'password', min_bits: password_min_bits, type: Cli::BadArgument) unless config[:password].nil?
|
|
1149
1152
|
# Files of the docroot can be sent to, or received from, any host by anyone who can reach the server
|
|
1150
1153
|
WebServerSimple.serve(parameters, NodeEmulatorServlet, protected: !config[:username].nil?, what: 'username and password', type: Cli::BadArgument) do
|
|
1151
1154
|
Log.log.warn('No username and password: emulator accepts requests without authentication') if config[:username].nil?
|
|
@@ -1155,10 +1158,8 @@ module Aspera
|
|
|
1155
1158
|
end
|
|
1156
1159
|
|
|
1157
1160
|
def action_telemetry(parameters: {}, **)
|
|
1161
|
+
# `url` and `key` are required by the schema
|
|
1158
1162
|
parameters = parameters.symbolize_keys
|
|
1159
|
-
%i[url key].each do |psym|
|
|
1160
|
-
Aspera.assert(parameters.key?(psym), type: Cli::BadArgument) { "Missing parameter: #{psym}" }
|
|
1161
|
-
end
|
|
1162
1163
|
require 'socket'
|
|
1163
1164
|
parameters[:interval] = 10 unless parameters.key?(:interval)
|
|
1164
1165
|
parameters[:hostname] = Socket.gethostname unless parameters.key?(:hostname)
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'basic_auth'
|
|
7
|
+
require_relative '../error'
|
|
4
8
|
|
|
5
9
|
module Aspera
|
|
6
10
|
module Cli
|
|
7
11
|
module Plugins
|
|
12
|
+
# Options of OAuth web authentication (authorization code): client and redirect URI.
|
|
13
|
+
# For a plugin that uses only this flow: `use_options OauthWebOptions` (without the options of `Oauth`)
|
|
14
|
+
module OauthWebOptions
|
|
15
|
+
extend OptionDeclarator
|
|
16
|
+
option :client_id, description: 'OAuth client identifier'
|
|
17
|
+
option :client_secret, description: 'OAuth client secret'
|
|
18
|
+
option :redirect_uri, description: 'OAuth (Web) redirect URI for web authentication'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Options of OAuth JWT authentication: private key
|
|
22
|
+
module OauthJwtOptions
|
|
23
|
+
extend OptionDeclarator
|
|
24
|
+
option :private_key, description: 'OAuth (JWT) RSA private key PEM value (prefix file path with @file:)'
|
|
25
|
+
option :passphrase, description: 'OAuth (JWT) RSA private key passphrase'
|
|
26
|
+
end
|
|
27
|
+
|
|
8
28
|
# base class for applications supporting OAuth 2.0 authentication
|
|
9
29
|
class Oauth < BasicAuth
|
|
10
30
|
class << self
|
|
@@ -29,11 +49,8 @@ module Aspera
|
|
|
29
49
|
# Options used for authentication (url, auth, client_id, etc...)
|
|
30
50
|
AUTH_OPTIONS = %i[url auth client_id client_secret redirect_uri private_key passphrase username password].freeze
|
|
31
51
|
option :auth, description: 'OAuth type of authentication', allowed: AUTH_TYPES, default: :jwt
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
option :redirect_uri, description: 'OAuth (Web) redirect URI for web authentication'
|
|
35
|
-
option :private_key, description: 'OAuth (JWT) RSA private key PEM value (prefix file path with @file:)'
|
|
36
|
-
option :passphrase, description: 'OAuth (JWT) RSA private key passphrase'
|
|
52
|
+
use_options OauthWebOptions
|
|
53
|
+
use_options OauthJwtOptions
|
|
37
54
|
end
|
|
38
55
|
end
|
|
39
56
|
end
|