aspera-cli 4.27.5 → 4.29.0
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 +301 -4
- data/CODE_OF_CONDUCT.md +18 -0
- data/CONTRIBUTING.md +139 -58
- data/GOVERNANCE.md +30 -0
- data/LICENSE +201 -0
- data/README.md +103 -26
- data/SECURITY.md +70 -0
- data/bin/ascli +8 -5
- data/bin/asession +10 -7
- data/docs/README.md +2551 -772
- data/docs/test-mcp-with-ai.md +13 -11
- 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 +34 -22
- data/lib/aspera/agent/factory.rb +8 -4
- 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 +8 -5
- data/lib/aspera/api/faspex.rb +16 -9
- data/lib/aspera/api/httpgw.rb +9 -6
- data/lib/aspera/api/node.rb +23 -19
- data/lib/aspera/ascmd.rb +8 -5
- data/lib/aspera/ascp/installation.rb +84 -42
- 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 +354 -0
- data/lib/aspera/ascp/management.rb +102 -48
- data/lib/aspera/ascp/session_errors.rb +217 -0
- data/lib/aspera/assert.rb +4 -0
- data/lib/aspera/cli/ascp_actions.rb +16 -37
- data/lib/aspera/cli/ascp_logs_actions.rb +176 -0
- data/lib/aspera/cli/async_transfer_store.rb +7 -4
- data/lib/aspera/cli/bootstrapper.rb +37 -34
- data/lib/aspera/cli/command_line.rb +24 -6
- data/lib/aspera/cli/command_registry.rb +49 -4
- data/lib/aspera/cli/command_spec.rb +34 -4
- data/lib/aspera/cli/completion/ascli.bash +53 -5
- data/lib/aspera/cli/completion/ascli.fish +27 -8
- data/lib/aspera/cli/completion/ascli.ps1 +63 -0
- data/lib/aspera/cli/completion/ascli.zsh +36 -4
- data/lib/aspera/cli/completion_actions.rb +594 -0
- data/lib/aspera/cli/context.rb +9 -4
- data/lib/aspera/cli/deprecation.rb +5 -2
- data/lib/aspera/cli/error.rb +45 -0
- data/lib/aspera/cli/extended_value.rb +83 -24
- data/lib/aspera/cli/formatter.rb +142 -73
- data/lib/aspera/cli/gem_checker.rb +9 -6
- data/lib/aspera/cli/hints.rb +22 -11
- data/lib/aspera/cli/http.rb +17 -13
- data/lib/aspera/cli/info.rb +17 -6
- data/lib/aspera/cli/mailer.rb +7 -4
- data/lib/aspera/cli/mcp/http_servlet.rb +155 -0
- data/lib/aspera/cli/mcp/secrets.rb +146 -0
- data/lib/aspera/cli/mcp/tool.rb +232 -0
- 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 +72 -11
- data/lib/aspera/cli/options.schema.yaml +856 -81
- data/lib/aspera/cli/parser.rb +64 -31
- data/lib/aspera/cli/plugins/alee.rb +7 -4
- data/lib/aspera/cli/plugins/aoc.rb +250 -44
- data/lib/aspera/cli/plugins/ats.rb +9 -8
- data/lib/aspera/cli/plugins/base.rb +51 -25
- data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
- data/lib/aspera/cli/plugins/config.rb +207 -141
- data/lib/aspera/cli/plugins/console.rb +9 -4
- data/lib/aspera/cli/plugins/cos.rb +8 -4
- data/lib/aspera/cli/plugins/factory.rb +22 -8
- data/lib/aspera/cli/plugins/faspex5.rb +37 -44
- data/lib/aspera/cli/plugins/faspio.rb +41 -8
- data/lib/aspera/cli/plugins/httpgw.rb +8 -4
- data/lib/aspera/cli/plugins/mcp.rb +186 -121
- data/lib/aspera/cli/plugins/node.rb +41 -34
- data/lib/aspera/cli/plugins/oauth.rb +5 -1
- data/lib/aspera/cli/plugins/orchestrator.rb +572 -59
- data/lib/aspera/cli/plugins/preview.rb +69 -44
- data/lib/aspera/cli/plugins/server.rb +66 -12
- data/lib/aspera/cli/plugins/shares.rb +288 -48
- data/lib/aspera/cli/plugins/transferd.rb +223 -0
- data/lib/aspera/cli/preset_actions.rb +155 -33
- data/lib/aspera/cli/preset_manager.rb +72 -16
- data/lib/aspera/cli/prompt.rb +7 -2
- data/lib/aspera/cli/result.rb +28 -11
- data/lib/aspera/cli/runner.rb +193 -80
- data/lib/aspera/cli/secret_finder.rb +4 -1
- data/lib/aspera/cli/security.rb +204 -0
- data/lib/aspera/cli/special_values.rb +4 -1
- data/lib/aspera/cli/sync_actions.rb +13 -10
- data/lib/aspera/cli/table_fitter.rb +119 -0
- data/lib/aspera/cli/terminal_formatter.rb +32 -40
- data/lib/aspera/cli/transfer_actions.rb +11 -8
- data/lib/aspera/cli/transfer_agent.rb +31 -19
- data/lib/aspera/cli/transfer_progress.rb +13 -45
- data/lib/aspera/cli/vault_actions.rb +45 -0
- data/lib/aspera/cli/vault_manager.rb +197 -50
- data/lib/aspera/cli/version.rb +4 -1
- data/lib/aspera/cli/web_secret.html.erb +61 -0
- data/lib/aspera/cli/web_secret.rb +222 -0
- data/lib/aspera/cli/wizard.rb +58 -45
- data/lib/aspera/command_line_builder.rb +35 -5
- data/lib/aspera/command_line_converter.rb +4 -1
- data/lib/aspera/coverage.rb +103 -33
- data/lib/aspera/data_repository.rb +42 -25
- data/lib/aspera/dot_container.rb +4 -1
- data/lib/aspera/duration.rb +45 -0
- data/lib/aspera/environment.rb +106 -33
- data/lib/aspera/exec_spec.rb +9 -5
- data/lib/aspera/faspex_gw.rb +105 -35
- data/lib/aspera/faspex_postproc.rb +193 -47
- data/lib/aspera/formatter_interface.rb +4 -2
- data/lib/aspera/graphql.rb +5 -1
- data/lib/aspera/hash_ext.rb +3 -0
- data/lib/aspera/id_generator.rb +6 -3
- data/lib/aspera/json_rpc/client.rb +55 -35
- data/lib/aspera/json_rpc/version.rb +4 -0
- data/lib/aspera/line_logger.rb +4 -1
- data/lib/aspera/link_header.rb +4 -1
- data/lib/aspera/log.rb +20 -10
- data/lib/aspera/markdown.rb +155 -115
- data/lib/aspera/mime.rb +9 -0
- data/lib/aspera/nagios.rb +9 -5
- data/lib/aspera/node_emulator.rb +111 -112
- data/lib/aspera/oauth/client/base.rb +163 -0
- data/lib/aspera/oauth/{boot.rb → client/boot.rb} +8 -4
- data/lib/aspera/oauth/{factory.rb → client/factory.rb} +13 -3
- data/lib/aspera/oauth/{generic.rb → client/generic.rb} +5 -1
- data/lib/aspera/oauth/{json_credentials.rb → client/json_credentials.rb} +4 -1
- data/lib/aspera/oauth/{jwt.rb → client/jwt.rb} +6 -3
- data/lib/aspera/oauth/client/shares_web.rb +85 -0
- data/lib/aspera/oauth/{url_json.rb → client/url_json.rb} +4 -1
- data/lib/aspera/oauth/client/web.rb +84 -0
- data/lib/aspera/oauth/server/authorize.html.erb +34 -0
- data/lib/aspera/oauth/server/pkce.rb +427 -0
- data/lib/aspera/orchestrator_workflow_checker.rb +679 -0
- 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 +11 -6
- data/lib/aspera/preview/utils.rb +6 -4
- data/lib/aspera/products/connect.rb +5 -2
- data/lib/aspera/products/desktop.rb +4 -1
- 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 +30 -1
- data/lib/aspera/rest/aspera_errors.rb +55 -60
- data/lib/aspera/rest/call_error.rb +3 -0
- data/lib/aspera/rest/client.rb +42 -42
- data/lib/aspera/rest/error_analyzer.rb +14 -2
- data/lib/aspera/rest/list.rb +14 -10
- data/lib/aspera/rest/parameters.rb +3 -0
- data/lib/aspera/rest/util.rb +13 -4
- data/lib/aspera/rest.rb +9 -7
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -11
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +4089 -0
- data/lib/aspera/schema/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +1097 -0
- 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/IBM_Aspera_Shares.yaml +819 -7
- data/lib/aspera/schema/async_tables.yaml +11 -10
- data/lib/aspera/schema/documentation.rb +56 -78
- data/lib/aspera/schema/reader.rb +46 -11
- data/lib/aspera/schema/registry.rb +45 -24
- data/lib/aspera/schema/transferd-config.schema.json +333 -0
- data/lib/aspera/schema/validator.rb +4 -1
- data/lib/aspera/sealed_hash.rb +166 -0
- data/lib/aspera/secret/hider.rb +201 -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 +110 -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 +114 -0
- 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 +6 -1
- data/lib/aspera/sync/conf.schema.yaml +25 -10
- data/lib/aspera/sync/database.rb +3 -0
- data/lib/aspera/sync/operations.rb +34 -12
- data/lib/aspera/temp_file_manager.rb +85 -22
- 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 +22 -14
- data/lib/aspera/transfer/result.rb +3 -0
- data/lib/aspera/transfer/resumer.rb +6 -4
- data/lib/aspera/transfer/spec.rb +45 -18
- data/lib/aspera/transfer/spec.schema.yaml +8 -5
- data/lib/aspera/transfer/units.rb +75 -0
- data/lib/aspera/uri_reader.rb +57 -7
- data/lib/aspera/web_auth/index.html.erb +20 -0
- 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 +59 -14
- data/lib/aspera/web_page.html.erb +262 -0
- data/lib/aspera/web_page.rb +66 -0
- data/lib/aspera/web_server_simple.rb +82 -13
- data/lib/aspera/yaml.rb +5 -1
- data/llms.txt +81 -0
- data/skills/ascli/SKILL.md +88 -0
- data.tar.gz.sig +0 -0
- metadata +116 -48
- metadata.gz.sig +0 -0
- data/lib/aspera/cli/mcp_tool.rb +0 -189
- data/lib/aspera/keychain/base.rb +0 -25
- data/lib/aspera/keychain/encrypted_hash.rb +0 -188
- data/lib/aspera/keychain/factory.rb +0 -59
- data/lib/aspera/keychain/hashicorp_vault.rb +0 -74
- data/lib/aspera/keychain/macos_security.rb +0 -171
- data/lib/aspera/keychain/one_password_api.rb +0 -86
- data/lib/aspera/keychain/one_password_base.rb +0 -34
- data/lib/aspera/keychain/one_password_cli.rb +0 -98
- data/lib/aspera/oauth/base.rb +0 -141
- data/lib/aspera/oauth/web.rb +0 -57
- data/lib/aspera/oauth.rb +0 -9
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1.yaml +0 -1784
- data/lib/aspera/schema/IBM Aspera faspio Gateway API-1.0.0.yaml +0 -249
- data/lib/aspera/secret_hider.rb +0 -117
- data/lib/aspera/web_auth/index.html +0 -147
|
@@ -1,11 +1,16 @@
|
|
|
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
|
-
|
|
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'
|
|
13
|
+
require 'securerandom'
|
|
9
14
|
|
|
10
15
|
module Aspera
|
|
11
16
|
module Cli
|
|
@@ -22,8 +27,17 @@ module Aspera
|
|
|
22
27
|
# # stdio transport:
|
|
23
28
|
# max_line_bytes: Integer - max JSON frame size (default 4 MiB)
|
|
24
29
|
# # http transport:
|
|
25
|
-
#
|
|
26
|
-
#
|
|
30
|
+
# url: String - address and port the server listens on (default "http://127.0.0.1:3000"), https:// for TLS
|
|
31
|
+
# cert, key, chain: String - TLS certificate, private key or PKCS12 passphrase, chain, see WebServerSimple
|
|
32
|
+
# auth_token: String - if set, require "Authorization: Bearer <token>" on MCP requests,
|
|
33
|
+
# and asked on the OAuth consent page (mandatory when url or public_url is not loopback)
|
|
34
|
+
# auth_token_min_bits: Integer - minimum estimated strength of auth_token in bits (default 80, 0 disables)
|
|
35
|
+
# oauth: Boolean - enable OAuth 2.0 PKCE flow with dynamic client registration (RFC 7591)
|
|
36
|
+
# oauth_access_token_ttl: Integer - access token lifetime in seconds (default 3600)
|
|
37
|
+
# oauth_refresh_token_ttl: Integer - refresh token lifetime in seconds (default 2592000 = 30 days)
|
|
38
|
+
# public_url: String - URL of the server for clients, used in OAuth metadata and secret pages
|
|
39
|
+
# (default: from url, mandatory with oauth on a wildcard address)
|
|
40
|
+
# port, bind: deprecated, replaced by url
|
|
27
41
|
# stateless: Boolean - stateless mode (default false)
|
|
28
42
|
# allowed_origins: Array<String>
|
|
29
43
|
# allowed_hosts: Array<String>
|
|
@@ -37,10 +51,19 @@ module Aspera
|
|
|
37
51
|
# Examples:
|
|
38
52
|
# ascli mcp server
|
|
39
53
|
# ascli mcp server @json:{"instructions":"Aspera transfers"}
|
|
40
|
-
# ascli mcp server @json:{"transport":"http","
|
|
54
|
+
# ascli mcp server @json:{"transport":"http","url":"http://127.0.0.1:3000"}
|
|
41
55
|
# ascli mcp server @json:{"protocol_version":"2024-11-05","max_line_bytes":1048576}
|
|
42
56
|
class Mcp < Base
|
|
43
57
|
application_name 'Model Context Protocol Server'
|
|
58
|
+
|
|
59
|
+
# Instruction for AI agents to always display the equivalent CLI command in their output.
|
|
60
|
+
COMMAND_DISPLAY_INSTRUCTIONS = <<~INST.strip
|
|
61
|
+
COMMAND DISPLAY (MANDATORY)
|
|
62
|
+
Whenever you execute an ascli command or present its results, you MUST ALWAYS explicitly
|
|
63
|
+
show the equivalent command line in your response to the user as bash syntax
|
|
64
|
+
(e.g. `ascli plugin command --option=value`).
|
|
65
|
+
INST
|
|
66
|
+
|
|
44
67
|
# Default instructions shown to the AI client when none are provided by the user.
|
|
45
68
|
DEFAULT_INSTRUCTIONS = <<~INST.strip
|
|
46
69
|
This is the Aspera CLI (ascli) MCP server (IBM Aspera file transfer and management).
|
|
@@ -48,6 +71,8 @@ module Aspera
|
|
|
48
71
|
Its description gives the syntax and the discovery sequence: follow it before any
|
|
49
72
|
command whose syntax you have not verified in this session.
|
|
50
73
|
|
|
74
|
+
#{COMMAND_DISPLAY_INSTRUCTIONS}
|
|
75
|
+
|
|
51
76
|
Plugins: aoc (Aspera on Cloud), faspex5 (Faspex 5), node (Node API), server (FASP/SSH
|
|
52
77
|
server), config (local configuration), console, orchestrator, ats, preview, shares,
|
|
53
78
|
cos, httpgw, faspio, alee.
|
|
@@ -58,6 +83,8 @@ module Aspera
|
|
|
58
83
|
If the user provides credentials inline (--url, --username, --password, --private-key),
|
|
59
84
|
use those exact values verbatim — never substitute a preset or another server.
|
|
60
85
|
Some plugins support browser login (--auth=web).
|
|
86
|
+
For a secret the user did not give (password, passphrase), pass "@secret:<name>" as value:
|
|
87
|
+
the user enters it on a web page, you never see it. Prefer it to asking in the conversation.
|
|
61
88
|
On error, report it as-is and stop.
|
|
62
89
|
|
|
63
90
|
TRANSFERS
|
|
@@ -68,34 +95,73 @@ module Aspera
|
|
|
68
95
|
monitor → ["config", "transfer", "status", "<job_id>"]
|
|
69
96
|
list → ["config", "transfer", "list"]
|
|
70
97
|
cleanup → ["config", "transfer", "cleanup"]
|
|
98
|
+
|
|
99
|
+
ORCHESTRATOR WORKFLOW DEVELOPMENT
|
|
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"]
|
|
108
|
+
For the template attributes (allowed values), inputs and outputs of an action plugin, and the
|
|
109
|
+
template settings they depend on, read its specification (fields: section "plugin-specifications"
|
|
110
|
+
of the development guide); the list of plugins is given by ["orchestrator", "plugins", "spec", "toc"]:
|
|
111
|
+
["orchestrator", "plugins", "spec", "show", "<PluginClass>"]
|
|
112
|
+
For the functional description and the setup of a plugin (for example the API client of Faspex),
|
|
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>"]
|
|
116
|
+
Before importing a workflow file, check it (graph, templates, inputs of steps) and fix all errors:
|
|
117
|
+
["orchestrator", "workflows", "check_import", "<file>"]
|
|
71
118
|
INST
|
|
72
119
|
|
|
73
120
|
# Keys forwarded to MCP::Server constructor (symbolized)
|
|
74
|
-
SERVER_KEYS
|
|
121
|
+
SERVER_KEYS = %i[instructions description].freeze
|
|
75
122
|
# Keys forwarded to MCP::Configuration
|
|
76
|
-
CONFIG_KEYS
|
|
123
|
+
CONFIG_KEYS = %i[protocol_version validate_tool_call_arguments].freeze
|
|
77
124
|
# Keys forwarded to StdioTransport
|
|
78
|
-
STDIO_KEYS
|
|
125
|
+
STDIO_KEYS = %i[max_line_bytes].freeze
|
|
79
126
|
# Keys forwarded to StreamableHTTPTransport
|
|
80
|
-
HTTP_KEYS
|
|
127
|
+
HTTP_KEYS = %i[stateless allowed_origins allowed_hosts session_idle_timeout max_sessions].freeze
|
|
128
|
+
# Keys of the HTTP server, consumed locally
|
|
129
|
+
HTTP_SERVER_KEYS = %i[url cert key chain port bind public_url auth_token auth_token_min_bits oauth oauth_access_token_ttl oauth_refresh_token_ttl].freeze
|
|
81
130
|
# Keys consumed locally (not forwarded to MCP gem)
|
|
82
|
-
TOOL_KEYS
|
|
83
|
-
|
|
131
|
+
TOOL_KEYS = %i[max_text_bytes extra_args].freeze
|
|
132
|
+
# Extended-value handlers disabled in MCP server mode whatever the security level:
|
|
133
|
+
# @stdin: is the JSON-RPC stream (stdio).
|
|
134
|
+
# Other unsafe handlers depend on the security level, see Security.
|
|
135
|
+
# @secret: is entered on a web page instead of the terminal, see Mcp::Secrets.
|
|
136
|
+
DISABLED_EXTENDED_VALUE_HANDLERS = %i[stdin].freeze
|
|
137
|
+
# Security level when not set by option `security`
|
|
138
|
+
DEFAULT_SECURITY_LEVEL = :high
|
|
139
|
+
private_constant :SERVER_KEYS, :CONFIG_KEYS, :STDIO_KEYS, :HTTP_KEYS, :HTTP_SERVER_KEYS, :TOOL_KEYS, :DISABLED_EXTENDED_VALUE_HANDLERS, :DEFAULT_SECURITY_LEVEL
|
|
84
140
|
|
|
85
141
|
command :server, description: 'Start the MCP (Model Context Protocol) server',
|
|
86
142
|
arguments: [{name: :mcp_options, type: [Hash], mandatory: false, schema: 'opts:components.schemas.McpServerOptions'}]
|
|
87
143
|
|
|
88
144
|
def action_server(mcp_options: nil, **)
|
|
89
|
-
|
|
145
|
+
require_relative '../mcp/tool'
|
|
146
|
+
require_relative '../extended_value'
|
|
90
147
|
mcp_options = (mcp_options || {}).transform_keys(&:to_sym)
|
|
91
|
-
unknown = mcp_options.keys - SERVER_KEYS - CONFIG_KEYS - STDIO_KEYS - HTTP_KEYS - TOOL_KEYS - %i[transport
|
|
148
|
+
unknown = mcp_options.keys - SERVER_KEYS - CONFIG_KEYS - STDIO_KEYS - HTTP_KEYS - HTTP_SERVER_KEYS - TOOL_KEYS - %i[transport]
|
|
92
149
|
Aspera.assert(unknown.empty?, type: Cli::BadArgument) { "Unknown MCP option(s): #{unknown.join(', ')}" }
|
|
93
|
-
Cli::
|
|
94
|
-
Cli::
|
|
150
|
+
Cli::Mcp::Tool.max_text_bytes = mcp_options.delete(:max_text_bytes)
|
|
151
|
+
Cli::Mcp::Tool.extra_args = mcp_options.delete(:extra_args)
|
|
95
152
|
transport = mcp_options.delete(:transport) || 'stdio'
|
|
96
153
|
raise Cli::BadArgument, "Unknown transport: #{transport}. Use 'stdio' or 'http'" \
|
|
97
154
|
unless %w[stdio http].include?(transport.to_s)
|
|
98
|
-
|
|
155
|
+
# Options of the other transport would be ignored
|
|
156
|
+
ignored = mcp_options.keys & (transport.to_s.eql?('stdio') ? HTTP_KEYS + HTTP_SERVER_KEYS : STDIO_KEYS)
|
|
157
|
+
Aspera.assert(ignored.empty?, type: Cli::BadArgument) { "MCP option(s) not used with transport #{transport}: #{ignored.join(', ')}" }
|
|
158
|
+
DISABLED_EXTENDED_VALUE_HANDLERS.each do |handler|
|
|
159
|
+
ExtendedValue.instance.on(handler) { |_| raise Cli::BadArgument, "@#{handler}: extended value is disabled in MCP server mode" }
|
|
160
|
+
end
|
|
161
|
+
ExtendedValue.instance.on(:secret) { |prompt| Cli::Mcp::Secrets.value(prompt) }
|
|
162
|
+
# Applies to commands of the client, and to presets, which the client can modify
|
|
163
|
+
Security.instance.lock('in MCP server mode', default: DEFAULT_SECURITY_LEVEL)
|
|
164
|
+
Log.log.info { "Starting MCP server (transport=#{transport}, security level #{Security.instance.level})..." }
|
|
99
165
|
start_mcp_server(transport: transport.to_sym, mcp_options: mcp_options)
|
|
100
166
|
Result::Nothing.new
|
|
101
167
|
end
|
|
@@ -106,17 +172,19 @@ module Aspera
|
|
|
106
172
|
# @param mcp_options [Hash] symbolized options
|
|
107
173
|
# @return [MCP::Server]
|
|
108
174
|
def build_mcp_server(mcp_options)
|
|
109
|
-
tool = Cli::
|
|
175
|
+
tool = Cli::Mcp::Tool
|
|
110
176
|
config_opts = mcp_options.slice(*CONFIG_KEYS)
|
|
111
177
|
server_opts = mcp_options.slice(*SERVER_KEYS)
|
|
112
178
|
server_opts[:instructions] ||= DEFAULT_INSTRUCTIONS
|
|
113
179
|
server_opts[:description] ||= "#{Info::GEM_NAME} MCP server (IBM Aspera file transfer and management)"
|
|
114
180
|
configuration = config_opts.empty? ? nil : MCP::Configuration.new(**config_opts)
|
|
115
181
|
MCP::Server.new(
|
|
116
|
-
name:
|
|
117
|
-
version:
|
|
118
|
-
tools:
|
|
119
|
-
configuration:
|
|
182
|
+
name: Info::GEM_NAME,
|
|
183
|
+
version: VERSION,
|
|
184
|
+
tools: [tool],
|
|
185
|
+
configuration: configuration,
|
|
186
|
+
# The request state of secret requests (@secret:) goes through the client: encrypted and bound to the tool call
|
|
187
|
+
request_state_security: MCP::Server::RequestStateSecurity.new(key: SecureRandom.random_bytes(32), ttl: Cli::WebSecret::TTL),
|
|
120
188
|
**server_opts
|
|
121
189
|
)
|
|
122
190
|
end
|
|
@@ -128,6 +196,8 @@ module Aspera
|
|
|
128
196
|
server = build_mcp_server(mcp_options)
|
|
129
197
|
case transport
|
|
130
198
|
when :stdio
|
|
199
|
+
# Secret pages are served by a local web server, started on first use of @secret:
|
|
200
|
+
Cli::Mcp::Tool.web_secret = Cli::Mcp::Secrets.web_secret
|
|
131
201
|
stdio_opts = mcp_options.slice(*STDIO_KEYS)
|
|
132
202
|
MCP::Server::Transports::StdioTransport.new(server, **stdio_opts).open
|
|
133
203
|
when :http
|
|
@@ -135,108 +205,103 @@ module Aspera
|
|
|
135
205
|
end
|
|
136
206
|
end
|
|
137
207
|
|
|
138
|
-
#
|
|
139
|
-
|
|
140
|
-
#
|
|
208
|
+
# Addresses listening on all interfaces: not a host name usable by clients
|
|
209
|
+
WILDCARD_BIND_ADDRESSES = %w[0.0.0.0 ::].freeze
|
|
210
|
+
# Address of the HTTP transport, when not set by option `url`
|
|
211
|
+
DEFAULT_HTTP_URL = 'http://127.0.0.1:3000'
|
|
212
|
+
private_constant :WILDCARD_BIND_ADDRESSES, :DEFAULT_HTTP_URL
|
|
213
|
+
|
|
214
|
+
# @param mcp_options [Hash] symbolized options
|
|
215
|
+
# @return [Hash] Parameters of WebServerSimple.serve: `url`, and `cert`, `key`, `chain` if set
|
|
216
|
+
def http_server_parameters(mcp_options)
|
|
217
|
+
url = mcp_options[:url]
|
|
218
|
+
bind, port = mcp_options.values_at(:bind, :port)
|
|
219
|
+
unless bind.nil? && port.nil?
|
|
220
|
+
Aspera.assert(url.nil?, type: Cli::BadArgument) { 'url cannot be used with bind or port' }
|
|
221
|
+
Log.log.warn { "MCP options bind and port are #{Deprecation.new(last: '4.27.5', message: 'use url')}" }
|
|
222
|
+
uri = URI.parse(DEFAULT_HTTP_URL)
|
|
223
|
+
uri.hostname = bind.to_s unless bind.nil?
|
|
224
|
+
uri.port = port unless port.nil?
|
|
225
|
+
url = uri.to_s
|
|
226
|
+
end
|
|
227
|
+
url ||= DEFAULT_HTTP_URL
|
|
228
|
+
# Paths of the servlet are absolute
|
|
229
|
+
Aspera.assert(['', '/'].include?(URI.parse(url).path), type: Cli::BadArgument) { "url shall have no path (the MCP endpoint is /mcp): #{url}" }
|
|
230
|
+
{url: url, **mcp_options.slice(:cert, :key, :chain)}
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# @param uri [URI] Address the server listens on
|
|
234
|
+
# @param public_url [String, nil] URL of the server for clients, if provided by user
|
|
235
|
+
# @param oauth_enabled [Boolean] whether OAuth PKCE flow is enabled
|
|
236
|
+
# @return [String] URL of the server for clients, without trailing slash
|
|
237
|
+
def http_base_url(uri, public_url, oauth_enabled)
|
|
238
|
+
return public_url.to_s.chomp('/') unless public_url.nil?
|
|
239
|
+
wildcard = WILDCARD_BIND_ADDRESSES.include?(uri.hostname)
|
|
240
|
+
Aspera.assert(!oauth_enabled || !wildcard, type: Cli::BadArgument) do
|
|
241
|
+
"public_url is required with oauth when listening on #{uri.hostname}: URL used by clients, e.g. #{uri.scheme}://myhost:#{uri.port}"
|
|
242
|
+
end
|
|
243
|
+
URI.parse("#{uri.scheme}://#{wildcard ? 'localhost' : uri.host}:#{uri.port}").to_s
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Start HTTP transport, see Mcp::HttpServlet.
|
|
247
|
+
# On an address that is not loopback, `auth_token` is mandatory, also with OAuth:
|
|
248
|
+
# it is the secret asked on the consent page, else anyone could approve its own client.
|
|
141
249
|
def start_http_transport(server, mcp_options)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
res.status = 200
|
|
160
|
-
res['Content-Type'] = 'application/json'
|
|
161
|
-
res.body = body
|
|
162
|
-
next
|
|
163
|
-
end
|
|
164
|
-
env = rack_env_from_webrick(req)
|
|
165
|
-
status, headers, rack_body = @app.call(env)
|
|
166
|
-
res.status = status
|
|
167
|
-
headers.each { |k, v| res[k] = v }
|
|
168
|
-
if rack_body.respond_to?(:call)
|
|
169
|
-
# Rack streaming body (SSE): wrap the WEBrick socket in a stream object
|
|
170
|
-
# that exposes write/flush/close, then hand off a Proc to WEBrick so it
|
|
171
|
-
# calls us back with the raw socket once headers have been flushed.
|
|
172
|
-
rack_proc = rack_body
|
|
173
|
-
res.chunked = true
|
|
174
|
-
res.body = proc do |socket|
|
|
175
|
-
stream = Object.new
|
|
176
|
-
stream.define_singleton_method(:write) { |data| socket.write(data) }
|
|
177
|
-
stream.define_singleton_method(:flush) { socket.flush rescue nil }
|
|
178
|
-
stream.define_singleton_method(:close) { socket.close rescue nil }
|
|
179
|
-
rack_proc.call(stream)
|
|
180
|
-
end
|
|
181
|
-
else
|
|
182
|
-
buf = +''
|
|
183
|
-
rack_body.each { |chunk| buf << chunk }
|
|
184
|
-
rack_body.close if rack_body.respond_to?(:close)
|
|
185
|
-
res.body = buf
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
define_method(:rack_env_from_webrick) do |req|
|
|
190
|
-
{
|
|
191
|
-
'REQUEST_METHOD' => req.request_method,
|
|
192
|
-
'SCRIPT_NAME' => '',
|
|
193
|
-
'PATH_INFO' => req.path,
|
|
194
|
-
'QUERY_STRING' => req.query_string || '',
|
|
195
|
-
'SERVER_NAME' => req.host,
|
|
196
|
-
'SERVER_PORT' => req.port.to_s,
|
|
197
|
-
'HTTP_VERSION' => req.http_version,
|
|
198
|
-
'rack.input' => StringIO.new(req.body.to_s),
|
|
199
|
-
'rack.errors' => $stderr,
|
|
200
|
-
'rack.url_scheme' => 'http',
|
|
201
|
-
'rack.multithread' => true,
|
|
202
|
-
'rack.multiprocess' => false,
|
|
203
|
-
'rack.run_once' => false
|
|
204
|
-
}.tap do |env|
|
|
205
|
-
req.header.each do |key, values|
|
|
206
|
-
http_key = "HTTP_#{key.upcase.tr('-', '_')}"
|
|
207
|
-
case key.downcase
|
|
208
|
-
when 'content-type' then env['CONTENT_TYPE'] = values.first
|
|
209
|
-
when 'content-length' then env['CONTENT_LENGTH'] = values.first
|
|
210
|
-
else env[http_key] = values.join(', ')
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
end
|
|
250
|
+
require_relative '../mcp/http_servlet'
|
|
251
|
+
require_relative '../../web_server_simple'
|
|
252
|
+
parameters = http_server_parameters(mcp_options)
|
|
253
|
+
uri = WebServerSimple.url(parameters)
|
|
254
|
+
auth_token = mcp_options[:auth_token]
|
|
255
|
+
oauth_enabled = mcp_options.fetch(:oauth, false)
|
|
256
|
+
access_token_ttl = mcp_options.fetch(:oauth_access_token_ttl, OAuth::Server::Pkce.default_access_token_ttl)
|
|
257
|
+
refresh_token_ttl = mcp_options.fetch(:oauth_refresh_token_ttl, OAuth::Server::Pkce.default_refresh_token_ttl)
|
|
258
|
+
min_bits = mcp_options.fetch(:auth_token_min_bits, Secret::Strength::DEFAULT_MIN_BITS)
|
|
259
|
+
Secret::Strength.assert_strong(auth_token, name: 'auth_token', min_bits: min_bits, type: Cli::BadArgument) unless auth_token.nil?
|
|
260
|
+
base_url = http_base_url(uri, mcp_options[:public_url], oauth_enabled)
|
|
261
|
+
what = "auth_token#{' (asked on the consent page)' if oauth_enabled}"
|
|
262
|
+
# Clients reach the server at public_url (e.g. through a reverse proxy), whatever the address it listens on
|
|
263
|
+
unless mcp_options[:public_url].nil?
|
|
264
|
+
public_host = URI.parse(base_url).hostname
|
|
265
|
+
Aspera.assert(!auth_token.nil? || WebServerSimple.loopback?(public_host), type: Cli::BadArgument) do
|
|
266
|
+
"#{what} is required when public_url is not loopback (localhost, 127.0.0.0/8, ::1): #{public_host}"
|
|
214
267
|
end
|
|
215
268
|
end
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
269
|
+
WebServerSimple.serve(
|
|
270
|
+
parameters,
|
|
271
|
+
Cli::Mcp::HttpServlet,
|
|
272
|
+
protected: !auth_token.nil?,
|
|
273
|
+
what: what,
|
|
274
|
+
type: Cli::BadArgument
|
|
275
|
+
) do
|
|
276
|
+
# Secret pages are served by this server: the static token, if any, is the access code asked on the page
|
|
277
|
+
web_secret = Cli::Mcp::Secrets.web_secret(base_url: base_url, access_code: auth_token)
|
|
278
|
+
Cli::Mcp::Tool.web_secret = web_secret
|
|
279
|
+
# Build OAuth::Server::Pkce only when OAuth is enabled.
|
|
280
|
+
# Pass MCP-specific branding via title: and description: so the external HTML
|
|
281
|
+
# template is used directly without a custom callback.
|
|
282
|
+
# The static token, if any, is the access code asked on the consent page.
|
|
283
|
+
oauth_server = if oauth_enabled
|
|
284
|
+
Log.log.info { 'OAuth 2.0 PKCE enabled (dynamic registration)' }
|
|
285
|
+
OAuth::Server::Pkce.new(
|
|
286
|
+
base_url: base_url,
|
|
287
|
+
access_token_ttl: access_token_ttl,
|
|
288
|
+
refresh_token_ttl: refresh_token_ttl,
|
|
289
|
+
title: "Authorize #{Info::GEM_NAME} MCP server",
|
|
290
|
+
description: "the <strong>#{Info::GEM_NAME} MCP server</strong>",
|
|
291
|
+
consent_secret: auth_token
|
|
292
|
+
)
|
|
222
293
|
end
|
|
294
|
+
[{
|
|
295
|
+
app: MCP::Server::Transports::StreamableHTTPTransport.new(server, **mcp_options.slice(*HTTP_KEYS)),
|
|
296
|
+
server_info: {name: server.name, version: server.version, description: server.description},
|
|
297
|
+
web_secret: web_secret,
|
|
298
|
+
auth_token: auth_token,
|
|
299
|
+
oauth_server: oauth_server,
|
|
300
|
+
allowed_hosts: mcp_options[:allowed_hosts],
|
|
301
|
+
# Pages of the server (consent, secret) are opened at base_url, also behind a reverse proxy that changes Host
|
|
302
|
+
allowed_origins: [*mcp_options[:allowed_origins], ServletHelpers.origin(base_url)]
|
|
303
|
+
}]
|
|
223
304
|
end
|
|
224
|
-
webrick = WEBrick::HTTPServer.new(
|
|
225
|
-
BindAddress: bind,
|
|
226
|
-
Port: port,
|
|
227
|
-
Logger: quiet_logger,
|
|
228
|
-
AccessLog: []
|
|
229
|
-
)
|
|
230
|
-
server_info = {
|
|
231
|
-
name: server.name,
|
|
232
|
-
version: server.version,
|
|
233
|
-
description: server.description
|
|
234
|
-
}
|
|
235
|
-
webrick.mount('/', rack_servlet, app, server_info)
|
|
236
|
-
Log.log.info { "MCP HTTP server listening on http://#{bind}:#{port}/" }
|
|
237
|
-
trap('INT') { webrick.shutdown }
|
|
238
|
-
trap('TERM') { webrick.shutdown }
|
|
239
|
-
webrick.start
|
|
240
305
|
end
|
|
241
306
|
end
|
|
242
307
|
end
|
|
@@ -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)'
|
|
@@ -83,10 +86,12 @@ module Aspera
|
|
|
83
86
|
# @param app_url [String] Tested URL
|
|
84
87
|
# @return [Hash] :preset_value, :test_args
|
|
85
88
|
def wizard(wizard, app_url)
|
|
89
|
+
username = options.get_option(:username, mandatory: true)
|
|
86
90
|
return {
|
|
91
|
+
preset_ids: [username],
|
|
87
92
|
preset_value: {
|
|
88
93
|
url: app_url,
|
|
89
|
-
username:
|
|
94
|
+
username: username,
|
|
90
95
|
password: options.get_option(:password, mandatory: true)
|
|
91
96
|
},
|
|
92
97
|
test_args: 'info'
|
|
@@ -577,7 +582,7 @@ module Aspera
|
|
|
577
582
|
arguments: [{name: :file, type: Hash, mandatory: false, default: nil}]
|
|
578
583
|
end
|
|
579
584
|
# Standalone leaf commands
|
|
580
|
-
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)'
|
|
581
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))) }
|
|
582
587
|
command(
|
|
583
588
|
:bearer_token, description: 'Generate bearer token',
|
|
@@ -775,7 +780,7 @@ module Aspera
|
|
|
775
780
|
# access_keys > do > show
|
|
776
781
|
def action_access_keys_do_show(path:, do_root_file_id:, **)
|
|
777
782
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
778
|
-
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))
|
|
779
784
|
end
|
|
780
785
|
|
|
781
786
|
# access_keys > do > modify
|
|
@@ -788,7 +793,7 @@ module Aspera
|
|
|
788
793
|
# access_keys > do > thumbnail
|
|
789
794
|
def action_access_keys_do_thumbnail(path:, do_root_file_id:, **)
|
|
790
795
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
791
|
-
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)
|
|
792
797
|
end
|
|
793
798
|
|
|
794
799
|
# access_keys > do > rename
|
|
@@ -1120,39 +1125,41 @@ module Aspera
|
|
|
1120
1125
|
def action_asperabrowser(**)
|
|
1121
1126
|
browse_params = {
|
|
1122
1127
|
'nodeUser' => options.get_option(:username, mandatory: true),
|
|
1123
|
-
'nodePW' => options.get_option(:password
|
|
1128
|
+
'nodePW' => options.get_option(:password),
|
|
1124
1129
|
'nodeURL' => options.get_option(:url, mandatory: true)
|
|
1125
|
-
}
|
|
1126
|
-
#
|
|
1127
|
-
encoded_params =
|
|
1128
|
-
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)}")
|
|
1129
1134
|
return Result::Status.new('done')
|
|
1130
1135
|
end
|
|
1131
1136
|
|
|
1132
1137
|
def action_emulator(parameters: {}, **)
|
|
1133
|
-
|
|
1138
|
+
require_relative '../../secret/strength'
|
|
1139
|
+
require_relative '../../web_server_simple'
|
|
1140
|
+
require_relative '../../node_emulator'
|
|
1134
1141
|
# missing parameters take the default of the schema
|
|
1135
1142
|
defaults = Schema::Registry.instance.reader(Schema::Registry::NODE_EMULATOR_OPTIONS).current['properties'].each_with_object({}) do |(name, property), result|
|
|
1136
1143
|
result[name.to_sym] = property['default'] if property.key?('default')
|
|
1137
1144
|
end
|
|
1138
1145
|
parameters = defaults.merge(parameters.symbolize_keys)
|
|
1139
|
-
|
|
1140
|
-
config = parameters.except(*WebServerSimple::PARAMS)
|
|
1146
|
+
config = WebServerSimple.servlet_parameters(parameters)
|
|
1141
1147
|
docroot = config.delete(:docroot)
|
|
1142
1148
|
retention_sec = config.delete(:retention_sec)
|
|
1149
|
+
password_min_bits = config.delete(:password_min_bits)
|
|
1143
1150
|
Aspera.assert(config[:username].nil? == config[:password].nil?, type: Cli::BadArgument) { 'Parameters username and password must be set together' }
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1151
|
+
Secret::Strength.assert_strong(config[:password], name: 'password', min_bits: password_min_bits, type: Cli::BadArgument) unless config[:password].nil?
|
|
1152
|
+
# Files of the docroot can be sent to, or received from, any host by anyone who can reach the server
|
|
1153
|
+
WebServerSimple.serve(parameters, NodeEmulatorServlet, protected: !config[:username].nil?, what: 'username and password', type: Cli::BadArgument) do
|
|
1154
|
+
Log.log.warn('No username and password: emulator accepts requests without authentication') if config[:username].nil?
|
|
1155
|
+
[config, NodeEmulator.new(docroot: docroot, retention_sec: retention_sec)]
|
|
1156
|
+
end
|
|
1148
1157
|
return Result::Status.new('Emulator terminated')
|
|
1149
1158
|
end
|
|
1150
1159
|
|
|
1151
1160
|
def action_telemetry(parameters: {}, **)
|
|
1161
|
+
# `url` and `key` are required by the schema
|
|
1152
1162
|
parameters = parameters.symbolize_keys
|
|
1153
|
-
%i[url key].each do |psym|
|
|
1154
|
-
Aspera.assert(parameters.key?(psym), type: Cli::BadArgument) { "Missing parameter: #{psym}" }
|
|
1155
|
-
end
|
|
1156
1163
|
require 'socket'
|
|
1157
1164
|
parameters[:interval] = 10 unless parameters.key?(:interval)
|
|
1158
1165
|
parameters[:hostname] = Socket.gethostname unless parameters.key?(:hostname)
|