Storing Secrets for Scripts
Secrets provide a method to store passwords and other confidential data in QPR ProcessAnalyzer, and use them without being able to see the stored secret values. For example in scripts, SAP, Salesforce and ODBC passwords can be stored as secrets, which can be referred by their names in the script commands.
There are project-specific and global secrets. To use a secret, the user needs to have GenericRead permission to the project (or global GenericRead to use global secrets). To define a secret, the ManageProject permission to the project is needed (or global ManageProject to define global secrets). If both a global and a project-specific secret with the same name and type are set, the project-specific secret will be used in that project, and thus the global secret is unavailable for that project.
Each secret has a type which defines in which command the secret can be used. The purpose of the type is to improve security, so that the secret can only be used in the intended command.
Setting secrets
Secrets can be set by calling the SetSecret function for the project, or the corresponding generic context SetSecret function. Project secrets can also be defined in the Project Properties Dialog.
Example: Set a project secret (for project id 1):
ProjectById(1).SetSecret("sap", "SapAdminPassword", "I l0ve 5AP!");
Example: Set a global secret:
SetSecret("sap", "SapReaderPassword", "I l0ve 5AP!");
Listing secrets
To list all secrets in the project, use the Secrets property for the project. For the global secrets, there is the corresponding global Secrets property. Note that the secret value cannot be retrieved even by system administrators.
Example: List project secrets (for project id 1):
ToJson(ProjectById(1).Secrets);
Example: List global secrets:
ToJson(Secrets);
Using secrets
Secrets can be used in the following commands:
- SQL scripting commands: ImportOdbcQuery, ImportSalesforceQuery and ImportSapQuery
- ODBC datasources of model
- ImportODBCSecure function (expression language)
- CreateSnowflakeConnection function expression language
- CreateMeaConnection function in expression language
Note: Currently ImportSqlQuery and ImportOleDbQuery don't support secrets.
QPR MEA connection string
The secret type QprMea is used to store a connection string for connecting and authenticating to QPR Suite (MEA) Web Service (https://wiki.onqpr.com/mea/index.php/QPR_Suite_Wiki).
The connection string is a JSON object with the following fields:
- url: QPR Suite webservice url. The url typically ends with /QPR.Isapi.dll/wsforward/MainService.svc/webHttp.
- logOnName: QPR Suite username.
- password: QPR Suite user password.
Example:
{
"url": "https://hostname/QPR/Portal/QPR.Isapi.dll/wsforward/MainService.svc/webHttp",
"logOnName": "qpr",
"password": "demo"
}
OAuth 2.0 client credentials secret
The secret type OAuth20ClientCredentials defines parameters to authenticate using the OAuth 2.0 client credentials flow. The resourceServerEndpoint binds the access token to its intended resource server, so for security reasons the access token cannot be used to authenticate to any other service.
The secret value is a JSON object that can contain the following fields:
- resourceServerEndpoint: Required absolute HTTPS URL of the resource server for which the access token is issued. Each product function that supports this secure value type defines how the endpoint is used.
- tokenEndpoint: The (https) url of the OAuth token endpoint.
- clientId: Required OAuth client identifier.
- clientSecret: Required OAuth client secret.
- scope: Optional OAuth scope. Must not be specified together with the resource field.
- resource: Optional OAuth resource value. Must not be specified together with the scope field.
- audience: Optional audience value retained in the configuration. It is not sent in the token request.
Example:
{
"resourceServerEndpoint": "...",
"tokenEndpoint": "...",
"clientId": "...",
"clientSecret": "...",
"scope": "...",
"resource": "...",
"audience": "..."
}