Main Content

webapps-secrets

Manage web app server secrets on Windows, Linux, and macOS systems

Since R2024a

Description

example

webapps-secrets set keyName keyValue [--mode Overwrite|FailIfExists] assigns the value keyValue to the secret keyName and adds the key to the vault. Optionally, you can configure whether to overwrite keyName or abort if the key already exists.

example

webapps-secrets remove keyName keyValue [--scope scopeValue] removes the secret keyName from the vault.

example

webapps-secrets set-attributes --secret-key keyName [attrName attrValue] [--scope scopeValue] [--mode Add|Merge|Replace] sets the attributes of the secret keyName. Optionally, you can configure whether to add new attributes to the key, merge the new and existing attributes, or replace all existing attributes with new ones.

example

webapps-secrets get-attributes --secret-key keyName [--scope scopeValue] returns the attributes of the secret with name keyName.

example

webapps-secrets list [--scope scopeValue] lists all currently configured secret keys in the scope scopeValue.

example

webapps-secrets listAll lists all currently configured secret keys in all scopes.

example

webapps-secrets --help displays help text for the command.

example

webapps-secrets --version displays version information for the command.

Examples

Set Value for Specific Secret Key

To set a value for a specific secret key, at the system command line, type:

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

Verify that the secret has been added.

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

Remove Secret from Server

To remove the existing secret key mypassword from the server, at the system command line, type:

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

Set Attributes for Secret Key

An attribute is unencrypted metadata that is stored along with the secret key and encrypted value in the webapps_secrets XML file.

To set a value for the secret key myusername, at the system command line, type:

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

To set attributes of the secret key myusername, at the system command line, type:

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

You can modify existing attributes of a secret key using the --mode operator.

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

Get Attributes for Secret Key

To retrieve the attributes for the secret key myusername, at the system command line, type:

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

List Secrets by Scope

To set a secret with a specific scope, at the system command line, type:

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

To list all currently configured secret keys with the scope $UserID, at the system command line, type:

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

List All Secrets

To list all currently configured secret keys, at the system command line, type:

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

Display Help Text

To print the webapps-secrets help text, at the system command line, type:

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

Display Version

To print the MATLAB® Web App Server™ version information, at the system command line, type:

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

Input Arguments

collapse all

Secret key name to identify the secret, specified as a unique string. If the name contains spaces, keyName must be surrounded by double quotes (").

Wildcards (*) are supported at the end of the secret name. For example, "myapp1.*".

Example: "my password"

Secret key value, specified as a string. The value is encrypted and stored in the MATLAB Web App Server vault. You can retrieve the value from a web app using the getSecret (MATLAB) function.

If the value contains spaces, keyValue must be surrounded by double quotes (").

Example: "AdL3DS2$CyMEgCQQCo9+BpMoYQJxRF+j6ctTi3"

Scope value, specified as any static string or a string with macros. The scope can specify users, groups, or specific web apps to allow access to the designated secret.

The following macros are supported:

  • $UserID—the log on session User ID. To use this macro, you must include userinfo.json in the config/webapps_private directory. For details, see Customize Web App Behavior Based on User.

  • $AppName—the web app name, which includes the CTF file name and folder name.

If a secret has a scope other than the default, you must specify the scope value using the --scope argument when calling set-attributes, get-attributes, list, or remove.

Example: "$AppName.$UserID"

Attribute name, specified as a string. An attribute is unencrypted metadata that is stored along with the secret key name and encrypted value in the webapps_secrets XML file. The attribute name describes the associated attribute value, specified by attrValue.

Example: port

Attribute value, specified as a string. An attribute is unencrypted metadata that is stored along with the secret key name and encrypted value in the webapps_secrets XML file. The attribute value is described by the associated attrName.

Example: 8080

More About

collapse all

MATLAB Web App Server Command-Line Script Location

The command-line scripts are located in the script folder in your MATLAB Web App Server installation folder. For instance, the default locations for R2024a are as follows:

Operating SystemDefault Location of Command-Line Scripts

Windows® (Administrator)

C:\Program Files\MATLAB\MATLAB Web App Server\R2024a\script

Linux® (sudo)

/usr/local/MATLAB/MATLAB_Web_App_Server/R2024a/script

macOS (Intel® processor) (sudo)

/Applications/MATLAB/MATLAB_Web_App_Server/R2024a/script

Version History

Introduced in R2024a