主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

webapps-secrets

管理 WindowsLinuxmacOS 系统上的 Web App 服务器机密

自 R2024a 起

说明

webapps-secrets set keyName keyValue [--mode Overwrite|FailIfExists] 将值 keyValue 分配给机密 keyName 并将密钥添加到保管库。或者,您可以配置是否覆盖 keyName 或者在密钥已存在时中止。

示例

webapps-secrets remove keyName keyValue [--scope scopeValue] 从保管库中删除机密 keyName

示例

webapps-secrets set-attributes --secret-key keyName [attrName attrValue] [--scope scopeValue] [--mode Add|Merge|Replace] 设置机密 keyName 的属性。您可以选择配置是否向键添加新属性、合并新属性和现有属性,或者用新属性替换所有现有属性。

示例

webapps-secrets get-attributes --secret-key keyName [--scope scopeValue] 返回名为 keyName 的机密的属性。

示例

webapps-secrets list [--scope scopeValue] 列出了 scopeValue 范围内所有当前配置的机密。

示例

webapps-secrets listAll 列出所有范围内当前配置的所有机密。

示例

webapps-secrets --help 显示命令的帮助文本。

示例

webapps-secrets --version 显示命令的版本信息。

示例

示例

设置特定机密的值

要设置特定机密的值,请在系统命令行中输入:

webapps-secrets set mypassword hunter2
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
MATLAB Web App Server secrets configuration has been updated.

验证机密是否已添加。

webapps-secrets listAll
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
List of secret keys configured:
    scope:<default>, secret key:mypassword

从服务器移除机密

要从服务器中删除现有的机密 mypassword,请在系统命令行中输入:

webapps-secrets remove mypassword 
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
MATLAB Web App Server secrets configuration has been updated.

设置机密的属性

属性是未加密的元数据,与机密和加密值一起存储在 webapps_secrets XML 文件中。

要设置机密 myusername 的值,请在系统命令行中输入:

webapps-secrets set myusername mluser
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
MATLAB Web App Server secrets configuration has been updated.

要设置机密 myusername 的属性,请在系统命令行中输入:

webapps-secrets set-attributes --secret-key myusername hostname myhost port 8080
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
MATLAB Web App Server secrets configuration has been updated.

您可以使用 --mode 运算符修改机密的现有属性。

webapps-secrets set-attributes --secret-key myusername port 422 --mode Merge
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
MATLAB Web App Server secrets configuration has been updated.

获取机密的属性

要检索机密 myusername 的属性,请在系统命令行中输入:

webapps-secrets get-attributes --secret-key myusername
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
List of secret keys configured:
    hostname --->myhost
    port --->422

按范围列出机密

要设置具有特定范围的机密,请在系统命令行中输入:

webapps-secrets set mysecret2 97e846a4-a913-4a26 --scope $UserID
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
MATLAB Web App Server secrets configuration has been updated.

要列出所有当前配置的范围为 $UserID 的机密,请在系统命令行中输入:

webapps-secrets list --scope $UserID
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
List of secret keys configured:
    scope:$UserID, secret key:mysecret2

列出所有机密

要列出所有当前配置的机密,请在系统命令行中输入:

webapps-secrets listAll
Vault location:C:\ProgramData\MathWorks\webapps\R2024b\config\webapps_private\webapps_secrets.xml
List of secret keys configured:
    scope:<default>, secret key:myusername
    scope:$UserID, secret key:mysecret2

显示帮助文本

要打印 webapps-secrets 帮助文本,请在系统命令行中输入:

webapps-secrets -h
Usage:
  webapps-secrets [--help | -h]
 Display this help message
  webapps-secrets [--version | -v]
 Display the version of MATLAB Web App Server
  webapps-secrets list  [--scope <value>]
 List currently configured secret keys
  webapps-secrets listAll
 List all currently configured secret keys in all scopes
  webapps-secrets set <key> <value> [--scope <value>] [--mode Overwrite|FailIfExists]
 Set a secret to MATLAB Web App Server
  webapps-secrets remove <key> [--scope <value>]
 Remove a secret key from MATLAB Web App Server
  webapps-secrets set-attributes --secret-key <secret_key> [<attr_key> <attr_value>] [--scope <value>] [--mode Add|Merge|Replace]    
 Set attributes of a secret to MATLAB Web App Server
  webapps-secrets get-attributes --secret-key <secret_key>  [--scope <value>]
 Get attributes of a secret from MATLAB Web App Server

显示版本

要打印 MATLAB® Web App Server™ 版本信息,请在系统命令行中输入:

webapps-secrets -v
MATLAB Web App Server (R2024b)

输入参数

全部折叠

用于标识机密的密钥名称,指定为唯一字符串。如果名称包含空格,则 keyName 必须用双引号 (") 括起来。

机密名称末尾支持通配符(*)。例如,"myapp1.*"

示例: "my password"

机密值,指定为字符串。该值已被加密并存储在 MATLAB Web App Server 保管库中。您可以使用 getSecret (MATLAB) 函数从 Web App 中检索值。

如果值包含空格,则 keyValue 必须用双引号 (") 括起来。

示例: "AdL3DS2$CyMEgCQQCo9+BpMoYQJxRF+j6ctTi3"

范围值,指定为任何静态字符串或带有宏的字符串。范围可以指定用户,群组或特定的 Web App 以允许访问指定的机密。

支持以下宏:

  • $UserID - 登录会话用户 ID。要使用此宏,您必须将 userinfo.json 包含在 config/webapps_private 目录中。有关详细信息,请参阅根据用户自定义 Web App 行为

  • $AppName - Web App 名称,其中包括 CTF 文件名和文件夹名称。

如果机密具有默认值以外的范围,则必须在调用 set-attributesget-attributeslistremove 时使用 --scope 参量指定范围值。

示例: "$AppName.$UserID"

属性名称,指定为字符串。属性是未加密的元数据,与机密名称和加密值一起存储在 webapps_secrets XML 文件中。属性名称描述关联的属性值,由 attrValue 指定。

示例: port

属性值,指定为字符串。属性是未加密的元数据,与机密名称和加密值一起存储在 webapps_secrets XML 文件中。属性值由关联的 attrName 描述。

示例: 8080

详细信息

全部折叠

版本历史记录

在 R2024a 中推出