I created an unauthenticated API Endpoint "/getData" which uses variables and the $Secret scope to connect to other APIs and return aggregated data.
Issue1: the endpoint could not read all secrets and threw a security exception despite none of them had any role restrictions. Recreating the secrets worked, so some update must have corrupted the permission requirements of the secrets. Not sure if this is worth looking into.
Issue2: the endpoint needs to run an internal script viaInvoke-PSUScript -Integrated -Script 'AuthorizeToAPI.ps1' -Wait that handles the authentication to that external API. That script is able to be run unauthenticated, but needs update variables/secrets. This is what I used:
$AccessTokenVar = Get-PSUVariable -Name "AccessToken"
$AccessTokenLifetimeVar = Get-PSUVariable -Name "AccessTokenLifetime"
$TokenResponse = Invoke-RestMethod "<externalAPIauthentication>" -Method 'POST' -Headers $Headers -Body $Body
Set-PSUVariable -Variable $AccessTokenVar -Value $TokenResponse.Token
Set-PSUVariable -Variable $AccessTokenLifetimeVar -Value $TokenResponse.LifeTimewhich worked fine until the last update and suddenly returns an error:
Permission denied. The role specified does not have access to this resource.
Since Issue1 clearly pointed to some update corrupting role requirements to variables, I m at a loss on what is intended behavior and what is not. Are integrated scripts not able to use Get/Set-PSUVariable or did more permissions get corrupted?
Help would be much appreciated :)
Issue1: the endpoint could not read all secrets and threw a security exception despite none of them had any role restrictions. Recreating the secrets worked, so some update must have corrupted the permission [...]
This is not the intended behavior. If recreating the secret worked then yes, the root cause is most likely that those permissions became corrupted somehow. It is unlikely the issue is related to a product update, but we can certainly keep drilling into this 🔎
Issue2: the endpoint needs to run an internal script [...]
Integrated scripts may use Get-PSUVariable & Set-PSUVariable.
Help would be much appreciated :)
Could we try comparing json exports of known good variables vs. seemingly corrupted ones?
Seems like the "system" User is not able to useGet-PSUVariable & Set-PSUVariablefor those variables:

If I run it myself it does work (the warning is fine), but if the system user runs it (via Invoke-PSUScript -Integrated ...) it can not access the variables.
The variables however, are unrestricted:


Is this a bug?
Could we try comparing json exports of known good variables vs. seemingly corrupted ones?
I can not find a way to export variables to compare them.
Seems like the "system" User is not able to useGet-PSUVariable & Set-PSUVariablefor those variables:

If I run it myself it does work (the warning is fine), but if the system user runs it (via Invoke-PSUScript -Integrated ...) it can not access the variables.
The variables however, are unrestricted:


Is this a bug?
Could we try comparing json exports of known good variables vs. seemingly corrupted ones?
I can not find a way to export variables to compare them.
Can you confirm which version of PSU you had before and what version you upgraded to? Below is a metadata-only snippet to show us more. Could you run the below code from sebi context and share the results?
$names = 'M42AccessToken', 'M42AccessTokenLifetime'
$names | ForEach-Object {
$variable = Get-PSUVariable -Name $_
[pscustomobject]@{
Name = $variable.Name
Secret = $variable.Secret
Vault = $variable.Vault
Database = $variable.Database
Role = $variable.Role
Roles = @($variable.Roles) -join ','
Scope = $variable.Scope
Module = $variable.Module
MissingSecret = $variable.MissingSecret
DisableRunAsSupport = $variable.DisableRunAsSupport
ReadOnly = $variable.ReadOnly
}
} | ConvertTo-Json -Depth 5