Storing Secrets for Scripts: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
Line 5: Line 5:
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.
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 and listing secrets ==
== Setting secrets ==
Secrets can be set by calling the [[QPR_ProcessAnalyzer_Objects_in_Expression_Language#SetSecret|SetSecret]] function for the project, or the corresponding generic context [[Generic_Functions_in_QPR_ProcessAnalyzer#SetSecret|SetSecret]] function.
Secrets can be set by calling the [[QPR_ProcessAnalyzer_Objects_in_Expression_Language#SetSecret|SetSecret]] function for the project, or the corresponding generic context [[Generic_Functions_in_QPR_ProcessAnalyzer#SetSecret|SetSecret]] function.


There is a property [[QPR_ProcessAnalyzer_Objects_in_Expression_Language#Project|Secrets]] for projects to list all secrets in the project. For the global secrets, there is the corresponding global [[Generic_Properties_in_Expression_Language#Secrets|Secrets]] property. Note that the secret value cannot be retrieved even by system administrators.
Example: Set a project secret (for project id 1):
<pre>
ProjectById(1).SetSecret("sap", "SapAdminPassword", "I l0ve 5AP!");
</pre>


Example: Set a global and a project-specific secret:
Example: Set a global secret:
<pre>
<pre>
SetSecret("sap", "SapReaderPassword", "I l0ve 5AP!");
SetSecret("sap", "SapReaderPassword", "I l0ve 5AP!");
ProjectById(1).SetSecret("sap", "SapAdminPassword", "I l0ve 5AP!");
</pre>
</pre>


Example: Show global secrets:
== Listing secrets ==
To list all secrets in the project, there is a property [[QPR_ProcessAnalyzer_Objects_in_Expression_Language#Project|Secrets]] for projects. For the global secrets, there is the corresponding global [[Generic_Properties_in_Expression_Language#Secrets|Secrets]] property. Note that the secret value cannot be retrieved even by system administrators.
 
Example: Show project secrets (for project id 1):
<pre>
<pre>
ToJson(Secrets);
ToJson(ProjectById(1).Secrets);
</pre>
</pre>


Example: Show project's secret:
Example: Show global secrets:
<pre>
<pre>
ToJson(ProjectById(1).Secrets);
ToJson(Secrets);
</pre>
</pre>



Revision as of 10:40, 12 May 2025

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.

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, there is a property Secrets for projects. For the global secrets, there is the corresponding global Secrets property. Note that the secret value cannot be retrieved even by system administrators.

Example: Show project secrets (for project id 1):

ToJson(ProjectById(1).Secrets);

Example: Show global secrets:

ToJson(Secrets);

Using secrets

Secrets can be used in the following commands:

Note: Currently ImportSqlQuery and ImportOleDbQuery don't yet support the secrets.