<< Click to Display Table of Contents >> RayVentory Data Hub > 12.6 u5 > Administration and User Guide > Advanced Topics Secure report parameters |
This is a cookbook, which demonstrates how to create secure links, that contain a locked-down version of the reports / dashboard parameters.
1.Refer to the guidelines outlined in the "Sharing Reports" chapter.
2.When you encounter prompts related to the two secure mode options, configure the settings as follows:
•Enable "Secure Mode" by checking the corresponding checkbox.
•To allow users to access the report even if they remove the encoded parameters from the URL, check the "Allow to see without parameters" option. Alternatively, if you want users to receive an error when attempting to access the report with manipulated links that lack encoded parameters, leave this option unchecked.
3.You will be presented with a public link and a corresponding public key (RSA PKCS#1).
4.Note down both values - this is the last time you are able to see them.
To programmatically generate a shared link, follow these steps:
1.Compile a list of parameters along with their corresponding values, including an additional parameter named "expire." Set the value of the "expire" parameter to a valid date and time until which the link should remain valid.
2.Ensure that the values are URL-compliant by encoding them.. For example, a space (" ") becomes %20.
3.Combine these parameter names and values by using an equal sign (=) , and then connect all pairs with an ampersand (&)
4.Encode the resulting string using an RSA PKCS#1 public key and convert it into a base64 format.
5.Append the base64-formatted string as a value of a params parameter to the public link.
Sample implementation in PowerShell:
$rsaPublicKey = [System.Security.Cryptography.RSACryptoServiceProvider]::new()
# Your public key
$publicKeyString = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2scvJBfTcUcFwuIefoQDPi45Y1bPcBjG1fWiAXgnA0YPJ4bWoT8tLX2VjMCh4khh2iOCEPCNz7S9dFxGiwNI46DjlSrU7P95ljnf+XYiN6uhwhrG13YEnuihrmSJTu5CqXONiCuFDrvxToZrwVMLdDO6IefoEmfG/fsEZct/T9hY21CRahmrDQUW7BBA4Nwf/3Vx8Bia/TgFuAs2Dt2d9I7ic4iKxDtqc7jQMCJvjo8FdvSzKxgdIWPD75H5T1N0+DRSHxkrFajrE458Rcr/Vgos/QsC3vwJS+feNzsD1YXqjyj6ieh0cJQotU3CzpEWxEXEJYXi4LNne0Pc0GFgEwIDAQAB";
# Your shared link
$yourSharedLink = "http://localhost:81/external/dashboard/5530a404-c579-44f8-8bdc-08db8e7c9c70?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJSZXBvcnRJZCI6IjU1MzBhNDA0LWM1NzktNDRmOC04YmRjLTA4ZGI4ZTdjOWM3MCIsIkFsbG93ZWRUb1NlZVdpdGhvdXRQYXJhbWV0ZXJzIjoiRmFsc2UiLCJSZWFkT25seU1vZGUiOiJUcnVlIiwiVGVuYW50SUQiOiI3MmJhNmZjMi1kNWZhLTQ5ZWUtODI4MS04NDFlNzYyYWVhMDUiLCJleHAiOjE2OTUwNDM1MjUsImlzcyI6IlJheW5ldCBHbWJIIiwiYXVkIjoiUmF5VmVudG9yeSBEYXRhIEh1YiBVc2VyIn0.2u4lfsbuwm5gpSITmukawxJHsBpxgrSdgWoaPccm2fI";
$yourParameters = @{
"Parameter1" = "Value 1"
"Parameter2" = "Value 2"
"Parameter3" = "Value 3"
};
# The expiration date - in this example 30 days from today
$expirationDate = (Get-Date).AddDays(30);
##########################################################
$parameterString = [System.Web.HttpUtility]::ParseQueryString("") # Create an empty query string
foreach ($key in $yourParameters.Keys) {
$value = $yourParameters[$key]
$parameterString.Add($key, $value)
}
$parameterString.Add("expire", $expirationDate.ToString("s"));
# Convert the query string to a URL-encoded string
$urlEncodedParameters = $parameterString.ToString()
$rsaPublicKey.ImportSubjectPublicKeyInfo([Convert]::FromBase64String($publicKeyString), [ref]$null)
$bytes = [System.Text.Encoding]::UTF8.GetBytes($urlEncodedParameters);
$encryptedBytes = $rsaPublicKey.Encrypt($bytes, $false);
$yourSharedLink + "¶ms=" + [System.Web.HttpUtility]::UrlEncode([Convert]::ToBase64String($encryptedBytes))