microsoft / ReportingServicesTools

Reporting Services Powershell Tools
MIT License
456 stars 213 forks source link

Get-RsRestFolderContent warning "No XSRF Token detected! This might be due to XSRF token disabled." #365

Open stiankrey opened 2 years ago

stiankrey commented 2 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior? After the Power BI Report Server January 2022 release, RsRest methods have started issuing a warning: WARNING: No XSRF Token detected! This might be due to XSRF token disabled.

The command executes successfully, but the warning is confusing to our developers.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Connecting to Report Server instance and get the content of the root folder issues a warning:

$reportPortalUri = "https://<server>/reports"
Connect-RsReportServer -ReportPortalUri $reportPortalUri

Get-RsRestFolderContent -RsFolder "/"

After some digging, I found out that the XSRF-TOKEN set in the session-variable in Power BI Report Server September 2021 release contained the value "depreceated". In the Power BI Report Server January 2022 release, the XSRF-TOKEN is not present in the session-variable (and thus empty).

In the file "Functions/Utilities/New-RsRestSession.ps1", lines 106-109, a check is performed to check if the XSRF-TOKEN is null, and a warning is issued if that is the case:

if ($xsrfToken -eq $null)
        {
            Write-Warning "No XSRF Token detected! This might be due to XSRF token disabled."
        }

Since the XSRF-token is no longer present in the January 2022 release, the warning is issued.

Commenting out the check and warning in that file, removes the warning issued when executing RsRest commands. (I commented out lines 106-116)

What is the expected behavior? Expected behaviour would be no warning issued when RsRest commands are executed.

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts? Powershell version: 5.1.17763.2268 OS: Windows Server 2019

This worked in versions of Power BI Report Server prior to January 2022 release

kmramsey commented 8 months ago

This is still a bug in January 2023. Is it fixed in newer versions?